summaryrefslogtreecommitdiff
path: root/src/driver/slbt_driver_ctx.c
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2024-02-16 05:54:17 +0000
committermidipix <writeonce@midipix.org>2024-02-16 05:59:56 +0000
commit2611275c5f0a180c96963c9b1c4d2f1d76a04b5d (patch)
tree122822fb588318e0a9968c5a98d3c94c4e67c6a4 /src/driver/slbt_driver_ctx.c
parentd895920cf970aa2f8a23530334e1eebd649cc615 (diff)
downloadslibtool-2611275c5f0a180c96963c9b1c4d2f1d76a04b5d.tar.bz2
slibtool-2611275c5f0a180c96963c9b1c4d2f1d76a04b5d.tar.xz
driver: host.ar, host.ranlib: added support for tool-specific argument vector.
Diffstat (limited to 'src/driver/slbt_driver_ctx.c')
-rw-r--r--src/driver/slbt_driver_ctx.c65
1 files changed, 65 insertions, 0 deletions
diff --git a/src/driver/slbt_driver_ctx.c b/src/driver/slbt_driver_ctx.c
index 82514bc..bbc1dd9 100644
--- a/src/driver/slbt_driver_ctx.c
+++ b/src/driver/slbt_driver_ctx.c
@@ -317,6 +317,64 @@ static int slbt_driver_fail_incompatible_args(
return slbt_get_driver_ctx_fail(0,meta);
}
+
+static int slbt_driver_parse_tool_argv(const char * tool, char *** tool_argv)
+{
+ int argc;
+ char ** argv;
+ const char * ch;
+ const char * mark;
+
+ if (!(ch = tool))
+ return 0;
+
+ argc = 1;
+
+ for (; *ch == ' '; )
+ ch++;
+
+ for (; *ch; ) {
+ if (*ch++ == ' ') {
+ argc++;
+
+ for (; (*ch == ' '); )
+ ch++;
+ }
+ }
+
+ if (argc == 1)
+ return 0;
+
+ if (!(*tool_argv = calloc(++argc,sizeof(char *))))
+ return -1;
+
+ for (ch=tool; (*ch == ' '); ch++)
+ (void)0;
+
+ argv = *tool_argv;
+ mark = ch;
+
+ for (; *ch; ) {
+ if (*ch == ' ') {
+ if (!(*argv++ = strndup(mark,ch-mark)))
+ return -1;
+
+ for (; (*ch == ' '); )
+ ch++;
+
+ mark = ch;
+ } else {
+ ch++;
+ }
+ }
+
+ if (!(*argv++ = strndup(mark,ch-mark)))
+ return -1;
+
+ return 0;
+}
+
+
int slbt_get_driver_ctx(
char ** argv,
char ** envp,
@@ -883,6 +941,13 @@ int slbt_get_driver_ctx(
cfgmeta_dlltool))
return slbt_get_driver_ctx_fail(&ctx->ctx,0);
+ /* host tool arguments */
+ if (slbt_driver_parse_tool_argv(ctx->cctx.host.ar,&ctx->host.ar_argv) < 0)
+ return slbt_get_driver_ctx_fail(&ctx->ctx,0);
+
+ if (slbt_driver_parse_tool_argv(ctx->cctx.host.ranlib,&ctx->host.ranlib_argv) < 0)
+ return slbt_get_driver_ctx_fail(&ctx->ctx,0);
+
/* flavor settings */
slbt_init_flavor_settings(
&ctx->cctx,0,