summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2016-05-20 22:06:32 -0400
committermidipix <writeonce@midipix.org>2016-05-20 22:20:07 -0400
commit70f645722337a041bf7f3c131646fafb9c7d21f1 (patch)
tree98d09605c7db807b2a079b362c38e38c326c3d02
parent431c9953417ba4143087e25e0bf7c5863df8682f (diff)
downloadslibtool-70f645722337a041bf7f3c131646fafb9c7d21f1.tar.bz2
slibtool-70f645722337a041bf7f3c131646fafb9c7d21f1.tar.xz
compile mode: slbt_create_object_wrapper(): initial implementation.
-rw-r--r--project/common.mk1
-rw-r--r--project/headers.mk1
-rw-r--r--src/internal/slibtool_metafile_impl.h11
-rw-r--r--src/internal/slibtool_objmeta_impl.c63
-rw-r--r--src/logic/slbt_exec_compile.c34
5 files changed, 79 insertions, 31 deletions
diff --git a/project/common.mk b/project/common.mk
index f55726a..b00f745 100644
--- a/project/common.mk
+++ b/project/common.mk
@@ -1,4 +1,5 @@
COMMON_SRCS = \
+ src/internal/slibtool_objmeta_impl.c \
src/internal/slibtool_symlink_impl.c \
src/driver/slbt_driver_ctx.c \
src/driver/slbt_unit_ctx.c \
diff --git a/project/headers.mk b/project/headers.mk
index bca122f..eb78201 100644
--- a/project/headers.mk
+++ b/project/headers.mk
@@ -6,6 +6,7 @@ INTERNAL_HEADERS = \
$(PROJECT_DIR)/src/internal/argv/argv.h \
$(PROJECT_DIR)/src/internal/$(PACKAGE)_driver_impl.h \
$(PROJECT_DIR)/src/internal/$(PACKAGE)_install_impl.h \
+ $(PROJECT_DIR)/src/internal/$(PACKAGE)_metafile_impl.h \
$(PROJECT_DIR)/src/internal/$(PACKAGE)_mkdir_impl.h \
$(PROJECT_DIR)/src/internal/$(PACKAGE)_readlink_impl.h \
$(PROJECT_DIR)/src/internal/$(PACKAGE)_spawn_impl.h \
diff --git a/src/internal/slibtool_metafile_impl.h b/src/internal/slibtool_metafile_impl.h
new file mode 100644
index 0000000..9a56db2
--- /dev/null
+++ b/src/internal/slibtool_metafile_impl.h
@@ -0,0 +1,11 @@
+/*******************************************************************/
+/* slibtool: a skinny libtool implementation, written in C */
+/* Copyright (C) 2016 Z. Gilboa */
+/* Released under the Standard MIT License; see COPYING.SLIBTOOL. */
+/*******************************************************************/
+
+#include <slibtool/slibtool.h>
+
+int slbt_create_object_wrapper(
+ const struct slbt_driver_ctx * dctx,
+ struct slbt_exec_ctx * ectx);
diff --git a/src/internal/slibtool_objmeta_impl.c b/src/internal/slibtool_objmeta_impl.c
new file mode 100644
index 0000000..e37d1eb
--- /dev/null
+++ b/src/internal/slibtool_objmeta_impl.c
@@ -0,0 +1,63 @@
+/*******************************************************************/
+/* slibtool: a skinny libtool implementation, written in C */
+/* Copyright (C) 2016 Z. Gilboa */
+/* Released under the Standard MIT License; see COPYING.SLIBTOOL. */
+/*******************************************************************/
+
+#include <stdio.h>
+#include <slibtool/slibtool.h>
+#include "slibtool_metafile_impl.h"
+
+static int slbt_create_default_object_wrapper(
+ const struct slbt_driver_ctx * dctx,
+ struct slbt_exec_ctx * ectx)
+{
+ int ret;
+ FILE * fout;
+ const struct slbt_source_version * verinfo;
+
+ if (!(fout = fopen(ectx->ltobjname,"w")))
+ return -1;
+
+ verinfo = slbt_source_version();
+
+ ret = fprintf(fout,
+ "# libtool compatible object wrapper\n"
+ "# Generated by %s (slibtool %d.%d.%d)\n"
+ "# [commit reference: %s]\n\n"
+
+ "pic_object='%s'\n"
+ "non_pic_object='%s'\n",
+
+ dctx->program,
+ verinfo->major,verinfo->minor,verinfo->revision,
+ verinfo->commit,
+
+ (dctx->cctx->drvflags & SLBT_DRIVER_SHARED)
+ ? ectx->lobjname
+ : "none",
+ (dctx->cctx->drvflags & SLBT_DRIVER_STATIC)
+ ? ectx->aobjname
+ : "none");
+
+ return (ret <= 0) || fclose(fout)
+ ? -1 : 0;
+}
+
+static int slbt_create_compatible_object_wrapper(
+ const struct slbt_driver_ctx * dctx,
+ struct slbt_exec_ctx * ectx)
+{
+ /* awaiting submission */
+ return slbt_create_default_object_wrapper(dctx,ectx);
+}
+
+int slbt_create_object_wrapper(
+ const struct slbt_driver_ctx * dctx,
+ struct slbt_exec_ctx * ectx)
+{
+ if (dctx->cctx->drvflags & SLBT_DRIVER_LEGABITS)
+ return slbt_create_compatible_object_wrapper(dctx,ectx);
+ else
+ return slbt_create_default_object_wrapper(dctx,ectx);
+}
diff --git a/src/logic/slbt_exec_compile.c b/src/logic/slbt_exec_compile.c
index 4a75270..90df731 100644
--- a/src/logic/slbt_exec_compile.c
+++ b/src/logic/slbt_exec_compile.c
@@ -13,6 +13,7 @@
#include <slibtool/slibtool.h>
#include "slibtool_spawn_impl.h"
#include "slibtool_mkdir_impl.h"
+#include "slibtool_metafile_impl.h"
static int slbt_exec_compile_remove_file(
const struct slbt_driver_ctx * dctx,
@@ -36,9 +37,7 @@ int slbt_exec_compile(
struct slbt_exec_ctx * ectx)
{
int ret;
- FILE * fout;
struct slbt_exec_ctx * actx = 0;
- const struct slbt_source_version * verinfo;
/* dry run */
if (dctx->cctx->drvflags & SLBT_DRIVER_DRY_RUN)
@@ -133,35 +132,8 @@ int slbt_exec_compile(
}
}
- /* libtool object */
- if (!(fout = fopen(ectx->ltobjname,"w"))) {
- slbt_free_exec_ctx(actx);
- return -1;
- }
-
- verinfo = slbt_source_version();
-
- ret = fprintf(fout,
- "# libtool compatible object wrapper\n"
- "# Generated by %s (slibtool %d.%d.%d)\n"
- "# [commit reference: %s]\n\n"
-
- "pic_object='%s'\n"
- "non_pic_object='%s'\n",
-
- dctx->program,
- verinfo->major,verinfo->minor,verinfo->revision,
- verinfo->commit,
-
- (dctx->cctx->drvflags & SLBT_DRIVER_SHARED)
- ? ectx->lobjname
- : "none",
- (dctx->cctx->drvflags & SLBT_DRIVER_STATIC)
- ? ectx->aobjname
- : "none");
-
- fclose(fout);
+ ret = slbt_create_object_wrapper(dctx,ectx);
slbt_free_exec_ctx(actx);
- return (ret > 0) ? 0 : -1;
+ return ret;
}