diff options
author | midipix <writeonce@midipix.org> | 2024-03-17 16:02:00 +0000 |
---|---|---|
committer | midipix <writeonce@midipix.org> | 2024-03-17 16:02:00 +0000 |
commit | 4c3fb76f0341f4ac98f23a434fc741e1252d9627 (patch) | |
tree | 9c2bb699dc3866e3f2a397ab631431c272ab6673 /src/driver | |
parent | 752cd9fff4d112e534cd137b30ddefb87b651b30 (diff) | |
download | slibtool-4c3fb76f0341f4ac98f23a434fc741e1252d9627.tar.bz2 slibtool-4c3fb76f0341f4ac98f23a434fc741e1252d9627.tar.xz |
slibtoolize mode: program skeleton, driver integration, and symlink extra.
Diffstat (limited to 'src/driver')
-rw-r--r-- | src/driver/slbt_amain.c | 17 | ||||
-rw-r--r-- | src/driver/slbt_driver_ctx.c | 10 | ||||
-rw-r--r-- | src/driver/slbt_split_argv.c | 41 |
3 files changed, 55 insertions, 13 deletions
diff --git a/src/driver/slbt_amain.c b/src/driver/slbt_amain.c index 3b21500..73d1462 100644 --- a/src/driver/slbt_amain.c +++ b/src/driver/slbt_amain.c @@ -85,6 +85,9 @@ static void slbt_perform_driver_actions(struct slbt_driver_ctx * dctx) if (dctx->cctx->mode == SLBT_MODE_AR) slbt_exec_ar(dctx); + + if (dctx->cctx->mode == SLBT_MODE_STOOLIE) + slbt_exec_stoolie(dctx); } static int slbt_exit(struct slbt_driver_ctx * dctx, int ret) @@ -132,6 +135,13 @@ int slbt_main(char ** argv, char ** envp, const struct slbt_fd_ctx * fdctx) else if (!(strcmp(dash,"ar"))) flags |= SLBT_DRIVER_MODE_AR; + /* slibtoolize (stoolie) mode */ + if (!(strcmp(program,"stoolie"))) + flags |= SLBT_DRIVER_MODE_STOOLIE; + + else if (!(strcmp(program,"slibtoolize"))) + flags |= SLBT_DRIVER_MODE_STOOLIE; + /* debug */ if (!(strcmp(program,"dlibtool"))) flags |= SLBT_DRIVER_DEBUG; @@ -182,9 +192,10 @@ int slbt_main(char ** argv, char ** envp, const struct slbt_fd_ctx * fdctx) /* --version must be the first (and only) action */ if (dctx->cctx->drvflags & SLBT_DRIVER_VERSION) if (dctx->cctx->mode != SLBT_MODE_AR) - return (slbt_version(dctx,fdout) < 0) - ? slbt_exit(dctx,SLBT_ERROR) - : slbt_exit(dctx,SLBT_OK); + if (dctx->cctx->mode != SLBT_MODE_STOOLIE) + return (slbt_version(dctx,fdout) < 0) + ? slbt_exit(dctx,SLBT_ERROR) + : slbt_exit(dctx,SLBT_OK); /* perform all other actions */ slbt_perform_driver_actions(dctx); diff --git a/src/driver/slbt_driver_ctx.c b/src/driver/slbt_driver_ctx.c index a5b3861..3bb0e58 100644 --- a/src/driver/slbt_driver_ctx.c +++ b/src/driver/slbt_driver_ctx.c @@ -454,6 +454,9 @@ int slbt_lib_get_driver_ctx( if (flags & SLBT_DRIVER_MODE_AR) cctx.mode = SLBT_MODE_AR; + else if (flags & SLBT_DRIVER_MODE_STOOLIE) + cctx.mode = SLBT_MODE_STOOLIE; + /* default flags (set at compile time and derived from symlink) */ cctx.drvflags = flags; @@ -484,6 +487,7 @@ int slbt_lib_get_driver_ctx( case SLBT_MODE_INSTALL: case SLBT_MODE_UNINSTALL: case SLBT_MODE_AR: + case SLBT_MODE_STOOLIE: break; default: @@ -531,6 +535,12 @@ int slbt_lib_get_driver_ctx( else if (!strcmp("ar",entry->arg)) cctx.mode = SLBT_MODE_AR; + + else if (!strcmp("stoolie",entry->arg)) + cctx.mode = SLBT_MODE_STOOLIE; + + else if (!strcmp("slibtoolize",entry->arg)) + cctx.mode = SLBT_MODE_STOOLIE; break; case TAG_FINISH: diff --git a/src/driver/slbt_split_argv.c b/src/driver/slbt_split_argv.c index 43af9f8..7ad20a3 100644 --- a/src/driver/slbt_split_argv.c +++ b/src/driver/slbt_split_argv.c @@ -16,6 +16,7 @@ #include "slibtool_objlist_impl.h" #include "slibtool_errinfo_impl.h" #include "slibtool_visibility_impl.h" +#include "slibtool_stoolie_impl.h" #include "slibtool_ar_impl.h" #include "argv/argv.h" @@ -59,6 +60,7 @@ slbt_hidden int slbt_split_argv( struct argv_entry * ccwrap; struct argv_entry * dumpmachine; struct argv_entry * aropt; + struct argv_entry * stoolieopt; const struct argv_option ** popt; const struct argv_option ** optout; const struct argv_option * optv[SLBT_OPTV_ELEMENTS]; @@ -71,6 +73,8 @@ slbt_hidden int slbt_split_argv( /* missing arguments? */ if ((altmode = (flags & SLBT_DRIVER_MODE_AR))) { slbt_optv_init(slbt_ar_options,optv); + } else if ((altmode = (flags & SLBT_DRIVER_MODE_STOOLIE))) { + slbt_optv_init(slbt_stoolie_options,optv); } else { slbt_optv_init(slbt_default_options,optv); } @@ -120,7 +124,7 @@ slbt_hidden int slbt_split_argv( } /* missing all of --mode, --help, --version, --info, --config, --dumpmachine, --features, and --finish? */ - mode = help = version = info = config = finish = features = ccwrap = dumpmachine = aropt = 0; + mode = help = version = info = config = finish = features = ccwrap = dumpmachine = aropt = stoolieopt = 0; for (entry=meta->entries; entry->fopt; entry++) if (entry->tag == TAG_MODE) @@ -146,11 +150,17 @@ slbt_hidden int slbt_split_argv( if (!altmode && mode && !strcmp(mode->arg,"ar")) aropt = mode; + if (!altmode && mode && !strcmp(mode->arg,"stoolie")) + stoolieopt = mode; + + if (!altmode && mode && !strcmp(mode->arg,"slibtoolize")) + stoolieopt = mode; + /* release temporary argv meta context */ slbt_argv_free(meta); /* error not due to an altmode argument? */ - if (!aropt && ctx.erridx && (ctx.erridx == ctx.unitidx)) { + if (!aropt && !stoolieopt && ctx.erridx && (ctx.erridx == ctx.unitidx)) { if (flags & SLBT_DRIVER_VERBOSITY_ERRORS) slbt_argv_get( argv,optv, @@ -167,12 +177,14 @@ slbt_hidden int slbt_split_argv( } /* missing compiler? */ - if (!ctx.unitidx && !help && !info && !config && !version && !finish && !features && !dumpmachine && !altmode && !aropt) { - if (flags & SLBT_DRIVER_VERBOSITY_ERRORS) - slbt_dprintf(fderr, - "%s: error: <compiler> is missing.\n", - program); - return -1; + if (!ctx.unitidx && !help && !info && !config && !version && !finish && !features && !dumpmachine) { + if (!altmode && !aropt && !stoolieopt) { + if (flags & SLBT_DRIVER_VERBOSITY_ERRORS) + slbt_dprintf(fderr, + "%s: error: <compiler> is missing.\n", + program); + return -1; + } } /* clone and normalize the argv vector */ @@ -196,7 +208,7 @@ slbt_hidden int slbt_split_argv( csysroot = 0; for (i=0,flast=false,dargv=sargv->dargv,dst=sargv->dargs; i<argc; i++) { - if ((fcopy = (flast || altmode || aropt))) { + if ((fcopy = (flast || altmode || aropt || stoolieopt))) { (void)0; } else if (!strcmp(argv[i],"--")) { @@ -340,6 +352,10 @@ slbt_hidden int slbt_split_argv( if (aropt && !ctx.unitidx) ctx.unitidx = argc; + /* --mode=slibtoolize and no slibtoolize-specific arguments? */ + if (stoolieopt && !ctx.unitidx) + ctx.unitidx = argc; + /* split vectors: slibtool's own options */ for (i=0; i<ctx.unitidx; i++) sargv->targv[i] = argv[i]; @@ -349,7 +365,7 @@ slbt_hidden int slbt_split_argv( cargv = sargv->cargv; /* known wrappers */ - if (ctx.unitidx && !ccwrap && !aropt) { + if (ctx.unitidx && !ccwrap && !aropt && !stoolieopt) { if ((base = strrchr(argv[i],'/'))) base++; else if ((base = strrchr(argv[i],'\\'))) @@ -375,6 +391,8 @@ slbt_hidden int slbt_split_argv( i = 0; } else if (aropt) { *cargv++ = argv[0]; + } else if (stoolieopt) { + *cargv++ = argv[0]; } else { *cargv++ = argv[i++]; } @@ -388,6 +406,9 @@ slbt_hidden int slbt_split_argv( if (aropt && (i >= ctx.unitidx)) { *cargv++ = argv[i]; + } else if (stoolieopt && (i >= ctx.unitidx)) { + *cargv++ = argv[i]; + } else if (argv[i][0] != '-') { if (argv[i+1] && (argv[i+1][0] == '+') && (argv[i+1][1] == '=') |