summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2024-03-25 03:06:17 +0000
committermidipix <writeonce@midipix.org>2024-03-25 03:06:17 +0000
commit967a1129d8c132693a0fed71ed7363fdfcf8f397 (patch)
tree5a5bc6d5f5c1105f1e1bbdd73a4e7247eb80d88b
parent83bcd3a56a9be8ef0f19c5682793697569b1724f (diff)
downloadslibtool-967a1129d8c132693a0fed71ed7363fdfcf8f397.tar.bz2
slibtool-967a1129d8c132693a0fed71ed7363fdfcf8f397.tar.xz
slibtoolize mode: integrated context creation, support multiple target dirs.
-rw-r--r--src/logic/slbt_exec_stoolie.c66
1 files changed, 57 insertions, 9 deletions
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 <sys/stat.h>
#include <slibtool/slibtool.h>
#include <slibtool/slibtool_output.h>
#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? */
+ /* <stoolie> 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);
-
- /* <stoolie> 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);