summaryrefslogtreecommitdiff
path: root/src/driver/slbt_driver_ctx.c
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2018-08-13 15:18:09 +0000
committermidipix <writeonce@midipix.org>2018-08-13 19:26:24 -0400
commit499a718d986776354bbd4e7787ea1c30c851e384 (patch)
tree4d68ae7b43b9ae0ccfca293d6a0d7b98ce25cdab /src/driver/slbt_driver_ctx.c
parent0801fe615c2657fec3205626c7ae60a28db680fe (diff)
downloadslibtool-499a718d986776354bbd4e7787ea1c30c851e384.tar.bz2
slibtool-499a718d986776354bbd4e7787ea1c30c851e384.tar.xz
driver: added --heuristics support.
Diffstat (limited to 'src/driver/slbt_driver_ctx.c')
-rw-r--r--src/driver/slbt_driver_ctx.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/driver/slbt_driver_ctx.c b/src/driver/slbt_driver_ctx.c
index eac59c5..658b62b 100644
--- a/src/driver/slbt_driver_ctx.c
+++ b/src/driver/slbt_driver_ctx.c
@@ -14,6 +14,7 @@
#include "slibtool_version.h"
#include "slibtool_driver_impl.h"
#include "slibtool_errinfo_impl.h"
+#include "slibtool_lconf_impl.h"
#include "argv/argv.h"
/* package info */
@@ -966,6 +967,8 @@ int slbt_get_driver_ctx(
struct argv_meta * meta;
struct argv_entry * entry;
const char * program;
+ const char * lconf;
+ uint64_t lflags;
argv_optv_init(slbt_default_options,optv);
@@ -989,7 +992,9 @@ int slbt_get_driver_ctx(
fdctx->fderr)))
return -1;
+ lconf = 0;
program = argv_program_name(argv[0]);
+
memset(&cctx,0,sizeof(cctx));
/* shared and static objects: enable by default, disable by ~switch */
@@ -1013,6 +1018,11 @@ int slbt_get_driver_ctx(
cctx.drvflags |= SLBT_DRIVER_VERSION;
break;
+ case TAG_HEURISTICS:
+ cctx.drvflags |= SLBT_DRIVER_HEURISTICS;
+ lconf = entry->arg;
+ break;
+
case TAG_MODE:
if (!strcmp("clean",entry->arg))
cctx.mode = SLBT_MODE_CLEAN;
@@ -1286,6 +1296,32 @@ int slbt_get_driver_ctx(
if (!(ctx = slbt_driver_ctx_alloc(meta,fdctx,&cctx)))
return slbt_get_driver_ctx_fail(meta);
+ /* heuristics */
+ if (cctx.drvflags & SLBT_DRIVER_HEURISTICS) {
+ if (slbt_get_lconf_flags(&ctx->ctx,lconf,&lflags) < 0) {
+ slbt_free_driver_ctx(&ctx->ctx);
+ return -1;
+ }
+
+ cctx.drvflags &= ~(uint64_t)SLBT_DRIVER_DISABLE_STATIC;
+ cctx.drvflags &= ~(uint64_t)SLBT_DRIVER_DISABLE_SHARED;
+
+ cctx.drvflags |= lflags;
+ cctx.drvflags |= SLBT_DRIVER_SHARED;
+ cctx.drvflags |= SLBT_DRIVER_STATIC;
+
+ /* -disable-static? */
+ if (cctx.drvflags & SLBT_DRIVER_DISABLE_STATIC)
+ cctx.drvflags &= ~(uint64_t)SLBT_DRIVER_STATIC;
+
+ /* -disable-shared? */
+ if (cctx.drvflags & SLBT_DRIVER_DISABLE_SHARED)
+ cctx.drvflags &= ~(uint64_t)SLBT_DRIVER_SHARED;
+
+ ctx->cctx.drvflags = cctx.drvflags;
+ }
+
+ /* ctx */
ctx->ctx.program = program;
ctx->ctx.cctx = &ctx->cctx;
ctx->targv = sargv.targv;