From 23b10108b56a851debb4d1e142e64b6d155e1fc3 Mon Sep 17 00:00:00 2001 From: midipix Date: Sat, 23 Jun 2018 01:35:08 -0400 Subject: driver: added slbt_output_features(), providing compatible --features output. --- src/driver/slbt_amain.c | 3 +++ src/driver/slbt_driver_ctx.c | 39 ++++++++++++++++++++++++++++++-------- src/output/slbt_output_features.c | 40 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 74 insertions(+), 8 deletions(-) create mode 100644 src/output/slbt_output_features.c (limited to 'src') diff --git a/src/driver/slbt_amain.c b/src/driver/slbt_amain.c index 48133b0..7d4a5a9 100644 --- a/src/driver/slbt_amain.c +++ b/src/driver/slbt_amain.c @@ -56,6 +56,9 @@ static void slbt_perform_driver_actions(struct slbt_driver_ctx * dctx) if (dctx->cctx->drvflags & SLBT_DRIVER_CONFIG) slbt_output_config(dctx); + if (dctx->cctx->drvflags & SLBT_DRIVER_FEATURES) + slbt_output_features(dctx); + if (dctx->cctx->mode == SLBT_MODE_COMPILE) slbt_exec_compile(dctx,0); diff --git a/src/driver/slbt_driver_ctx.c b/src/driver/slbt_driver_ctx.c index 2f08895..5b11848 100644 --- a/src/driver/slbt_driver_ctx.c +++ b/src/driver/slbt_driver_ctx.c @@ -45,6 +45,10 @@ static const char cfgnmachine[] = "native (derived from -dumpmachine)"; static const char cfgxmachine[] = "foreign (derived from -dumpmachine)"; static const char cfgnative[] = "native"; + +/* default compiler argv */ +static char * slbt_default_cargv[] = {"cc",0}; + /* elf rpath */ static const char*ldrpath_elf[] = { "/lib", @@ -191,6 +195,7 @@ static int slbt_split_argv( struct argv_entry * mode; struct argv_entry * config; struct argv_entry * finish; + struct argv_entry * features; const struct argv_option ** popt; const struct argv_option ** optout; const struct argv_option * optv[SLBT_OPTV_ELEMENTS]; @@ -219,24 +224,32 @@ static int slbt_split_argv( } /* obtain slibtool's own arguments */ - compiler = argv[ctx.unitidx]; - argv[ctx.unitidx] = 0; + if (ctx.unitidx) { + compiler = argv[ctx.unitidx]; + argv[ctx.unitidx] = 0; + + meta = argv_get(argv,optv,ARGV_VERBOSITY_NONE); + argv[ctx.unitidx] = compiler; + } else { + meta = argv_get(argv,optv,ARGV_VERBOSITY_NONE); + } - meta = argv_get(argv,optv,ARGV_VERBOSITY_NONE); - argv[ctx.unitidx] = compiler; + /* missing all of --mode, --config, --features, and --finish? */ + mode = config = finish = features = 0; - /* missing all of --mode, --config, and --finish? */ - for (mode=0, config=0, finish=0, entry=meta->entries; entry->fopt; entry++) + for (entry=meta->entries; entry->fopt; entry++) if (entry->tag == TAG_MODE) mode = entry; else if (entry->tag == TAG_CONFIG) config = entry; else if (entry->tag == TAG_FINISH) finish = entry; + else if (entry->tag == TAG_FEATURES) + features = entry; argv_free(meta); - if (!mode && !config && !finish) { + if (!mode && !config && !finish && !features) { fprintf(stderr, "%s: error: --mode must be specified.\n", program); @@ -244,7 +257,7 @@ static int slbt_split_argv( } /* missing compiler? */ - if (!ctx.unitidx && !finish) { + if (!ctx.unitidx && !finish && !features) { if (flags & SLBT_DRIVER_VERBOSITY_ERRORS) fprintf(stderr, "%s: error: is missing.\n", @@ -261,6 +274,16 @@ static int slbt_split_argv( else return -1; + /* --features and no ? */ + if (features && !ctx.unitidx) { + for (i=0; itargv[i] = argv[i]; + + sargv->cargv = slbt_default_cargv; + + return 0; + } + /* split vectors: slibtool's own options */ for (i=0; itargv[i] = argv[i]; diff --git a/src/output/slbt_output_features.c b/src/output/slbt_output_features.c new file mode 100644 index 0000000..b0252fa --- /dev/null +++ b/src/output/slbt_output_features.c @@ -0,0 +1,40 @@ +/*******************************************************************/ +/* slibtool: a skinny libtool implementation, written in C */ +/* Copyright (C) 2016--2017 Z. Gilboa */ +/* Released under the Standard MIT License; see COPYING.SLIBTOOL. */ +/*******************************************************************/ + +#include +#include +#include + +#include +#include "slibtool_errinfo_impl.h" + +static const char enable[] = "enable"; +static const char disable[] = "disable"; + +int slbt_output_features(const struct slbt_driver_ctx * dctx) +{ + const char * shared_option; + const char * static_option; + + shared_option = (dctx->cctx->drvflags & SLBT_DRIVER_DISABLE_SHARED) + ? disable : enable; + + static_option = (dctx->cctx->drvflags & SLBT_DRIVER_DISABLE_STATIC) + ? disable : enable; + + if (fprintf(stdout,"host: %s\n",dctx->cctx->host.host) < 0) + return SLBT_SYSTEM_ERROR(dctx); + + if (fprintf(stdout,"%s shared libraries\n",shared_option) < 0) + return SLBT_SYSTEM_ERROR(dctx); + + if (fprintf(stdout,"%s static libraries\n",static_option) < 0) + return SLBT_SYSTEM_ERROR(dctx); + + return fflush(stdout) + ? SLBT_SYSTEM_ERROR(dctx) + : 0; +} -- cgit v1.2.3