aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2019-08-23 12:45:22 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2019-08-23 12:45:22 +0200
commit0ca011d1220207b3c1cba92791413f113ec66329 (patch)
tree855224e36408fc80ec7d47741b59ce4524402240
parent20f97f06ce54c31e32cf58cfd1b7cae3617c1661 (diff)
keep_going
-rw-r--r--build2/b.cxx18
-rw-r--r--libbuild2/algorithm.ixx8
-rw-r--r--libbuild2/context.cxx4
-rw-r--r--libbuild2/context.hxx22
-rw-r--r--libbuild2/operation.cxx4
-rw-r--r--libbuild2/test/rule.cxx2
-rw-r--r--libbuild2/test/script/parser.cxx2
-rw-r--r--libbuild2/utility.cxx7
-rw-r--r--libbuild2/utility.hxx1
9 files changed, 39 insertions, 29 deletions
diff --git a/build2/b.cxx b/build2/b.cxx
index af51a31..0f1009a 100644
--- a/build2/b.cxx
+++ b/build2/b.cxx
@@ -478,7 +478,7 @@ main (int argc, char* argv[])
//
init (&::terminate,
argv[0],
- !ops.serial_stop (), ops.dry_run (),
+ ops.dry_run (),
(ops.mtime_check () ? optional<bool> (true) :
ops.no_mtime_check () ? optional<bool> (false) : nullopt),
(ops.config_sub_specified ()
@@ -493,7 +493,7 @@ main (int argc, char* argv[])
// current and child processes unless we are in the stop mode. Failed that
// we may have multiple dialog boxes popping up.
//
- if (keep_going)
+ if (!ops.serial_stop ())
SetErrorMode (SetErrorMode (0) | // Returns the current mode.
SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX);
#endif
@@ -615,7 +615,16 @@ main (int argc, char* argv[])
// the global scope being setup. We reset it for every meta-operation (see
// below).
//
- unique_ptr<context> ctx (new context (sched, cmd_vars));
+ unique_ptr<context> ctx;
+ auto new_context = [&ctx, &cmd_vars]
+ {
+ ctx = nullptr; // Free first.
+ ctx.reset (new context (sched,
+ cmd_vars,
+ !ops.serial_stop () /* keep_going */));
+ };
+
+ new_context ();
// Parse the buildspec.
//
@@ -757,8 +766,7 @@ main (int argc, char* argv[])
//
if (dirty)
{
- ctx = nullptr;
- ctx.reset (new context (sched, cmd_vars));
+ new_context ();
dirty = false;
}
diff --git a/libbuild2/algorithm.ixx b/libbuild2/algorithm.ixx
index f865992..13a3323 100644
--- a/libbuild2/algorithm.ixx
+++ b/libbuild2/algorithm.ixx
@@ -356,10 +356,12 @@ namespace build2
size_t sc, atomic_count& tc,
bool fail)
{
- assert (t.ctx.phase == run_phase::match);
+ context& ctx (t.ctx);
+
+ assert (ctx.phase == run_phase::match);
target_state r (match (a, t, sc, &tc).second);
- if (fail && !keep_going && r == target_state::failed)
+ if (fail && !ctx.keep_going && r == target_state::failed)
throw failed ();
return r;
@@ -559,7 +561,7 @@ namespace build2
{
target_state r (execute (a, t, sc, &tc));
- if (fail && !keep_going && r == target_state::failed)
+ if (fail && !t.ctx.keep_going && r == target_state::failed)
throw failed ();
return r;
diff --git a/libbuild2/context.cxx b/libbuild2/context.cxx
index b1b45eb..1b1b9f6 100644
--- a/libbuild2/context.cxx
+++ b/libbuild2/context.cxx
@@ -50,9 +50,10 @@ namespace build2
};
context::
- context (scheduler& s, const strings& cmd_vars)
+ context (scheduler& s, const strings& cmd_vars, bool kg)
: data_ (new data (*this)),
sched (s),
+ keep_going (kg),
phase_mutex (phase),
scopes (data_->scopes),
global_scope (create_global_scope (data_->scopes)),
@@ -851,7 +852,6 @@ namespace build2
//text << this_thread::get_id () << " phase restore " << n << " " << o;
}
- bool keep_going = false;
bool dry_run = false;
void (*config_save_variable) (scope&, const variable&, uint64_t);
diff --git a/libbuild2/context.hxx b/libbuild2/context.hxx
index 59c70e3..dbf2329 100644
--- a/libbuild2/context.hxx
+++ b/libbuild2/context.hxx
@@ -110,6 +110,14 @@ namespace build2
public:
scheduler& sched;
+ // Keep going flag.
+ //
+ // Note that setting it to false is not of much help unless we are running
+ // serially: in parallel we queue most of the things up before we see any
+ // failures.
+ //
+ bool keep_going;
+
// In order to perform each operation the build system goes through the
// following phases:
//
@@ -326,7 +334,9 @@ namespace build2
public:
explicit
- context (scheduler&, const strings& cmd_vars = {});
+ context (scheduler&,
+ const strings& cmd_vars = {},
+ bool keep_going = true);
// Set current meta-operation and operation.
//
@@ -471,16 +481,6 @@ namespace build2
bool phase;
};
-
-
- // Keep going flag.
- //
- // Note that setting it to false is not of much help unless we are running
- // serially. In parallel we queue most of the things up before we see any
- // failures.
- //
- LIBBUILD2_SYMEXPORT extern bool keep_going;
-
// Dry run flag (see --dry-run|-n).
//
// This flag is set only for the final execute phase (as opposed to those
diff --git a/libbuild2/operation.cxx b/libbuild2/operation.cxx
index 661c439..ac1c159 100644
--- a/libbuild2/operation.cxx
+++ b/libbuild2/operation.cxx
@@ -183,7 +183,7 @@ namespace build2
// Bail out if the target has failed and we weren't instructed to
// keep going.
//
- if (s == target_state::failed && !keep_going)
+ if (s == target_state::failed && !ctx.keep_going)
{
++i;
break;
@@ -342,7 +342,7 @@ namespace build2
// Bail out if the target has failed and we weren't instructed to keep
// going.
//
- if (s == target_state::failed && !keep_going)
+ if (s == target_state::failed && !ctx.keep_going)
break;
}
diff --git a/libbuild2/test/rule.cxx b/libbuild2/test/rule.cxx
index ef9adca..bd412f5 100644
--- a/libbuild2/test/rule.cxx
+++ b/libbuild2/test/rule.cxx
@@ -560,7 +560,7 @@ namespace build2
// Executed synchronously. If failed and we were not asked to
// keep going, bail out.
//
- if (r == scope_state::failed && !keep_going)
+ if (r == scope_state::failed && !ctx.keep_going)
break;
}
}
diff --git a/libbuild2/test/script/parser.cxx b/libbuild2/test/script/parser.cxx
index 43c3849..582237a 100644
--- a/libbuild2/test/script/parser.cxx
+++ b/libbuild2/test/script/parser.cxx
@@ -3033,7 +3033,7 @@ namespace build2
// Bail out if the scope has failed and we weren't instructed
// to keep going.
//
- if (chain->state == scope_state::failed && !keep_going)
+ if (chain->state == scope_state::failed && !ctx.keep_going)
throw failed ();
}
}
diff --git a/libbuild2/utility.cxx b/libbuild2/utility.cxx
index 63fa609..d08cb31 100644
--- a/libbuild2/utility.cxx
+++ b/libbuild2/utility.cxx
@@ -495,14 +495,15 @@ namespace build2
void
init (void (*t) (bool),
const char* a0,
- bool kg, bool dr, optional<bool> mc,
- optional<path> cs, optional<path> cg)
+ bool dr,
+ optional<bool> mc,
+ optional<path> cs,
+ optional<path> cg)
{
terminate = t;
argv0 = process::path_search (a0, true);
- keep_going = kg;
dry_run_option = dr;
mtime_check_option = mc;
diff --git a/libbuild2/utility.hxx b/libbuild2/utility.hxx
index ed94a08..b5e842d 100644
--- a/libbuild2/utility.hxx
+++ b/libbuild2/utility.hxx
@@ -124,7 +124,6 @@ namespace build2
LIBBUILD2_SYMEXPORT void
init (void (*terminate) (bool),
const char* argv0,
- bool keep_going = false,
bool dry_run = false,
optional<bool> mtime_check = nullopt,
optional<path> config_sub = nullopt,