From 6cc8301e4fb819393c1245cea0fbfb89e69b90b4 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 23 Aug 2019 08:02:15 +0200 Subject: Meta/operations and counts --- build2/b.cxx | 27 +++++++++++++++------------ build2/cc/compile-rule.cxx | 6 +++--- build2/cc/link-rule.cxx | 9 +++++---- 3 files changed, 23 insertions(+), 19 deletions(-) (limited to 'build2') diff --git a/build2/b.cxx b/build2/b.cxx index 6a49cb7..cb9c2c0 100644 --- a/build2/b.cxx +++ b/build2/b.cxx @@ -107,12 +107,15 @@ namespace build2 if (ops.structured_result ()) { + const target& t (at.as_target ()); + context& ctx (t.ctx); + cout << at.state - << ' ' << current_mif->name - << ' ' << current_inner_oif->name; + << ' ' << ctx.current_mif->name + << ' ' << ctx.current_inner_oif->name; - if (current_outer_oif != nullptr) - cout << '(' << current_outer_oif->name << ')'; + if (ctx.current_outer_oif != nullptr) + cout << '(' << ctx.current_outer_oif->name << ')'; // There are two ways one may wish to identify the target of the // operation: as something specific but inherently non-portable (say, @@ -131,7 +134,7 @@ namespace build2 stream_verbosity sv (stream_verb (cout)); stream_verb (cout, stream_verbosity (1, 0)); - cout << ' ' << at.as_target () << endl; + cout << ' ' << t << endl; stream_verb (cout, sv); } @@ -773,7 +776,7 @@ main (int argc, char* argv[]) values& mparams (lifted == nullptr ? mit->params : lifted->params); string mname (lifted == nullptr ? mit->name : lifted->name); - current_mname = mname; // Set early. + ctx->current_mname = mname; // Set early. if (!mname.empty ()) { @@ -782,7 +785,7 @@ main (int argc, char* argv[]) // Can modify params, opspec, change meta-operation name. // if (auto f = meta_operation_table[m].process) - mname = current_mname = f ( + mname = ctx->current_mname = f ( *ctx, mparams, opspecs, lifted != nullptr, l); } } @@ -802,7 +805,7 @@ main (int argc, char* argv[]) const values& oparams (lifted == nullptr ? os.params : values ()); const string& oname (lifted == nullptr ? os.name : empty_string); - current_oname = oname; // Set early. + ctx->current_oname = oname; // Set early. if (lifted != nullptr) lifted = nullptr; // Clear for the next iteration. @@ -1242,7 +1245,7 @@ main (int argc, char* argv[]) fail (l) << "unexpected parameters for meta-operation " << mif->name; - ctx->current_mif (*mif); + ctx->current_meta_operation (*mif); dirty = true; } @@ -1562,7 +1565,7 @@ main (int argc, char* argv[]) if (mif->operation_pre != nullptr) mif->operation_pre (mparams, pre_oid); // Cannot be translated. - ctx->current_oif (*pre_oif, oif); + ctx->current_operation (*pre_oif, oif); action a (mid, pre_oid, oid); @@ -1589,7 +1592,7 @@ main (int argc, char* argv[]) tgs.reset (); } - ctx->current_oif (*oif, outer_oif); + ctx->current_operation (*oif, outer_oif); action a (mid, oid, oif->outer_id); @@ -1617,7 +1620,7 @@ main (int argc, char* argv[]) if (mif->operation_pre != nullptr) mif->operation_pre (mparams, post_oid); // Cannot be translated. - ctx->current_oif (*post_oif, oif); + ctx->current_operation (*post_oif, oif); action a (mid, post_oid, oid); diff --git a/build2/cc/compile-rule.cxx b/build2/cc/compile-rule.cxx index f600f76..6902bb6 100644 --- a/build2/cc/compile-rule.cxx +++ b/build2/cc/compile-rule.cxx @@ -698,7 +698,7 @@ namespace build2 // Start asynchronous matching of prerequisites. Wait with unlocked // phase to allow phase switching. // - wait_guard wg (t.ctx, target::count_busy (), t[a].task_count, true); + wait_guard wg (t.ctx, t.ctx.count_busy (), t[a].task_count, true); size_t start (pts.size ()); // Index of the first to be added. for (prerequisite_member p: group_prerequisite_members (a, t)) @@ -760,7 +760,7 @@ namespace build2 continue; } - match_async (a, *pt, target::count_busy (), t[a].task_count); + match_async (a, *pt, t.ctx.count_busy (), t[a].task_count); pts.push_back (prerequisite_target (pt, pi)); } @@ -5585,7 +5585,7 @@ namespace build2 { touch (tp, false, 2); t.mtime (system_clock::now ()); - skip_count.fetch_add (1, memory_order_relaxed); + t.ctx.skip_count.fetch_add (1, memory_order_relaxed); } // Note: else mtime should be cached. diff --git a/build2/cc/link-rule.cxx b/build2/cc/link-rule.cxx index 57772a9..3d99535 100644 --- a/build2/cc/link-rule.cxx +++ b/build2/cc/link-rule.cxx @@ -484,6 +484,7 @@ namespace build2 tracer trace (x, "link_rule::apply"); file& t (xt.as ()); + context& ctx (t.ctx); // Note that for_install is signalled by install_rule and therefore // can only be relied upon during execute. @@ -698,7 +699,7 @@ namespace build2 // Note that ad hoc inputs have to be explicitly marked with the // include=adhoc prerequisite-specific variable. // - if (current_outer_oif != nullptr) + if (ctx.current_outer_oif != nullptr) continue; } @@ -1164,7 +1165,7 @@ namespace build2 bool u; if ((u = pt->is_a ()) || pt->is_a ()) { - const variable& var (t.ctx.var_pool["bin.whole"]); // @@ Cache. + const variable& var (ctx.var_pool["bin.whole"]); // @@ Cache. // See the bin module for the lookup semantics discussion. Note // that the variable is not overridable so we omit find_override() @@ -1198,7 +1199,7 @@ namespace build2 // Wait with unlocked phase to allow phase switching. // - wait_guard wg (t.ctx, target::count_busy (), t[a].task_count, true); + wait_guard wg (ctx, ctx.count_busy (), t[a].task_count, true); i = start; for (prerequisite_member p: group_prerequisite_members (a, t)) @@ -1230,7 +1231,7 @@ namespace build2 } } - match_async (a, *pt, target::count_busy (), t[a].task_count); + match_async (a, *pt, ctx.count_busy (), t[a].task_count); mark (pt, m); } -- cgit v1.1