From b9575f640dcf44bbce4f97e5e92289b34d1d073a Mon Sep 17 00:00:00 2001
From: midipix <writeonce@midipix.org>
Date: Sat, 18 Jun 2016 23:26:01 -0400
Subject: driver: added --finish support.

---
 src/driver/slbt_driver_ctx.c        | 31 +++++++++++++++++++------------
 src/internal/slibtool_driver_impl.h |  1 +
 src/skin/slbt_skin_default.c        |  3 +++
 3 files changed, 23 insertions(+), 12 deletions(-)

(limited to 'src')

diff --git a/src/driver/slbt_driver_ctx.c b/src/driver/slbt_driver_ctx.c
index b230ce8..baf08fb 100644
--- a/src/driver/slbt_driver_ctx.c
+++ b/src/driver/slbt_driver_ctx.c
@@ -192,6 +192,7 @@ static int slbt_split_argv(
 	struct argv_entry *		entry;
 	struct argv_entry *		mode;
 	struct argv_entry *		config;
+	struct argv_entry *		finish;
 	const struct argv_option *	option;
 	const struct argv_option *	options = slbt_default_options;
 	struct argv_ctx			ctx = {ARGV_VERBOSITY_NONE,
@@ -216,15 +217,6 @@ static int slbt_split_argv(
 		return -1;
 	}
 
-	/* missing compiler? */
-	if (!ctx.unitidx) {
-		if (flags & SLBT_DRIVER_VERBOSITY_ERRORS)
-			fprintf(stderr,
-				"%s: error: <compiler> is missing.\n",
-				program);
-		return -1;
-	}
-
 	/* obtain slibtool's own arguments */
 	compiler = argv[ctx.unitidx];
 	argv[ctx.unitidx] = 0;
@@ -232,22 +224,33 @@ static int slbt_split_argv(
 	meta = argv_get(argv,options,ARGV_VERBOSITY_NONE);
 	argv[ctx.unitidx] = compiler;
 
-	/* missing both --mode and --config? */
-	for (mode=0, config=0, entry=meta->entries; entry->fopt; entry++)
+	/* missing all of --mode, --config, and --finish? */
+	for (mode=0, config=0, finish=0, entry=meta->entries; entry->fopt; entry++)
 		if (entry->tag == TAG_MODE)
 			mode = entry;
 		else if (entry->tag == TAG_CONFIG)
 			config = entry;
+		else if (entry->tag == TAG_FINISH)
+			finish = entry;
 
 	argv_free(meta);
 
-	if (!mode && !config) {
+	if (!mode && !config && !finish) {
 		fprintf(stderr,
 			"%s: error: --mode must be specified.\n",
 			program);
 		return -1;
 	}
 
+	/* missing compiler? */
+	if (!ctx.unitidx && !finish) {
+		if (flags & SLBT_DRIVER_VERBOSITY_ERRORS)
+			fprintf(stderr,
+				"%s: error: <compiler> is missing.\n",
+				program);
+		return -1;
+	}
+
 	/* allocate split vectors */
 	for (argc=0, targv=argv; *targv; targv++)
 		argc++;
@@ -841,6 +844,10 @@ int slbt_get_driver_ctx(
 						cctx.mode = SLBT_MODE_UNINSTALL;
 					break;
 
+				case TAG_FINISH:
+					cctx.mode = SLBT_MODE_FINISH;
+					break;
+
 				case TAG_DRY_RUN:
 					cctx.drvflags |= SLBT_DRIVER_DRY_RUN;
 					break;
diff --git a/src/internal/slibtool_driver_impl.h b/src/internal/slibtool_driver_impl.h
index ac823a8..4a40122 100644
--- a/src/internal/slibtool_driver_impl.h
+++ b/src/internal/slibtool_driver_impl.h
@@ -21,6 +21,7 @@ enum app_tags {
 	TAG_FEATURES,
 	TAG_LEGABITS,
 	TAG_MODE,
+	TAG_FINISH,
 	TAG_WARNINGS,
 	TAG_ANNOTATE,
 	TAG_DEPS,
diff --git a/src/skin/slbt_skin_default.c b/src/skin/slbt_skin_default.c
index 90d5aad..09408a3 100644
--- a/src/skin/slbt_skin_default.c
+++ b/src/skin/slbt_skin_default.c
@@ -22,6 +22,9 @@ const struct argv_option slbt_default_options[] = {
 				"their addition is expected before "
 				"the next release"},
 
+	{"finish",		0,TAG_FINISH,ARGV_OPTARG_NONE,0,0,0,
+				"same as --mode=finish"},
+
 	{"dry-run",		'n',TAG_DRY_RUN,ARGV_OPTARG_NONE,0,0,0,
 				"do not spawn any processes, "
 				"do not make any changes to the file system"},
-- 
cgit v1.2.3