aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2021-08-16 09:38:16 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2021-08-16 09:38:16 +0200
commit6dcf87224a7e13550d664430bd149f42c8b12531 (patch)
tree91ee5bbfae46a8abb3133648f34b6223a10ed0ca
parent97f312a1b536c92440b04ec3dd743fc2802ab150 (diff)
Add pkg-build --noop-exit option
-rw-r--r--bpkg/pkg-build.cli10
-rw-r--r--bpkg/pkg-build.cxx21
2 files changed, 28 insertions, 3 deletions
diff --git a/bpkg/pkg-build.cli b/bpkg/pkg-build.cli
index 02df2d1..2ae2948 100644
--- a/bpkg/pkg-build.cli
+++ b/bpkg/pkg-build.cli
@@ -345,12 +345,20 @@ namespace bpkg
bool --no-refinement
{
- "Don't try to refine the configuration by offering drop any unused
+ "Don't try to refine the configuration by offering to drop any unused
dependencies that were potentially left behind on the previous
\cb{pkg-build} or \cb{pkg-drop} command execution if the command
is otherwise a noop (performs no new package builds, upgrades, etc)."
}
+ uint16_t --noop-exit
+ {
+ "<code>",
+
+ "Exit with the specified error code if the command execution is a noop
+ (performs no new package builds, upgrades, etc)."
+ }
+
uint16_t --no-private-config
{
"<code>",
diff --git a/bpkg/pkg-build.cxx b/bpkg/pkg-build.cxx
index 1e8e9dd..f59c2c0 100644
--- a/bpkg/pkg-build.cxx
+++ b/bpkg/pkg-build.cxx
@@ -3203,6 +3203,17 @@ namespace bpkg
//
validate_options (o, ""); // Global package options.
+ if (o.noop_exit_specified ())
+ {
+ if (o.print_only ())
+ fail << "--noop-exit specified with --print-only";
+
+ // We can probably use build2's --structured-result to support this.
+ //
+ if (!o.configure_only ())
+ fail << "--noop-exit is only supported in --configure-only mode";
+ }
+
if (o.update_dependent () && o.leave_dependent ())
fail << "both --update-dependent|-U and --leave-dependent|-L "
<< "specified" <<
@@ -4693,6 +4704,9 @@ namespace bpkg
{
assert (rec_pkgs.empty ());
+ if (o.noop_exit_specified ())
+ return o.noop_exit ();
+
info << "nothing to build";
return 0;
}
@@ -5935,10 +5949,13 @@ namespace bpkg
// prerequsites got upgraded/downgraded and that the user may want to in
// addition update (that update_dependents flag above).
//
- execute_plan (o, pkgs, false /* simulate */, find_prereq_database);
+ bool noop (!execute_plan (o,
+ pkgs,
+ false /* simulate */,
+ find_prereq_database));
if (o.configure_only ())
- return 0;
+ return noop && o.noop_exit_specified () ? o.noop_exit () : 0;
// update
//