summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/driver/slbt_amain.c12
-rw-r--r--src/internal/slibtool_ar_impl.h1
-rw-r--r--src/logic/slbt_exec_ar.c11
-rw-r--r--src/skin/slbt_skin_ar.c3
4 files changed, 25 insertions, 2 deletions
diff --git a/src/driver/slbt_amain.c b/src/driver/slbt_amain.c
index 2359293..b6bbe40 100644
--- a/src/driver/slbt_amain.c
+++ b/src/driver/slbt_amain.c
@@ -178,11 +178,19 @@ 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);
+
+ /* perform all other actions */
+ slbt_perform_driver_actions(dctx);
+
+ /* print --version on behalf of a secondary tool as needed */
+ if (dctx->cctx->drvflags & SLBT_DRIVER_VERSION)
return (slbt_version(dctx,fdout) < 0)
? slbt_exit(dctx,SLBT_ERROR)
: slbt_exit(dctx,SLBT_OK);
- slbt_perform_driver_actions(dctx);
-
return slbt_exit(dctx,dctx->errv[0] ? SLBT_ERROR : SLBT_OK);
}
diff --git a/src/internal/slibtool_ar_impl.h b/src/internal/slibtool_ar_impl.h
index 9287832..18d1ba2 100644
--- a/src/internal/slibtool_ar_impl.h
+++ b/src/internal/slibtool_ar_impl.h
@@ -9,6 +9,7 @@ extern const struct argv_option slbt_ar_options[];
enum ar_tags {
TAG_AR_HELP,
+ TAG_AR_VERSION,
TAG_AR_CHECK,
};
diff --git a/src/logic/slbt_exec_ar.c b/src/logic/slbt_exec_ar.c
index 3e1c0f2..18ee97e 100644
--- a/src/logic/slbt_exec_ar.c
+++ b/src/logic/slbt_exec_ar.c
@@ -142,6 +142,10 @@ int slbt_exec_ar(
& SLBT_DRIVER_ANNOTATE_NEVER);
return 0;
+ case TAG_AR_VERSION:
+ ictx->cctx.drvflags |= SLBT_DRIVER_VERSION;
+ break;
+
case TAG_AR_CHECK:
ictx->cctx.drvflags |= SLBT_DRIVER_MODE_AR_CHECK;
break;
@@ -155,6 +159,13 @@ int slbt_exec_ar(
};
}
+ /* defer --version printing to slbt_main() as needed */
+ if (cctx->drvflags & SLBT_DRIVER_VERSION) {
+ argv_free(meta);
+ slbt_free_exec_ctx(actx);
+ return SLBT_OK;
+ }
+
/* at least one action must be specified */
if (!(cctx->drvflags & SLBT_DRIVER_MODE_AR_ACTIONS)) {
if (cctx->drvflags & SLBT_DRIVER_VERBOSITY_ERRORS)
diff --git a/src/skin/slbt_skin_ar.c b/src/skin/slbt_skin_ar.c
index 4ef38d7..6adfe6b 100644
--- a/src/skin/slbt_skin_ar.c
+++ b/src/skin/slbt_skin_ar.c
@@ -2,6 +2,9 @@
#include "argv/argv.h"
const struct argv_option slbt_ar_options[] = {
+ {"version", 0,TAG_AR_VERSION,ARGV_OPTARG_NONE,0,0,0,
+ "show version information"},
+
{"help", 'h',TAG_AR_HELP,ARGV_OPTARG_NONE,0,0,0,
"display ar mode help"},