aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2020-02-11 12:05:19 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2020-02-11 12:05:19 +0200
commit5278e39d58007b730e452a14d8e13aa93118e9f4 (patch)
tree18e1e2fe0a3cac3adf6c74c4e8118e89c59a8ed2
parent364159d8d024a783db44cb0a5b81e94f87f10ef4 (diff)
Add match_only flag to context
-rw-r--r--build2/b.cxx7
-rw-r--r--libbuild2/cc/compile-rule.cxx4
-rw-r--r--libbuild2/context.cxx2
-rw-r--r--libbuild2/context.hxx5
-rw-r--r--libbuild2/dist/operation.cxx85
-rw-r--r--libbuild2/module.cxx1
6 files changed, 58 insertions, 46 deletions
diff --git a/build2/b.cxx b/build2/b.cxx
index aab73c1..2917ad1 100644
--- a/build2/b.cxx
+++ b/build2/b.cxx
@@ -588,6 +588,7 @@ main (int argc, char* argv[])
ctx = nullptr; // Free first.
ctx.reset (new context (sched,
mutexes,
+ ops.match_only (),
ops.dry_run (),
!ops.serial_stop () /* keep_going */,
cmd_vars));
@@ -1558,7 +1559,7 @@ main (int argc, char* argv[])
if (dump_match)
dump (*ctx, a);
- if (mif->execute != nullptr && !ops.match_only ())
+ if (mif->execute != nullptr && !ctx->match_only)
mif->execute (mparams, a, tgs, diag, true /* progress */);
}
@@ -1585,7 +1586,7 @@ main (int argc, char* argv[])
if (dump_match)
dump (*ctx, a);
- if (mif->execute != nullptr && !ops.match_only ())
+ if (mif->execute != nullptr && !ctx->match_only)
mif->execute (mparams, a, tgs, diag, true /* progress */);
}
@@ -1613,7 +1614,7 @@ main (int argc, char* argv[])
if (dump_match)
dump (*ctx, a);
- if (mif->execute != nullptr && !ops.match_only ())
+ if (mif->execute != nullptr && !ctx->match_only)
mif->execute (mparams, a, tgs, diag, true /* progress */);
}
diff --git a/libbuild2/cc/compile-rule.cxx b/libbuild2/cc/compile-rule.cxx
index 26df353..b0fc40c 100644
--- a/libbuild2/cc/compile-rule.cxx
+++ b/libbuild2/cc/compile-rule.cxx
@@ -3278,7 +3278,7 @@ namespace build2
// We can only defer the failure if we will be running the compiler.
// Let's also only do it in the "keep going" mode.
//
- bool df (!ctx.dry_run_option && ctx.keep_going);
+ bool df (!ctx.match_only && !ctx.dry_run_option && ctx.keep_going);
const file* ht (enter_header (a, bs, t, li,
move (hp), cache,
@@ -3340,7 +3340,7 @@ namespace build2
this] (path hp, path bp, timestamp mt) -> optional<bool>
{
context& ctx (t.ctx);
- bool df (!ctx.dry_run_option && ctx.keep_going);
+ bool df (!ctx.match_only && !ctx.dry_run_option && ctx.keep_going);
const file* ht (enter_header (a, bs, t, li,
move (hp), true /* cache */,
diff --git a/libbuild2/context.cxx b/libbuild2/context.cxx
index de8c097..4082e0c 100644
--- a/libbuild2/context.cxx
+++ b/libbuild2/context.cxx
@@ -56,6 +56,7 @@ namespace build2
context::
context (scheduler& s,
global_mutexes& ms,
+ bool mo,
bool dr,
bool kg,
const strings& cmd_vars,
@@ -64,6 +65,7 @@ namespace build2
: data_ (new data (*this)),
sched (s),
mutexes (ms),
+ match_only (mo),
dry_run_option (dr),
keep_going (kg),
phase_mutex (*this),
diff --git a/libbuild2/context.hxx b/libbuild2/context.hxx
index 62a02cc..a2bfe3d 100644
--- a/libbuild2/context.hxx
+++ b/libbuild2/context.hxx
@@ -142,6 +142,10 @@ namespace build2
scheduler& sched;
global_mutexes& mutexes;
+ // Match only flag (see --match-only but also dist).
+ //
+ bool match_only;
+
// Dry run flag (see --dry-run|-n).
//
// This flag is set (based on dry_run_option) only for the final execute
@@ -436,6 +440,7 @@ namespace build2
explicit
context (scheduler&,
global_mutexes&,
+ bool match_only = false,
bool dry_run = false,
bool keep_going = true,
const strings& cmd_vars = {},
diff --git a/libbuild2/dist/operation.cxx b/libbuild2/dist/operation.cxx
index cc16e9b..52031a3 100644
--- a/libbuild2/dist/operation.cxx
+++ b/libbuild2/dist/operation.cxx
@@ -145,55 +145,58 @@ namespace build2
values params;
path_name pn ("<dist>");
const location loc (pn); // Dummy location.
-
- const operations& ops (rs->root_extra->operations);
-
- for (operations::size_type id (default_id + 1); // Skip default_id.
- id < ops.size ();
- ++id)
{
- if (const operation_info* oif = ops[id])
- {
- // Skip aliases (e.g., update-for-install). In fact, one can argue
- // the default update should be sufficient since it is assumed to
- // update all prerequisites and we no longer support ad hoc stuff
- // like test.input. Though here we are using the dist meta-operation,
- // not perform.
- //
- if (oif->id != id)
- continue;
+ auto mog = make_guard ([&ctx] () {ctx.match_only = false;});
+ ctx.match_only = true;
- // Use standard (perform) match.
- //
- if (oif->pre != nullptr)
+ const operations& ops (rs->root_extra->operations);
+ for (operations::size_type id (default_id + 1); // Skip default_id.
+ id < ops.size ();
+ ++id)
+ {
+ if (const operation_info* oif = ops[id])
{
- if (operation_id pid = oif->pre (params, dist_id, loc))
+ // Skip aliases (e.g., update-for-install). In fact, one can argue
+ // the default update should be sufficient since it is assumed to
+ // update all prerequisites and we no longer support ad hoc stuff
+ // like test.input. Though here we are using the dist meta-
+ // operation, not perform.
+ //
+ if (oif->id != id)
+ continue;
+
+ // Use standard (perform) match.
+ //
+ if (oif->pre != nullptr)
{
- const operation_info* poif (ops[pid]);
- ctx.current_operation (*poif, oif, false /* diag_noise */);
- action a (dist_id, poif->id, oif->id);
- match (params, a, ts,
- 1 /* diag (failures only) */,
- false /* progress */);
+ if (operation_id pid = oif->pre (params, dist_id, loc))
+ {
+ const operation_info* poif (ops[pid]);
+ ctx.current_operation (*poif, oif, false /* diag_noise */);
+ action a (dist_id, poif->id, oif->id);
+ match (params, a, ts,
+ 1 /* diag (failures only) */,
+ false /* progress */);
+ }
}
- }
- ctx.current_operation (*oif, nullptr, false /* diag_noise */);
- action a (dist_id, oif->id);
- match (params, a, ts,
- 1 /* diag (failures only) */,
- false /* progress */);
+ ctx.current_operation (*oif, nullptr, false /* diag_noise */);
+ action a (dist_id, oif->id);
+ match (params, a, ts,
+ 1 /* diag (failures only) */,
+ false /* progress */);
- if (oif->post != nullptr)
- {
- if (operation_id pid = oif->post (params, dist_id))
+ if (oif->post != nullptr)
{
- const operation_info* poif (ops[pid]);
- ctx.current_operation (*poif, oif, false /* diag_noise */);
- action a (dist_id, poif->id, oif->id);
- match (params, a, ts,
- 1 /* diag (failures only) */,
- false /* progress */);
+ if (operation_id pid = oif->post (params, dist_id))
+ {
+ const operation_info* poif (ops[pid]);
+ ctx.current_operation (*poif, oif, false /* diag_noise */);
+ action a (dist_id, poif->id, oif->id);
+ match (params, a, ts,
+ 1 /* diag (failures only) */,
+ false /* progress */);
+ }
}
}
}
diff --git a/libbuild2/module.cxx b/libbuild2/module.cxx
index aa8dc97..777f177 100644
--- a/libbuild2/module.cxx
+++ b/libbuild2/module.cxx
@@ -177,6 +177,7 @@ namespace build2
ctx.module_context_storage->reset (
new context (ctx.sched,
ctx.mutexes,
+ false, /* match_only */
false, /* dry_run */
ctx.keep_going,
ctx.global_var_overrides, /* cmd_vars */