summaryrefslogtreecommitdiff
path: root/src/driver/slbt_driver_ctx.c
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2016-03-19 16:23:27 -0400
committermidipix <writeonce@midipix.org>2016-03-19 16:23:27 -0400
commit5a916148f05272931f5b717074e9bb5ac60f20fc (patch)
treed2c90702e79fd5e7d3dc379844ea29706b92142e /src/driver/slbt_driver_ctx.c
parentf0921baf8e80bcb60d03a7448f947f6d25dc2f46 (diff)
downloadslibtool-5a916148f05272931f5b717074e9bb5ac60f20fc.tar.bz2
slibtool-5a916148f05272931f5b717074e9bb5ac60f20fc.tar.xz
driver: added -version-info support.
Diffstat (limited to 'src/driver/slbt_driver_ctx.c')
-rw-r--r--src/driver/slbt_driver_ctx.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/src/driver/slbt_driver_ctx.c b/src/driver/slbt_driver_ctx.c
index 10a531f..b9203c8 100644
--- a/src/driver/slbt_driver_ctx.c
+++ b/src/driver/slbt_driver_ctx.c
@@ -14,6 +14,7 @@
#include "slibtool_driver_impl.h"
#include "argv/argv.h"
+
static const char cfgexplicit[] = "command-line argument";
static const char cfghost[] = "derived from <host>";
static const char cfgtarget[] = "derived from <target>";
@@ -220,6 +221,11 @@ static int slbt_split_argv(
} else if (!(strcmp("rpath",&argv[i][1]))) {
*targv++ = argv[i++];
*targv++ = argv[i];
+
+ } else if (!(strcmp("version-info",&argv[i][1]))) {
+ *targv++ = argv[i++];
+ *targv++ = argv[i];
+
} else {
for (option=options; option->long_name; option++)
if (!(strcmp(option->long_name,&argv[i][1])))
@@ -383,6 +389,33 @@ static int slbt_init_host_params(
return 0;
}
+static int slbt_init_version_info(
+ struct slbt_driver_ctx_impl * ictx,
+ struct slbt_version_info * verinfo)
+{
+ int current;
+ int revision;
+ int age;
+
+ sscanf(verinfo->verinfo,"%d:%d:%d",
+ &current,&revision,&age);
+
+ if (current < age) {
+ if (ictx->cctx.drvflags & SLBT_DRIVER_VERBOSITY_ERRORS)
+ fprintf(stderr,
+ "%s: error: invalid version info: "
+ "<current> may not be smaller than <age>.\n",
+ argv_program_name(ictx->cctx.targv[0]));
+ return -1;
+ }
+
+ verinfo->major = current - age;
+ verinfo->minor = age;
+ verinfo->revision = revision;
+
+ return 0;
+}
+
int slbt_get_driver_ctx(
char ** argv,
char ** envp,
@@ -524,6 +557,10 @@ int slbt_get_driver_ctx(
cctx.rpath = entry->arg;
break;
+ case TAG_VERSION_INFO:
+ cctx.verinfo.verinfo = entry->arg;
+ break;
+
case TAG_TARGET:
cctx.target = entry->arg;
break;
@@ -573,6 +610,13 @@ int slbt_get_driver_ctx(
return -1;
}
+ /* version info */
+ if (ctx->cctx.verinfo.verinfo)
+ if (slbt_init_version_info(ctx,&ctx->cctx.verinfo)) {
+ slbt_free_driver_ctx(&ctx->ctx);
+ return -1;
+ }
+
*pctx = &ctx->ctx;
return SLBT_OK;
}