diff --git a/include/slibtool/slibtool.h b/include/slibtool/slibtool.h index 4ca7064..a21f54c 100644 --- a/include/slibtool/slibtool.h +++ b/include/slibtool/slibtool.h @@ -38,7 +38,7 @@ extern "C" { #define SLBT_DRIVER_VERSION 0x0010 #define SLBT_DRIVER_DRY_RUN 0x0020 -#define SLBT_DRIVER_CONFIG 0x0040 +#define SLBT_DRIVER_INFO 0x0040 #define SLBT_DRIVER_DEBUG 0x0080 #define SLBT_DRIVER_FEATURES 0x0100 #define SLBT_DRIVER_DEPS 0x0200 @@ -399,7 +399,7 @@ slbt_api int slbt_store_archive (struct slbt_archive_ctx *, slbt_api int slbt_main (char **, char **, const struct slbt_fd_ctx *); -slbt_api int slbt_output_config (const struct slbt_driver_ctx *); +slbt_api int slbt_output_info (const struct slbt_driver_ctx *); slbt_api int slbt_output_machine (const struct slbt_driver_ctx *); slbt_api int slbt_output_features (const struct slbt_driver_ctx *); slbt_api int slbt_output_fdcwd (const struct slbt_driver_ctx *); diff --git a/project/common.mk b/project/common.mk index ead6410..29fe375 100644 --- a/project/common.mk +++ b/project/common.mk @@ -35,11 +35,11 @@ API_SRCS = \ src/logic/linkcmd/slbt_linkcmd_executable.c \ src/logic/linkcmd/slbt_linkcmd_host.c \ src/logic/linkcmd/slbt_linkcmd_implib.c \ - src/output/slbt_output_config.c \ src/output/slbt_output_error.c \ src/output/slbt_output_exec.c \ src/output/slbt_output_fdcwd.c \ src/output/slbt_output_features.c \ + src/output/slbt_output_info.c \ src/output/slbt_output_machine.c \ src/skin/slbt_skin_ar.c \ src/skin/slbt_skin_default.c \ diff --git a/src/driver/slbt_amain.c b/src/driver/slbt_amain.c index d89884d..0136625 100644 --- a/src/driver/slbt_amain.c +++ b/src/driver/slbt_amain.c @@ -59,8 +59,8 @@ static ssize_t slbt_version(struct slbt_driver_ctx * dctx, int fdout) 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_INFO) + slbt_output_info(dctx); if (dctx->cctx->drvflags & SLBT_DRIVER_FEATURES) slbt_output_features(dctx); diff --git a/src/driver/slbt_driver_ctx.c b/src/driver/slbt_driver_ctx.c index c2ff1d0..d03d1ed 100644 --- a/src/driver/slbt_driver_ctx.c +++ b/src/driver/slbt_driver_ctx.c @@ -488,8 +488,8 @@ int slbt_get_driver_ctx( cmdnoshared = entry; break; - case TAG_CONFIG: - cctx.drvflags |= SLBT_DRIVER_CONFIG; + case TAG_INFO: + cctx.drvflags |= SLBT_DRIVER_INFO; break; case TAG_DUMPMACHINE: @@ -773,7 +773,7 @@ int slbt_get_driver_ctx( } /* info mode */ - if (cctx.drvflags & (SLBT_DRIVER_CONFIG | SLBT_DRIVER_FEATURES)) + if (cctx.drvflags & (SLBT_DRIVER_INFO | SLBT_DRIVER_FEATURES)) cctx.mode = SLBT_MODE_INFO; /* --tag */ diff --git a/src/driver/slbt_split_argv.c b/src/driver/slbt_split_argv.c index 2ad62ca..946468e 100644 --- a/src/driver/slbt_split_argv.c +++ b/src/driver/slbt_split_argv.c @@ -51,7 +51,7 @@ int slbt_split_argv( struct argv_entry * mode; struct argv_entry * help; struct argv_entry * version; - struct argv_entry * config; + struct argv_entry * info; struct argv_entry * finish; struct argv_entry * features; struct argv_entry * ccwrap; @@ -117,8 +117,8 @@ int slbt_split_argv( return -1; } - /* missing all of --mode, --help, --version, --config, --dumpmachine, --features, and --finish? */ - mode = help = version = config = finish = features = ccwrap = dumpmachine = aropt = 0; + /* missing all of --mode, --help, --version, --info, --dumpmachine, --features, and --finish? */ + mode = help = version = info = finish = features = ccwrap = dumpmachine = aropt = 0; for (entry=meta->entries; entry->fopt; entry++) if (entry->tag == TAG_MODE) @@ -127,8 +127,8 @@ int slbt_split_argv( help = entry; else if (entry->tag == TAG_VERSION) version = entry; - else if (entry->tag == TAG_CONFIG) - config = entry; + else if (entry->tag == TAG_INFO) + info = entry; else if (entry->tag == TAG_FINISH) finish = entry; else if (entry->tag == TAG_FEATURES) @@ -155,7 +155,7 @@ int slbt_split_argv( return -1; } - if (!mode && !help && !version && !config && !finish && !features && !dumpmachine && !altmode) { + if (!mode && !help && !version && !info && !finish && !features && !dumpmachine && !altmode) { slbt_dprintf(fderr, "%s: error: --mode must be specified.\n", program); diff --git a/src/internal/slibtool_driver_impl.h b/src/internal/slibtool_driver_impl.h index cff9656..f633adf 100644 --- a/src/internal/slibtool_driver_impl.h +++ b/src/internal/slibtool_driver_impl.h @@ -24,7 +24,7 @@ enum app_tags { TAG_HELP, TAG_HELP_ALL, TAG_VERSION, - TAG_CONFIG, + TAG_INFO, TAG_DUMPMACHINE, TAG_DEBUG, TAG_DRY_RUN, diff --git a/src/output/slbt_output_config.c b/src/output/slbt_output_config.c deleted file mode 100644 index 71389e2..0000000 --- a/src/output/slbt_output_config.c +++ /dev/null @@ -1,114 +0,0 @@ -/*******************************************************************/ -/* slibtool: a skinny libtool implementation, written in C */ -/* Copyright (C) 2016--2024 SysDeer Technologies, LLC */ -/* Released under the Standard MIT License; see COPYING.SLIBTOOL. */ -/*******************************************************************/ - -#include -#include -#include - -#include -#include "slibtool_driver_impl.h" -#include "slibtool_dprintf_impl.h" -#include "slibtool_errinfo_impl.h" - -#ifndef SLBT_TAB_WIDTH -#define SLBT_TAB_WIDTH 8 -#endif - -#ifndef SLBT_KEY_WIDTH -#define SLBT_KEY_WIDTH 16 -#endif - -static bool slbt_output_config_line( - int fd, - const char * key, - const char * value, - const char * annotation, - int midwidth) -{ - return (slbt_dprintf(fd,"%-*s%-*s%s\n", - SLBT_KEY_WIDTH, key, - midwidth, value ? value : "", - annotation ? annotation : "") < 0) - ? true : false; -} - -int slbt_output_config(const struct slbt_driver_ctx * dctx) -{ - const struct slbt_common_ctx * cctx; - const char * compiler; - const char * target; - int len; - int midwidth; - int fdout; - - cctx = dctx->cctx; - compiler = cctx->cargv[0] ? cctx->cargv[0] : ""; - target = cctx->target ? cctx->target : ""; - midwidth = strlen(compiler); - fdout = slbt_driver_fdout(dctx); - - if ((len = strlen(target)) > midwidth) - midwidth = len; - - if ((len = strlen(cctx->host.host)) > midwidth) - midwidth = len; - - if ((len = strlen(cctx->host.flavor)) > midwidth) - midwidth = len; - - if ((len = strlen(cctx->host.ar)) > midwidth) - midwidth = len; - - if ((len = strlen(cctx->host.ranlib)) > midwidth) - midwidth = len; - - if ((len = strlen(cctx->host.windres)) > midwidth) - midwidth = len; - - if ((len = strlen(cctx->host.dlltool)) > midwidth) - midwidth = len; - - if ((len = strlen(cctx->host.mdso)) > midwidth) - midwidth = len; - - midwidth += SLBT_TAB_WIDTH; - midwidth &= (~(SLBT_TAB_WIDTH-1)); - - if (slbt_output_config_line(fdout,"key","value","annotation",midwidth)) - return SLBT_SYSTEM_ERROR(dctx,0); - - if (slbt_output_config_line(fdout,"---","-----","----------",midwidth)) - return SLBT_SYSTEM_ERROR(dctx,0); - - if (slbt_output_config_line(fdout,"compiler",cctx->cargv[0],"",midwidth)) - return SLBT_SYSTEM_ERROR(dctx,0); - - if (slbt_output_config_line(fdout,"target",cctx->target,"",midwidth)) - return SLBT_SYSTEM_ERROR(dctx,0); - - if (slbt_output_config_line(fdout,"host",cctx->host.host,cctx->cfgmeta.host,midwidth)) - return SLBT_SYSTEM_ERROR(dctx,0); - - if (slbt_output_config_line(fdout,"flavor",cctx->host.flavor,cctx->cfgmeta.flavor,midwidth)) - return SLBT_SYSTEM_ERROR(dctx,0); - - if (slbt_output_config_line(fdout,"ar",cctx->host.ar,cctx->cfgmeta.ar,midwidth)) - return SLBT_SYSTEM_ERROR(dctx,0); - - if (slbt_output_config_line(fdout,"ranlib",cctx->host.ranlib,cctx->cfgmeta.ranlib,midwidth)) - return SLBT_SYSTEM_ERROR(dctx,0); - - if (slbt_output_config_line(fdout,"windres",cctx->host.windres,cctx->cfgmeta.windres,midwidth)) - return SLBT_SYSTEM_ERROR(dctx,0); - - if (slbt_output_config_line(fdout,"dlltool",cctx->host.dlltool,cctx->cfgmeta.dlltool,midwidth)) - return SLBT_SYSTEM_ERROR(dctx,0); - - if (slbt_output_config_line(fdout,"mdso",cctx->host.mdso,cctx->cfgmeta.mdso,midwidth)) - return SLBT_SYSTEM_ERROR(dctx,0); - - return 0; -} diff --git a/src/output/slbt_output_info.c b/src/output/slbt_output_info.c new file mode 100644 index 0000000..7498cb8 --- /dev/null +++ b/src/output/slbt_output_info.c @@ -0,0 +1,114 @@ +/*******************************************************************/ +/* slibtool: a skinny libtool implementation, written in C */ +/* Copyright (C) 2016--2024 SysDeer Technologies, LLC */ +/* Released under the Standard MIT License; see COPYING.SLIBTOOL. */ +/*******************************************************************/ + +#include +#include +#include + +#include +#include "slibtool_driver_impl.h" +#include "slibtool_dprintf_impl.h" +#include "slibtool_errinfo_impl.h" + +#ifndef SLBT_TAB_WIDTH +#define SLBT_TAB_WIDTH 8 +#endif + +#ifndef SLBT_KEY_WIDTH +#define SLBT_KEY_WIDTH 16 +#endif + +static bool slbt_output_info_line( + int fd, + const char * key, + const char * value, + const char * annotation, + int midwidth) +{ + return (slbt_dprintf(fd,"%-*s%-*s%s\n", + SLBT_KEY_WIDTH, key, + midwidth, value ? value : "", + annotation ? annotation : "") < 0) + ? true : false; +} + +int slbt_output_info(const struct slbt_driver_ctx * dctx) +{ + const struct slbt_common_ctx * cctx; + const char * compiler; + const char * target; + int len; + int midwidth; + int fdout; + + cctx = dctx->cctx; + compiler = cctx->cargv[0] ? cctx->cargv[0] : ""; + target = cctx->target ? cctx->target : ""; + midwidth = strlen(compiler); + fdout = slbt_driver_fdout(dctx); + + if ((len = strlen(target)) > midwidth) + midwidth = len; + + if ((len = strlen(cctx->host.host)) > midwidth) + midwidth = len; + + if ((len = strlen(cctx->host.flavor)) > midwidth) + midwidth = len; + + if ((len = strlen(cctx->host.ar)) > midwidth) + midwidth = len; + + if ((len = strlen(cctx->host.ranlib)) > midwidth) + midwidth = len; + + if ((len = strlen(cctx->host.windres)) > midwidth) + midwidth = len; + + if ((len = strlen(cctx->host.dlltool)) > midwidth) + midwidth = len; + + if ((len = strlen(cctx->host.mdso)) > midwidth) + midwidth = len; + + midwidth += SLBT_TAB_WIDTH; + midwidth &= (~(SLBT_TAB_WIDTH-1)); + + if (slbt_output_info_line(fdout,"key","value","annotation",midwidth)) + return SLBT_SYSTEM_ERROR(dctx,0); + + if (slbt_output_info_line(fdout,"---","-----","----------",midwidth)) + return SLBT_SYSTEM_ERROR(dctx,0); + + if (slbt_output_info_line(fdout,"compiler",cctx->cargv[0],"",midwidth)) + return SLBT_SYSTEM_ERROR(dctx,0); + + if (slbt_output_info_line(fdout,"target",cctx->target,"",midwidth)) + return SLBT_SYSTEM_ERROR(dctx,0); + + if (slbt_output_info_line(fdout,"host",cctx->host.host,cctx->cfgmeta.host,midwidth)) + return SLBT_SYSTEM_ERROR(dctx,0); + + if (slbt_output_info_line(fdout,"flavor",cctx->host.flavor,cctx->cfgmeta.flavor,midwidth)) + return SLBT_SYSTEM_ERROR(dctx,0); + + if (slbt_output_info_line(fdout,"ar",cctx->host.ar,cctx->cfgmeta.ar,midwidth)) + return SLBT_SYSTEM_ERROR(dctx,0); + + if (slbt_output_info_line(fdout,"ranlib",cctx->host.ranlib,cctx->cfgmeta.ranlib,midwidth)) + return SLBT_SYSTEM_ERROR(dctx,0); + + if (slbt_output_info_line(fdout,"windres",cctx->host.windres,cctx->cfgmeta.windres,midwidth)) + return SLBT_SYSTEM_ERROR(dctx,0); + + if (slbt_output_info_line(fdout,"dlltool",cctx->host.dlltool,cctx->cfgmeta.dlltool,midwidth)) + return SLBT_SYSTEM_ERROR(dctx,0); + + if (slbt_output_info_line(fdout,"mdso",cctx->host.mdso,cctx->cfgmeta.mdso,midwidth)) + return SLBT_SYSTEM_ERROR(dctx,0); + + return 0; +} diff --git a/src/skin/slbt_skin_default.c b/src/skin/slbt_skin_default.c index e904e84..cf4675c 100644 --- a/src/skin/slbt_skin_default.c +++ b/src/skin/slbt_skin_default.c @@ -39,8 +39,8 @@ const struct argv_option slbt_default_options[] = { "a universal playground game; " "currently accepted tags are {%s}"}, - {"config", 0,TAG_CONFIG,ARGV_OPTARG_NONE,0,0,0, - "display configuration information"}, + {"info", 0,TAG_INFO,ARGV_OPTARG_NONE,0,0,0, + "display detected (or cached) environment information"}, {"debug", 0,TAG_DEBUG,ARGV_OPTARG_NONE,0,0,0, "display internal debug information"},