From 967a1129d8c132693a0fed71ed7363fdfcf8f397 Mon Sep 17 00:00:00 2001 From: midipix Date: Mon, 25 Mar 2024 03:06:17 +0000 Subject: slibtoolize mode: integrated context creation, support multiple target dirs. --- src/logic/slbt_exec_stoolie.c | 66 +++++++++++++++++++++++++++++++++++++------ 1 file changed, 57 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/logic/slbt_exec_stoolie.c b/src/logic/slbt_exec_stoolie.c index 45aa76d..e9f1d15 100644 --- a/src/logic/slbt_exec_stoolie.c +++ b/src/logic/slbt_exec_stoolie.c @@ -4,6 +4,7 @@ /* Released under the Standard MIT License; see COPYING.SLIBTOOL. */ /*******************************************************************/ +#include #include #include #include "slibtool_driver_impl.h" @@ -11,6 +12,8 @@ #include "slibtool_errinfo_impl.h" #include "argv/argv.h" +static const char slbt_this_dir[2] = {'.',0}; + static int slbt_stoolie_usage( int fdout, const char * program, @@ -79,6 +82,11 @@ int slbt_exec_stoolie(const struct slbt_driver_ctx * dctx) struct argv_meta * meta; struct argv_entry * entry; size_t nunits; + size_t cunits; + const char ** unitv; + const char ** unitp; + struct slbt_stoolie_ctx ** stctxv; + struct slbt_stoolie_ctx ** stctxp; const struct argv_option * optv[SLBT_OPTV_ELEMENTS]; /* context */ @@ -98,17 +106,9 @@ int slbt_exec_stoolie(const struct slbt_driver_ctx * dctx) (void)fderr; - /* missing arguments? */ + /* argv meta */ slbt_optv_init(slbt_stoolie_options,optv); - if (!iargv[1] && (dctx->cctx->drvflags & SLBT_DRIVER_VERBOSITY_USAGE)) - return slbt_stoolie_usage( - fdout, - dctx->program, - 0,optv,0,ectx, - dctx->cctx->drvflags & SLBT_DRIVER_ANNOTATE_NEVER); - - /* argv meta */ if (!(meta = slbt_argv_get( iargv,optv, dctx->cctx->drvflags & SLBT_DRIVER_VERBOSITY_ERRORS @@ -192,10 +192,58 @@ int slbt_exec_stoolie(const struct slbt_driver_ctx * dctx) return SLBT_OK; } + /* default to this-dir as needed */ + if (!(cunits = nunits)) + nunits++; + + /* slibtoolize target directory vector allocation */ + if (!(stctxv = calloc(nunits+1,sizeof(struct slbt_stoolie_ctx *)))) + return slbt_exec_stoolie_fail( + ectx,meta, + SLBT_SYSTEM_ERROR(dctx,0)); + + /* unit vector allocation */ + if (!(unitv = calloc(nunits+1,sizeof(const char *)))) { + free (stctxv); + + return slbt_exec_stoolie_fail( + ectx,meta, + SLBT_SYSTEM_ERROR(dctx,0)); + } + + /* unit vector initialization */ + for (entry=meta->entries,unitp=unitv; entry->fopt || entry->arg; entry++) + if (!entry->fopt) + *unitp++ = entry->arg; + + if (!cunits) + unitp[0] = slbt_this_dir; + + /* slibtoolize target directory vector initialization */ + for (unitp=unitv,stctxp=stctxv; *unitp; unitp++,stctxp++) { + if (slbt_st_get_stoolie_ctx(dctx,*unitp,stctxp) < 0) { + for (stctxp=stctxv; *stctxp; stctxp++) + slbt_st_free_stoolie_ctx(*stctxp); + + free(unitv); + free(stctxv); + + return slbt_exec_stoolie_fail( + ectx,meta, + SLBT_NESTED_ERROR(dctx)); + } + } + /* slibtoolize operations */ ret = slbt_exec_stoolie_perform_actions(dctx); /* all done */ + for (stctxp=stctxv; *stctxp; stctxp++) + slbt_st_free_stoolie_ctx(*stctxp); + + free(unitv); + free(stctxv); + slbt_argv_free(meta); slbt_ectx_free_exec_ctx(ectx); -- cgit v1.2.3