From 499a718d986776354bbd4e7787ea1c30c851e384 Mon Sep 17 00:00:00 2001 From: midipix Date: Mon, 13 Aug 2018 15:18:09 +0000 Subject: driver: added --heuristics support. --- include/slibtool/slibtool.h | 1 + src/driver/slbt_driver_ctx.c | 36 ++++++++++++++++++++++++++++++++++++ src/internal/slibtool_driver_impl.h | 1 + src/skin/slbt_skin_default.c | 6 ++++++ 4 files changed, 44 insertions(+) diff --git a/include/slibtool/slibtool.h b/include/slibtool/slibtool.h index fac022f..18fdc30 100644 --- a/include/slibtool/slibtool.h +++ b/include/slibtool/slibtool.h @@ -47,6 +47,7 @@ extern "C" { #define SLBT_DRIVER_SHARED 0x4000 #define SLBT_DRIVER_STATIC 0x8000 +#define SLBT_DRIVER_HEURISTICS 0x010000 #define SLBT_DRIVER_STRICT 0x020000 #define SLBT_DRIVER_NO_UNDEFINED 0x040000 #define SLBT_DRIVER_MODULE 0x080000 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; diff --git a/src/internal/slibtool_driver_impl.h b/src/internal/slibtool_driver_impl.h index ab4ace1..451b1a6 100644 --- a/src/internal/slibtool_driver_impl.h +++ b/src/internal/slibtool_driver_impl.h @@ -62,6 +62,7 @@ enum app_tags { TAG_NO_INSTALL, TAG_PREFER_PIC, TAG_PREFER_NON_PIC, + TAG_HEURISTICS, TAG_SHARED, TAG_STATIC, TAG_ALL_STATIC, diff --git a/src/skin/slbt_skin_default.c b/src/skin/slbt_skin_default.c index ce8df6f..7678f2a 100644 --- a/src/skin/slbt_skin_default.c +++ b/src/skin/slbt_skin_default.c @@ -11,6 +11,12 @@ const struct argv_option slbt_default_options[] = { {"help-all", 'h',TAG_HELP_ALL,ARGV_OPTARG_NONE,0,0,0, "show comprehensive help information"}, + {"heuristics", 0,TAG_HEURISTICS,ARGV_OPTARG_OPTIONAL,0,0,"", + "enable/disable creation of shared/static libraries " + "by parsing a project-specific shell script, " + "the %s of which is either provided via this " + "command-line argument, or detected by the program."}, + {"mode", 0,TAG_MODE,ARGV_OPTARG_REQUIRED,0, "clean|compile|execute|finish" "|install|link|uninstall",0, -- cgit v1.2.3