summaryrefslogtreecommitdiff
path: root/src/driver/slbt_driver_ctx.c
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2019-02-19 08:30:41 -0500
committermidipix <writeonce@midipix.org>2019-02-19 08:30:41 -0500
commit34988f835484e8a4fdc3e9a93930786755a63d05 (patch)
tree2a3e0b8a853927d15e13d0a297089c0c21d088a0 /src/driver/slbt_driver_ctx.c
parent513f55dd376fbfc0625b00e56340fa17052a75ea (diff)
downloadslibtool-34988f835484e8a4fdc3e9a93930786755a63d05.tar.bz2
slibtool-34988f835484e8a4fdc3e9a93930786755a63d05.tar.xz
driver, compile & link mode: support arbitrary & known compiler wrappers.
Diffstat (limited to 'src/driver/slbt_driver_ctx.c')
-rw-r--r--src/driver/slbt_driver_ctx.c39
1 files changed, 33 insertions, 6 deletions
diff --git a/src/driver/slbt_driver_ctx.c b/src/driver/slbt_driver_ctx.c
index a898205..da8bc76 100644
--- a/src/driver/slbt_driver_ctx.c
+++ b/src/driver/slbt_driver_ctx.c
@@ -263,12 +263,14 @@ static int slbt_split_argv(
bool flast;
bool fcopy;
size_t size;
+ const char * base;
struct argv_meta * meta;
struct argv_entry * entry;
struct argv_entry * mode;
struct argv_entry * config;
struct argv_entry * finish;
struct argv_entry * features;
+ struct argv_entry * ccwrap;
const struct argv_option ** popt;
const struct argv_option ** optout;
const struct argv_option * optv[SLBT_OPTV_ELEMENTS];
@@ -311,7 +313,7 @@ static int slbt_split_argv(
}
/* missing all of --mode, --config, --features, and --finish? */
- mode = config = finish = features = 0;
+ mode = config = finish = features = ccwrap = 0;
for (entry=meta->entries; entry->fopt; entry++)
if (entry->tag == TAG_MODE)
@@ -322,6 +324,8 @@ static int slbt_split_argv(
finish = entry;
else if (entry->tag == TAG_FEATURES)
features = entry;
+ else if (entry->tag == TAG_CCWRAP)
+ ccwrap = entry;
argv_free(meta);
@@ -422,8 +426,8 @@ static int slbt_split_argv(
argv = sargv->dargv;
/* allocate split vectors */
- if ((sargv->targv = calloc(2*(argc+1),sizeof(char *))))
- sargv->cargv = sargv->targv + argc + 1;
+ if ((sargv->targv = calloc(2*(argc+2),sizeof(char *))))
+ sargv->cargv = sargv->targv + argc + 2;
else
return -1;
@@ -441,13 +445,32 @@ static int slbt_split_argv(
for (i=0; i<ctx.unitidx; i++)
sargv->targv[i] = argv[i];
+ /* split vector marks */
+ targv = sargv->targv + i;
+ cargv = sargv->cargv;
+
+ /* known wrappers */
+ if (ctx.unitidx && !ccwrap) {
+ if ((base = strrchr(argv[i],'/')))
+ base++;
+ else if ((base = strrchr(argv[i],'\\')))
+ base++;
+ else
+ base = argv[i];
+
+ if (!strcmp(base,"ccache")
+ || !strcmp(base,"distcc")
+ || !strcmp(base,"compiler")
+ || !strcmp(base,"purify")) {
+ *targv++ = "--ccwrap";
+ *targv++ = argv[i++];
+ }
+ }
+
/* split vectors: legacy mixture */
for (optout=optv; optout[0]->tag != TAG_OUTPUT; optout++)
(void)0;
- targv = sargv->targv + i;
- cargv = sargv->cargv;
-
for (; i<argc; i++) {
if (argv[i][0] != '-') {
if (argv[i+1] && (argv[i+1][0] == '+')
@@ -1332,6 +1355,10 @@ int slbt_get_driver_ctx(
break;
+ case TAG_CCWRAP:
+ cctx.ccwrap = entry->arg;
+ break;
+
case TAG_IMPLIB:
if (!strcmp("idata",entry->arg)) {
cctx.drvflags |= SLBT_DRIVER_IMPLIB_IDATA;