summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2016-03-09 23:26:17 -0500
committermidipix <writeonce@midipix.org>2016-03-10 08:32:40 -0500
commit5aae4bb6c4d410c35c7ced08cae21ff3273d5155 (patch)
tree60e9b3206587873c6375bfe1001d748679befa97
parentdf088e66dafc9df4a28070b24c3815bc8f4b1aec (diff)
downloadslibtool-5aae4bb6c4d410c35c7ced08cae21ff3273d5155.tar.bz2
slibtool-5aae4bb6c4d410c35c7ced08cae21ff3273d5155.tar.xz
struct slbt_exec_ctx: added placeholders for quick handling of different modes.
-rw-r--r--include/slibtool/slibtool.h5
-rw-r--r--src/logic/slbt_exec_ctx.c30
2 files changed, 25 insertions, 10 deletions
diff --git a/include/slibtool/slibtool.h b/include/slibtool/slibtool.h
index ebd0794..b9327f4 100644
--- a/include/slibtool/slibtool.h
+++ b/include/slibtool/slibtool.h
@@ -82,6 +82,10 @@ struct slbt_exec_ctx {
char * program;
char ** argv;
char ** envp;
+ char ** dpic;
+ char ** fpic;
+ char ** cass;
+ char ** lout[2];
char * csrc;
char * ldirname;
char * lbasename;
@@ -131,6 +135,7 @@ slbt_api void slbt_free_unit_ctx (struct slbt_unit_ctx *);
slbt_api int slbt_get_exec_ctx (const struct slbt_driver_ctx *, struct slbt_exec_ctx **);
slbt_api void slbt_free_exec_ctx (struct slbt_exec_ctx *);
+slbt_api void slbt_reset_placeholders (struct slbt_exec_ctx *);
slbt_api int slbt_map_input (int fd, const char * path, int prot, struct slbt_input *);
slbt_api int slbt_unmap_input (struct slbt_input *);
diff --git a/src/logic/slbt_exec_ctx.c b/src/logic/slbt_exec_ctx.c
index e191585..cfa7434 100644
--- a/src/logic/slbt_exec_ctx.c
+++ b/src/logic/slbt_exec_ctx.c
@@ -183,20 +183,19 @@ int slbt_get_exec_ctx(
}
}
- if (dctx->cctx->mode == SLBT_MODE_COMPILE) {
- if (dctx->cctx->drvflags & SLBT_DRIVER_SHARED) {
- ictx->ctx.argv[i++] = "-DPIC";
- ictx->ctx.argv[i++] = "-fPIC";
- }
+ /* placeholders for -DPIC, -fPIC, -c, -o, <output> */
+ ictx->ctx.dpic = &ictx->ctx.argv[i++];
+ ictx->ctx.fpic = &ictx->ctx.argv[i++];
+ ictx->ctx.cass = &ictx->ctx.argv[i++];
- ictx->ctx.argv[i++] = "-c";
- }
+ ictx->ctx.lout[0] = &ictx->ctx.argv[i++];
+ ictx->ctx.lout[1] = &ictx->ctx.argv[i++];
/* output file name */
if (ref) {
- ictx->ctx.argv[i++] = "-o";
- ictx->ctx.argv[i++] = ch;
- ictx->ctx.lobjname = ch;
+ *ictx->ctx.lout[0] = "-o";
+ *ictx->ctx.lout[1] = ch;
+ ictx->ctx.lobjname = ch;
sprintf(ch,"%s%s",
ictx->ctx.ldirname,
@@ -229,3 +228,14 @@ void slbt_free_exec_ctx(struct slbt_exec_ctx * ctx)
slbt_free_exec_ctx_impl(ictx,0);
}
}
+
+
+void slbt_reset_placeholders(struct slbt_exec_ctx * ectx)
+{
+ *ectx->dpic = "-DSLIBTOOL_PLACEHOLDER_DPIC";
+ *ectx->fpic = "-DSLIBTOOL_PLACEHOLDER_FPIC";
+ *ectx->cass = "-DSLIBTOOL_PLACEHOLDER_COMPILE_ASSEMBLE";
+
+ *ectx->lout[0] = "-DSLIBTOOL_PLACEHOLDER_OUTPUT_SWITCH";
+ *ectx->lout[1] = "-DSLIBTOOL_PLACEHOLDER_OUTPUT_FILE";
+}