summaryrefslogtreecommitdiffhomepage
path: root/src/logic/slbt_exec_ar.c
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2024-02-16 22:48:01 +0000
committermidipix <writeonce@midipix.org>2024-02-16 22:53:36 +0000
commit0b177bee8b822e7291764b8c7c097125218da782 (patch)
tree3077287c7d17686220058cc6879380e405aded2e /src/logic/slbt_exec_ar.c
parent145d2bceaaf622475218abf3a549d2285298fc3c (diff)
downloadslibtool-0b177bee8b822e7291764b8c7c097125218da782.tar.bz2
slibtool-0b177bee8b822e7291764b8c7c097125218da782.tar.xz
ar mode: archive merging: added the -Wmerge command-line action.
Diffstat (limited to 'src/logic/slbt_exec_ar.c')
-rw-r--r--src/logic/slbt_exec_ar.c52
1 files changed, 51 insertions, 1 deletions
diff --git a/src/logic/slbt_exec_ar.c b/src/logic/slbt_exec_ar.c
index e3613fd..eab86ea 100644
--- a/src/logic/slbt_exec_ar.c
+++ b/src/logic/slbt_exec_ar.c
@@ -11,7 +11,8 @@
#include "slibtool_errinfo_impl.h"
#include "argv/argv.h"
-#define SLBT_DRIVER_MODE_AR_ACTIONS (SLBT_DRIVER_MODE_AR_CHECK)
+#define SLBT_DRIVER_MODE_AR_ACTIONS (SLBT_DRIVER_MODE_AR_CHECK \
+ | SLBT_DRIVER_MODE_AR_MERGE)
#define SLBT_DRIVER_MODE_AR_OUTPUTS (SLBT_OUTPUT_ARCHIVE_MEMBERS \
| SLBT_OUTPUT_ARCHIVE_HEADERS \
@@ -77,6 +78,7 @@ static int slbt_exec_ar_perform_archive_actions(
struct slbt_archive_ctx ** arctxv)
{
struct slbt_archive_ctx ** arctxp;
+ struct slbt_archive_ctx * arctx;
for (arctxp=arctxv; *arctxp; arctxp++) {
if (dctx->cctx->fmtflags & SLBT_DRIVER_MODE_AR_OUTPUTS)
@@ -88,6 +90,15 @@ static int slbt_exec_ar_perform_archive_actions(
return SLBT_NESTED_ERROR(dctx);
}
+ if (dctx->cctx->drvflags & SLBT_DRIVER_MODE_AR_MERGE) {
+ if (slbt_merge_archives(arctxv,&arctx) < 0)
+ return SLBT_NESTED_ERROR(dctx);
+
+ /* (defer mode to umask) */
+ if (slbt_store_archive(arctx,dctx->cctx->output,0666) < 0)
+ return SLBT_NESTED_ERROR(dctx);
+ }
+
return 0;
}
@@ -183,6 +194,14 @@ int slbt_exec_ar(
ictx->cctx.drvflags |= SLBT_DRIVER_MODE_AR_CHECK;
break;
+ case TAG_AR_MERGE:
+ ictx->cctx.drvflags |= SLBT_DRIVER_MODE_AR_MERGE;
+ break;
+
+ case TAG_AR_OUTPUT:
+ ictx->cctx.output = entry->arg;
+ break;
+
case TAG_AR_PRINT:
if (!entry->arg)
ictx->cctx.fmtflags |= SLBT_OUTPUT_ARCHIVE_MEMBERS;
@@ -260,6 +279,37 @@ int slbt_exec_ar(
SLBT_ERR_AR_NO_ACTION_SPECIFIED));
}
+ /* -Wmerge without -Woutput? */
+ if ((cctx->drvflags & SLBT_DRIVER_MODE_AR_MERGE) && !cctx->output) {
+ if (cctx->drvflags & SLBT_DRIVER_VERBOSITY_ERRORS)
+ slbt_dprintf(fderr,
+ "%s: archive merging: output must be specified.\n",
+ dctx->program);
+
+ return slbt_exec_ar_fail(
+ actx,meta,
+ SLBT_CUSTOM_ERROR(
+ dctx,
+ SLBT_ERR_AR_OUTPUT_NOT_SPECIFIED));
+ }
+
+
+ /* -Woutput without -Wmerge? */
+ if (cctx->output && !(cctx->drvflags & SLBT_DRIVER_MODE_AR_MERGE)) {
+ if (cctx->drvflags & SLBT_DRIVER_VERBOSITY_ERRORS)
+ slbt_dprintf(fderr,
+ "%s: output may only be specified "
+ "when merging one or more archives.\n",
+ dctx->program);
+
+ return slbt_exec_ar_fail(
+ actx,meta,
+ SLBT_CUSTOM_ERROR(
+ dctx,
+ SLBT_ERR_AR_OUTPUT_NOT_APPLICABLE));
+ }
+
+
/* at least one unit must be specified */
if (!nunits) {
if (cctx->drvflags & SLBT_DRIVER_VERBOSITY_ERRORS)