aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2024-10-16 14:05:03 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2024-10-16 14:05:03 +0200
commit9cf2dbda0d6a7006a5425c19973bb0a7286392f6 (patch)
treea32409aa36827c574898f89f196447d801dae6a1
parent881b5b560d055bfb762f17cffb82b22961f36ad2 (diff)
Stop on first error for install and uninstall operations
-rw-r--r--libbuild2/install/operation.cxx12
-rw-r--r--libbuild2/operation.cxx20
-rw-r--r--libbuild2/operation.hxx6
-rw-r--r--libbuild2/test/operation.cxx4
4 files changed, 34 insertions, 8 deletions
diff --git a/libbuild2/install/operation.cxx b/libbuild2/install/operation.cxx
index ce5d24a..029a5f6 100644
--- a/libbuild2/install/operation.cxx
+++ b/libbuild2/install/operation.cxx
@@ -369,7 +369,10 @@ namespace build2
// files, there is not going to be much speedup from doing it in parallel.
// There is also now the installation manifest, which relies on us
// installing all the filesystem entries of a target serially.
-
+ //
+ // Additionally, we stop on first error since there is no sense in
+ // continuing.
+ //
const operation_info op_install {
install_id,
0,
@@ -379,7 +382,8 @@ namespace build2
"installed",
"has nothing to install", // We cannot "be installed".
execution_mode::first,
- 0 /* concurrency */, // Run serially.
+ 0 /* concurrency */, // Run serially.
+ false /* keep_going */, // Stop on first error.
&pre_install,
nullptr,
&install_pre,
@@ -406,7 +410,8 @@ namespace build2
"uninstalled",
"is not installed",
execution_mode::last,
- 0 /* concurrency */, // Run serially
+ 0 /* concurrency */, // Run serially.
+ false /* keep_going */, // Stop on first error.
&pre_uninstall,
nullptr,
nullptr,
@@ -427,6 +432,7 @@ namespace build2
op_update.name_done,
op_update.mode,
op_update.concurrency,
+ op_update.keep_going,
op_update.pre_operation,
op_update.post_operation,
op_update.operation_pre,
diff --git a/libbuild2/operation.cxx b/libbuild2/operation.cxx
index 93db206..76118ea 100644
--- a/libbuild2/operation.cxx
+++ b/libbuild2/operation.cxx
@@ -664,6 +664,15 @@ namespace build2
default: assert (false); // Not supported.
}
+ // Override the keep_going flag if requested by the operation.
+ //
+ auto kgg = make_guard ([&ctx, o = ctx.keep_going] ()
+ {
+ ctx.keep_going = o;
+ });
+ if (!ctx.current_inner_oif->keep_going)
+ ctx.keep_going = false;
+
// Set the dry-run flag.
//
ctx.dry_run = ctx.dry_run_option;
@@ -819,7 +828,7 @@ namespace build2
//
ctx.dry_run = false;
- // Restore original scheduler settings.
+ // Restore original scheduler and keep_going settings.
}
// Print skip count if not zero. Note that we print it regardless of the
@@ -1500,7 +1509,8 @@ namespace build2
"",
"",
execution_mode::first,
- 1 /* concurrency */,
+ 1 /* concurrency */,
+ true /* keep_going */,
nullptr,
nullptr,
nullptr,
@@ -1528,7 +1538,8 @@ namespace build2
"updated",
"is up to date",
execution_mode::first,
- 1 /* concurrency */,
+ 1 /* concurrency */,
+ true /* keep_going */,
nullptr,
nullptr,
nullptr,
@@ -1546,7 +1557,8 @@ namespace build2
"cleaned",
"is clean",
execution_mode::last,
- 1 /* concurrency */,
+ 1 /* concurrency */,
+ true /* keep_going */,
nullptr,
nullptr,
nullptr,
diff --git a/libbuild2/operation.hxx b/libbuild2/operation.hxx
index 7d11161..4ca1305 100644
--- a/libbuild2/operation.hxx
+++ b/libbuild2/operation.hxx
@@ -235,6 +235,12 @@ namespace build2
//
const size_t concurrency;
+ // Whether to keep going in case of errors for this operation. If the
+ // value is false, then the context's keep_going flag is overridden for
+ // the duration of the operation.
+ //
+ const bool keep_going;
+
// The values argument in the callbacks is the operation parameters. If
// the operation expects parameters, then it should have a non-NULL
// operation_pre() callback. Failed that, any parameters will be diagnosed
diff --git a/libbuild2/test/operation.cxx b/libbuild2/test/operation.cxx
index 2535adb..640d2fe 100644
--- a/libbuild2/test/operation.cxx
+++ b/libbuild2/test/operation.cxx
@@ -63,7 +63,8 @@ namespace build2
"tested",
"has nothing to test", // We cannot "be tested".
execution_mode::first,
- 1 /* concurrency */,
+ 1 /* concurrency */,
+ true /* keep_going */,
&pre_test,
nullptr,
nullptr,
@@ -84,6 +85,7 @@ namespace build2
op_update.name_done,
op_update.mode,
op_update.concurrency,
+ op_update.keep_going,
op_update.pre_operation,
op_update.post_operation,
op_update.operation_pre,