From 5a916148f05272931f5b717074e9bb5ac60f20fc Mon Sep 17 00:00:00 2001 From: midipix Date: Sat, 19 Mar 2016 16:23:27 -0400 Subject: driver: added -version-info support. --- include/slibtool/slibtool.h | 8 +++++++ src/driver/slbt_driver_ctx.c | 44 +++++++++++++++++++++++++++++++++++++ src/internal/slibtool_driver_impl.h | 1 + src/skin/slbt_skin_default.c | 5 +++++ 4 files changed, 58 insertions(+) diff --git a/include/slibtool/slibtool.h b/include/slibtool/slibtool.h index 002a278..e64ec70 100644 --- a/include/slibtool/slibtool.h +++ b/include/slibtool/slibtool.h @@ -99,6 +99,13 @@ struct slbt_exec_ctx { int exitcode; }; +struct slbt_version_info { + int major; + int minor; + int revision; + const char * verinfo; +}; + struct slbt_host_params { const char * host; const char * flavor; @@ -113,6 +120,7 @@ struct slbt_common_ctx { uint64_t fmtflags; struct slbt_host_params host; struct slbt_host_params cfgmeta; + struct slbt_version_info verinfo; enum slbt_mode mode; enum slbt_tag tag; enum slbt_warning_level warnings; 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 "; static const char cfgtarget[] = "derived from "; @@ -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", + ¤t,&revision,&age); + + if (current < age) { + if (ictx->cctx.drvflags & SLBT_DRIVER_VERBOSITY_ERRORS) + fprintf(stderr, + "%s: error: invalid version info: " + " may not be smaller than .\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; } diff --git a/src/internal/slibtool_driver_impl.h b/src/internal/slibtool_driver_impl.h index 0ba0dfc..91bdc92 100644 --- a/src/internal/slibtool_driver_impl.h +++ b/src/internal/slibtool_driver_impl.h @@ -33,6 +33,7 @@ enum app_tags { TAG_DLLTOOL, TAG_OUTPUT, TAG_RPATH, + TAG_VERSION_INFO, TAG_NO_SUPPRESS, TAG_PREFER_PIC, TAG_PREFER_NON_PIC, diff --git a/src/skin/slbt_skin_default.c b/src/skin/slbt_skin_default.c index 926cc75..8339024 100644 --- a/src/skin/slbt_skin_default.c +++ b/src/skin/slbt_skin_default.c @@ -86,6 +86,11 @@ const struct argv_option slbt_default_options[] = { "where a library should eventually be " "installed, relative to $(DESTDIR)$(PREFIX)"}, + {"version-info", 0,TAG_VERSION_INFO,ARGV_OPTARG_REQUIRED, + ARGV_OPTION_HYBRID_ONLY|ARGV_OPTION_HYBRID_SPACE,0, + "[:[:]]", + "specify version information"}, + {"no-suppress", 0,TAG_NO_SUPPRESS,ARGV_OPTARG_NONE, ARGV_OPTION_HYBRID_ONLY,0,0, "transparently forward all " -- cgit v1.2.3