From 5278e39d58007b730e452a14d8e13aa93118e9f4 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 11 Feb 2020 12:05:19 +0200 Subject: Add match_only flag to context --- libbuild2/cc/compile-rule.cxx | 4 +- libbuild2/context.cxx | 2 + libbuild2/context.hxx | 5 +++ libbuild2/dist/operation.cxx | 85 ++++++++++++++++++++++--------------------- libbuild2/module.cxx | 1 + 5 files changed, 54 insertions(+), 43 deletions(-) (limited to 'libbuild2') 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 { 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 (""); 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 */ -- cgit v1.1