From 2611275c5f0a180c96963c9b1c4d2f1d76a04b5d Mon Sep 17 00:00:00 2001 From: midipix Date: Feb 16 2024 05:59:56 +0000 Subject: driver: host.ar, host.ranlib: added support for tool-specific argument vector. --- 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, diff --git a/src/internal/slibtool_lconf_impl.c b/src/internal/slibtool_lconf_impl.c index 88dc873..5daa2f4 100644 --- a/src/internal/slibtool_lconf_impl.c +++ b/src/internal/slibtool_lconf_impl.c @@ -799,7 +799,7 @@ int slbt_get_lconf_flags( /* ar tool */ if (!ctx->cctx.host.ar) { - if (slbt_get_lconf_var(addr,cap,"AR=",0,&val) < 0) + if (slbt_get_lconf_var(addr,cap,"AR=",0x20,&val) < 0) return SLBT_CUSTOM_ERROR( dctx,SLBT_ERR_LCONF_PARSE); @@ -812,7 +812,7 @@ int slbt_get_lconf_flags( /* ranlib tool */ if (!ctx->cctx.host.ranlib) { - if (slbt_get_lconf_var(addr,cap,"RANLIB=",0,&val) < 0) + if (slbt_get_lconf_var(addr,cap,"RANLIB=",0x20,&val) < 0) return SLBT_CUSTOM_ERROR( dctx,SLBT_ERR_LCONF_PARSE);