From 4f5b6cb7ed4e05e98cce7e692462f49e24b7a39a Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 22 Aug 2019 14:38:57 +0200 Subject: Targets, scopes, vars --- build2/b.cxx | 52 ++++++++++++++++++++++-------------------- build2/bin/init.cxx | 12 +++++----- build2/bin/target.cxx | 36 ++++++++++++++++------------- build2/c/init.cxx | 2 +- build2/cc/common.cxx | 43 +++++++++++++++++++---------------- build2/cc/common.hxx | 4 +++- build2/cc/compile-rule.cxx | 56 ++++++++++++++++++++++++++-------------------- build2/cc/init.cxx | 5 +++-- build2/cc/link-rule.cxx | 13 ++++++----- build2/cc/module.cxx | 16 +++++++------ build2/cc/msvc.cxx | 9 ++++++-- build2/cc/pkgconfig.cxx | 4 ++-- build2/cc/utility.cxx | 2 +- build2/cli/init.cxx | 2 +- build2/cli/rule.cxx | 4 ++-- build2/cli/target.cxx | 11 ++++----- build2/cxx/init.cxx | 7 +++--- 17 files changed, 156 insertions(+), 122 deletions(-) (limited to 'build2') diff --git a/build2/b.cxx b/build2/b.cxx index f359dbc..6a49cb7 100644 --- a/build2/b.cxx +++ b/build2/b.cxx @@ -590,6 +590,8 @@ main (int argc, char* argv[]) ? optional (ops.max_stack () * 1024) : nullopt)); + // @@ CTX: should these be per-context? + // variable_cache_mutex_shard_size = sched.shard_size (); variable_cache_mutex_shard.reset ( new shared_mutex[variable_cache_mutex_shard_size]); @@ -606,10 +608,11 @@ main (int argc, char* argv[]) trace << "jobs: " << jobs; } - // Set the build state before parsing the buildspec since it relies on - // global scope being setup. + // Set the build context before parsing the buildspec since it relies on + // the global scope being setup. We reset it for every meta-operation (see + // below). // - variable_overrides var_ovs (reset (cmd_vars)); + unique_ptr ctx (new context (sched, cmd_vars)); // Parse the buildspec. // @@ -619,7 +622,7 @@ main (int argc, char* argv[]) istringstream is (args); is.exceptions (istringstream::failbit | istringstream::badbit); - parser p; + parser p (*ctx); bspec = p.parse_buildspec (is, path ("")); } catch (const io_error&) @@ -745,13 +748,14 @@ main (int argc, char* argv[]) else opspecs.assign (lifted, 1); - // Reset the build state for each meta-operation since there is no + // Reset the build context for each meta-operation since there is no // guarantee their assumptions (e.g., in the load callback) are // compatible. // if (dirty) { - var_ovs = reset (cmd_vars); + ctx = nullptr; + ctx.reset (new context (sched, cmd_vars)); dirty = false; } @@ -778,15 +782,16 @@ 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 (var_ovs, mparams, opspecs, lifted != nullptr, l); + mname = current_mname = f ( + *ctx, mparams, opspecs, lifted != nullptr, l); } } // Expose early so can be used during bootstrap (with the same // limitations as for pre-processing). // - global_scope->rw ().assign (var_build_meta_operation) = mname; + scope& gs (ctx->global_scope.rw ()); + gs.assign (var_build_meta_operation) = mname; for (auto oit (opspecs.begin ()); oit != opspecs.end (); ++oit) { @@ -978,7 +983,7 @@ main (int argc, char* argv[]) // Handle a forwarded configuration. Note that if we've changed // out_root then we also have to remap out_base. // - out_root = bootstrap_fwd (src_root, altn); + out_root = bootstrap_fwd (*ctx, src_root, altn); if (src_root != out_root) { out_base = out_root / out_base.leaf (src_root); @@ -1023,8 +1028,7 @@ main (int argc, char* argv[]) // use to the bootstrap files (other than src-root.build, which, // BTW, doesn't need to exist if src_root == out_root). // - scope& rs ( - create_root (*scope::global_, out_root, src_root)->second); + scope& rs (create_root (gs, out_root, src_root)->second); bool bstrapped (bootstrapped (rs)); @@ -1238,7 +1242,7 @@ main (int argc, char* argv[]) fail (l) << "unexpected parameters for meta-operation " << mif->name; - set_current_mif (*mif); + ctx->current_mif (*mif); dirty = true; } @@ -1427,9 +1431,9 @@ main (int argc, char* argv[]) // So we split it into two passes. // { - auto& sm (scope_map::instance); + auto& sm (ctx->scopes.rw ()); - for (const variable_override& o: var_ovs) + for (const variable_override& o: ctx->var_overrides) { if (o.ovr.visibility != variable_visibility::normal) continue; @@ -1450,7 +1454,7 @@ main (int argc, char* argv[]) v = o.val; } - for (const variable_override& o: var_ovs) + for (const variable_override& o: ctx->var_overrides) { // Ours is either project (%foo) or scope (/foo). // @@ -1504,7 +1508,7 @@ main (int argc, char* argv[]) // building before we know how to for all the targets in this // operation batch. // - const scope& bs (scopes.find (ts.out_base)); + const scope& bs (ctx->scopes.find (ts.out_base)); // Find the target type and extract the extension. // @@ -1546,7 +1550,7 @@ main (int argc, char* argv[]) } // target if (dump_load) - dump (); + dump (*ctx); // Finally, match the rules and perform the operation. // @@ -1558,7 +1562,7 @@ main (int argc, char* argv[]) if (mif->operation_pre != nullptr) mif->operation_pre (mparams, pre_oid); // Cannot be translated. - set_current_oif (*pre_oif, oif); + ctx->current_oif (*pre_oif, oif); action a (mid, pre_oid, oid); @@ -1570,7 +1574,7 @@ main (int argc, char* argv[]) mif->match (mparams, a, tgs, diag, true /* progress */); if (dump_match) - dump (a); + dump (*ctx, a); if (mif->execute != nullptr && !ops.match_only ()) mif->execute (mparams, a, tgs, diag, true /* progress */); @@ -1585,7 +1589,7 @@ main (int argc, char* argv[]) tgs.reset (); } - set_current_oif (*oif, outer_oif); + ctx->current_oif (*oif, outer_oif); action a (mid, oid, oif->outer_id); @@ -1597,7 +1601,7 @@ main (int argc, char* argv[]) mif->match (mparams, a, tgs, diag, true /* progress */); if (dump_match) - dump (a); + dump (*ctx, a); if (mif->execute != nullptr && !ops.match_only ()) mif->execute (mparams, a, tgs, diag, true /* progress */); @@ -1613,7 +1617,7 @@ main (int argc, char* argv[]) if (mif->operation_pre != nullptr) mif->operation_pre (mparams, post_oid); // Cannot be translated. - set_current_oif (*post_oif, oif); + ctx->current_oif (*post_oif, oif); action a (mid, post_oid, oid); @@ -1625,7 +1629,7 @@ main (int argc, char* argv[]) mif->match (mparams, a, tgs, diag, true /* progress */); if (dump_match) - dump (a); + dump (*ctx, a); if (mif->execute != nullptr && !ops.match_only ()) mif->execute (mparams, a, tgs, diag, true /* progress */); diff --git a/build2/bin/init.cxx b/build2/bin/init.cxx index b46d643..4e80834 100644 --- a/build2/bin/init.cxx +++ b/build2/bin/init.cxx @@ -56,7 +56,7 @@ namespace build2 // Target is a string and not target_triplet because it can be // specified by the user. // - auto& vp (var_pool.rw (rs)); + auto& vp (rs.ctx.var_pool.rw (rs)); vp.insert ("config.bin.target", true); vp.insert ("config.bin.pattern", true); @@ -266,7 +266,7 @@ namespace build2 // config.bin.target // { - const variable& var (var_pool["config.bin.target"]); + const variable& var (rs.ctx.var_pool["config.bin.target"]); // We first see if the value was specified via the configuration // mechanism. @@ -343,7 +343,7 @@ namespace build2 // config.bin.pattern // { - const variable& var (var_pool["config.bin.pattern"]); + const variable& var (rs.ctx.var_pool["config.bin.pattern"]); // We first see if the value was specified via the configuration // mechanism. @@ -568,7 +568,7 @@ namespace build2 // if (first) { - auto& v (var_pool.rw (rs)); + auto& v (rs.ctx.var_pool.rw (rs)); v.insert ("bin.ar.path"); v.insert ("bin.ranlib.path"); @@ -744,7 +744,7 @@ namespace build2 // if (first) { - auto& v (var_pool.rw (rs)); + auto& v (rs.ctx.var_pool.rw (rs)); v.insert ("bin.ld.path"); v.insert ("config.bin.ld", true); @@ -857,7 +857,7 @@ namespace build2 // if (first) { - auto& v (var_pool.rw (rs)); + auto& v (rs.ctx.var_pool.rw (rs)); v.insert ("bin.rc.path"); v.insert ("config.bin.rc", true); diff --git a/build2/bin/target.cxx b/build2/bin/target.cxx index ec4a0ef..2ef3d87 100644 --- a/build2/bin/target.cxx +++ b/build2/bin/target.cxx @@ -88,11 +88,12 @@ namespace build2 // template static target* - m_factory (const target_type&, dir_path dir, dir_path out, string n) + m_factory (context& ctx, + const target_type&, dir_path dir, dir_path out, string n) { - const G* g (targets.find (dir, out, n)); + const G* g (ctx.targets.find (dir, out, n)); - M* m (new M (move (dir), move (out), move (n))); + M* m (new M (ctx, move (dir), move (out), move (n))); m->group = g; return m; @@ -258,21 +259,22 @@ namespace build2 // template static target* - g_factory (const target_type&, dir_path dir, dir_path out, string n) + g_factory (context& ctx, + const target_type&, dir_path dir, dir_path out, string n) { // Casts are MT-aware (during serial load). // E* e (phase == run_phase::load - ? const_cast (targets.find (dir, out, n)) + ? const_cast (ctx.targets.find (dir, out, n)) : nullptr); A* a (phase == run_phase::load - ? const_cast (targets.find (dir, out, n)) + ? const_cast (ctx.targets.find (dir, out, n)) : nullptr); S* s (phase == run_phase::load - ? const_cast (targets.find (dir, out, n)) + ? const_cast (ctx.targets.find (dir, out, n)) : nullptr); - G* g (new G (move (dir), move (out), move (n))); + G* g (new G (ctx, move (dir), move (out), move (n))); if (e != nullptr) e->group = g; if (a != nullptr) a->group = g; @@ -323,16 +325,17 @@ namespace build2 // The same as g_factory() but without E. // static target* - libul_factory (const target_type&, dir_path dir, dir_path out, string n) + libul_factory (context& ctx, + const target_type&, dir_path dir, dir_path out, string n) { libua* a (phase == run_phase::load - ? const_cast (targets.find (dir, out, n)) + ? const_cast (ctx.targets.find (dir, out, n)) : nullptr); libus* s (phase == run_phase::load - ? const_cast (targets.find (dir, out, n)) + ? const_cast (ctx.targets.find (dir, out, n)) : nullptr); - libul* g (new libul (move (dir), move (out), move (n))); + libul* g (new libul (ctx, move (dir), move (out), move (n))); if (a != nullptr) a->group = g; if (s != nullptr) s->group = g; @@ -403,18 +406,19 @@ namespace build2 } static target* - lib_factory (const target_type&, dir_path dir, dir_path out, string n) + lib_factory (context& ctx, + const target_type&, dir_path dir, dir_path out, string n) { // Casts are MT-aware (during serial load). // liba* a (phase == run_phase::load - ? const_cast (targets.find (dir, out, n)) + ? const_cast (ctx.targets.find (dir, out, n)) : nullptr); libs* s (phase == run_phase::load - ? const_cast (targets.find (dir, out, n)) + ? const_cast (ctx.targets.find (dir, out, n)) : nullptr); - lib* l (new lib (move (dir), move (out), move (n))); + lib* l (new lib (ctx, move (dir), move (out), move (n))); if (a != nullptr) a->group = l; if (s != nullptr) s->group = l; diff --git a/build2/c/init.cxx b/build2/c/init.cxx index 5c55281..ff9cc58 100644 --- a/build2/c/init.cxx +++ b/build2/c/init.cxx @@ -145,7 +145,7 @@ namespace build2 // Enter all the variables and initialize the module data. // - auto& v (var_pool.rw (rs)); + auto& v (rs.ctx.var_pool.rw (rs)); cc::config_data d { cc::lang::c, diff --git a/build2/cc/common.cxx b/build2/cc/common.cxx index aa0eb89..4f5db4c 100644 --- a/build2/cc/common.cxx +++ b/build2/cc/common.cxx @@ -87,7 +87,7 @@ namespace build2 bool impl (proc_impl && proc_impl (l, la)); bool cc (false), same (false); - auto& vp (var_pool); + auto& vp (top_bs.ctx.var_pool); lookup c_e_libs; lookup x_e_libs; @@ -221,7 +221,7 @@ namespace build2 : &cast ( bs.root_scope ()->vars[same ? x_sys_lib_dirs - : var_pool[*t + ".sys_lib_dirs"]]); + : bs.ctx.var_pool[*t + ".sys_lib_dirs"]]); }; auto find_linfo = [top_li, t, cc, &bs, &l, &li] () @@ -474,7 +474,7 @@ namespace build2 if (xt == nullptr) { if (n.qualified ()) - xt = import_existing (pk); + xt = import_existing (s.ctx, pk); } if (xt == nullptr) @@ -494,20 +494,21 @@ namespace build2 // template ulock common:: - insert_library (T*& r, + insert_library (context& ctx, + T*& r, const string& name, const dir_path& d, optional ext, bool exist, tracer& trace) { - auto p (targets.insert_locked (T::static_type, - d, - dir_path (), - name, - move (ext), - true, // Implied. - trace)); + auto p (ctx.targets.insert_locked (T::static_type, + d, + dir_path (), + name, + move (ext), + true, // Implied. + trace)); assert (!exist || !p.second.owns_lock ()); r = &p.first.template as (); @@ -626,6 +627,8 @@ namespace build2 &name, ext, &p, &f, exist, &trace, this] (const dir_path& d) -> bool { + context& ctx (p.scope->ctx); + timestamp mt; // libs @@ -648,9 +651,10 @@ namespace build2 if (tclass == "windows") { libi* i (nullptr); - insert_library (i, name, d, se, exist, trace); + insert_library (ctx, i, name, d, se, exist, trace); - ulock l (insert_library (s, name, d, nullopt, exist, trace)); + ulock l ( + insert_library (ctx, s, name, d, nullopt, exist, trace)); if (!exist) { @@ -677,7 +681,7 @@ namespace build2 } else { - insert_library (s, name, d, se, exist, trace); + insert_library (ctx, s, name, d, se, exist, trace); s->mtime (mt); s->path (move (f)); @@ -697,7 +701,7 @@ namespace build2 if (mt != timestamp_nonexistent) { - insert_library (s, name, d, se, exist, trace); + insert_library (ctx, s, name, d, se, exist, trace); s->mtime (mt); s->path (move (f)); @@ -722,7 +726,7 @@ namespace build2 // Note that this target is outside any project which we treat // as out trees. // - insert_library (a, name, d, ae, exist, trace); + insert_library (ctx, a, name, d, ae, exist, trace); a->mtime (mt); a->path (move (f)); } @@ -760,14 +764,14 @@ namespace build2 if (na && !r.first.empty ()) { - insert_library (a, name, d, nullopt, exist, trace); + insert_library (ctx, a, name, d, nullopt, exist, trace); a->mtime (timestamp_unreal); a->path (empty_path); } if (ns && !r.second.empty ()) { - insert_library (s, name, d, nullopt, exist, trace); + insert_library (ctx, s, name, d, nullopt, exist, trace); s->mtime (timestamp_unreal); s->path (empty_path); } @@ -821,7 +825,8 @@ namespace build2 // Enter (or find) the lib{} target group. // lib* lt; - insert_library (lt, name, *pd, l ? p.tk.ext : nullopt, exist, trace); + insert_library ( + p.scope->ctx, lt, name, *pd, l ? p.tk.ext : nullopt, exist, trace); // Result. // diff --git a/build2/cc/common.hxx b/build2/cc/common.hxx index c58a7f3..b24eb7d 100644 --- a/build2/cc/common.hxx +++ b/build2/cc/common.hxx @@ -8,6 +8,7 @@ #include #include +#include #include #include @@ -278,7 +279,8 @@ namespace build2 template static ulock - insert_library (T*&, + insert_library (context&, + T*&, const string&, const dir_path&, optional, diff --git a/build2/cc/compile-rule.cxx b/build2/cc/compile-rule.cxx index 833fd44..9dede21 100644 --- a/build2/cc/compile-rule.cxx +++ b/build2/cc/compile-rule.cxx @@ -365,7 +365,9 @@ namespace build2 const variable& var ( com ? c_export_poptions - : (t == x ? x_export_poptions : var_pool[t + ".export.poptions"])); + : (t == x + ? x_export_poptions + : l.ctx.var_pool[t + ".export.poptions"])); append_options (args, l, var); }; @@ -418,7 +420,9 @@ namespace build2 const variable& var ( com ? c_export_poptions - : (t == x ? x_export_poptions : var_pool[t + ".export.poptions"])); + : (t == x + ? x_export_poptions + : l.ctx.var_pool[t + ".export.poptions"])); hash_options (cs, l, var); }; @@ -472,7 +476,9 @@ namespace build2 const variable& var ( com ? c_export_poptions - : (t == x ? x_export_poptions : var_pool[t + ".export.poptions"])); + : (t == x + ? x_export_poptions + : l.ctx.var_pool[t + ".export.poptions"])); append_prefixes (m, l, var); }; @@ -2161,7 +2167,7 @@ namespace build2 // small_vector tts; - const scope& bs (scopes.find (d)); + const scope& bs (t.ctx.scopes.find (d)); if (const scope* rs = bs.root_scope ()) { tts = map_extension (bs, n, e); @@ -2201,7 +2207,7 @@ namespace build2 // absolute path with a spelled-out extension to multiple targets. // for (const target_type* tt: tts) - if ((r = targets.find (*tt, d, out, n, e, trace)) != nullptr) + if ((r = t.ctx.targets.find (*tt, d, out, n, e, trace)) != nullptr) break; // Note: we can't do this because of the in-source builds where @@ -2887,7 +2893,7 @@ namespace build2 // See if this path is inside a project with an out-of- // tree build and is in the out directory tree. // - const scope& bs (scopes.find (d)); + const scope& bs (t.ctx.scopes.find (d)); if (bs.root_scope () != nullptr) { const dir_path& bp (bs.out_path ()); @@ -5101,7 +5107,7 @@ namespace build2 modules_sidebuild_dir /= x); - const scope* ps (&scopes.find (pd)); + const scope* ps (&rs.ctx.scopes.find (pd)); if (ps->out_path () != pd) { @@ -5112,7 +5118,7 @@ namespace build2 // Re-test again now that we are in exclusive phase (another thread // could have already created and loaded the subproject). // - ps = &scopes.find (pd); + ps = &rs.ctx.scopes.find (pd); if (ps->out_path () != pd) { @@ -5200,7 +5206,7 @@ namespace build2 // exists then we assume all this is already done (otherwise why would // someone have created such a target). // - if (const file* bt = targets.find ( + if (const file* bt = bs.ctx.targets.find ( tt, pd, dir_path (), // Always in the out tree. @@ -5237,13 +5243,14 @@ namespace build2 } } - auto p (targets.insert_locked (tt, - move (pd), - dir_path (), // Always in the out tree. - move (mf), - nullopt, // Use default extension. - true, // Implied. - trace)); + auto p (bs.ctx.targets.insert_locked ( + tt, + move (pd), + dir_path (), // Always in the out tree. + move (mf), + nullopt, // Use default extension. + true, // Implied. + trace)); file& bt (static_cast (p.first)); // Note that this is racy and someone might have created this target @@ -5295,7 +5302,7 @@ namespace build2 const target_type& tt (compile_types (li.type).hbmi); - if (const file* bt = targets.find ( + if (const file* bt = bs.ctx.targets.find ( tt, pd, dir_path (), // Always in the out tree. @@ -5307,13 +5314,14 @@ namespace build2 prerequisites ps; ps.push_back (prerequisite (ht)); - auto p (targets.insert_locked (tt, - move (pd), - dir_path (), // Always in the out tree. - move (mf), - nullopt, // Use default extension. - true, // Implied. - trace)); + auto p (bs.ctx.targets.insert_locked ( + tt, + move (pd), + dir_path (), // Always in the out tree. + move (mf), + nullopt, // Use default extension. + true, // Implied. + trace)); file& bt (static_cast (p.first)); // Note that this is racy and someone might have created this target diff --git a/build2/cc/init.cxx b/build2/cc/init.cxx index e22ece7..3ff59a1 100644 --- a/build2/cc/init.cxx +++ b/build2/cc/init.cxx @@ -77,7 +77,7 @@ namespace build2 // Enter variables. Note: some overridable, some not. // - auto& v (var_pool.rw (rs)); + auto& v (rs.ctx.var_pool.rw (rs)); auto v_t (variable_visibility::target); @@ -276,7 +276,8 @@ namespace build2 // Prepare configuration hints. They are only used on the first load // of bin.config so we only populate them on our first load. // - variable_map h; + variable_map h (rs.ctx); + if (first) { // Note that all these variables have already been registered. diff --git a/build2/cc/link-rule.cxx b/build2/cc/link-rule.cxx index bb91722..09109c2 100644 --- a/build2/cc/link-rule.cxx +++ b/build2/cc/link-rule.cxx @@ -165,14 +165,15 @@ namespace build2 // otherwise the above search would have returned the member // target. // - pt = search_existing (p.prerequisite.key (tt)); + pt = search_existing (t.ctx, p.prerequisite.key (tt)); } } else if (!p.is_a ()) { // See if we also/instead have a group. // - pg = search_existing (p.prerequisite.key (libul::static_type)); + pg = search_existing (t.ctx, + p.prerequisite.key (libul::static_type)); if (pt == nullptr) swap (pt, pg); @@ -1163,7 +1164,7 @@ namespace build2 bool u; if ((u = pt->is_a ()) || pt->is_a ()) { - const variable& var (var_pool["bin.whole"]); // @@ Cache. + const variable& var (t.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() @@ -1473,7 +1474,7 @@ namespace build2 ? (exp ? c_export_loptions : c_loptions) : (t == x ? (exp ? x_export_loptions : x_loptions) - : var_pool[t + (exp ? ".export.loptions" : ".loptions")])); + : l.ctx.var_pool[t + (exp ? ".export.loptions" : ".loptions")])); append_options (d.args, *g, var); } @@ -1575,7 +1576,7 @@ namespace build2 ? (exp ? c_export_loptions : c_loptions) : (t == x ? (exp ? x_export_loptions : x_loptions) - : var_pool[t + (exp ? ".export.loptions" : ".loptions")])); + : l.ctx.var_pool[t + (exp ? ".export.loptions" : ".loptions")])); hash_options (d.cs, *g, var); } @@ -1966,7 +1967,7 @@ namespace build2 const string& cs ( cast ( rs[tsys == "win32-msvc" - ? var_pool["bin.ld.checksum"] + ? t.ctx.var_pool["bin.ld.checksum"] : x_checksum])); if (dd.expect (cs) != nullptr) diff --git a/build2/cc/module.cxx b/build2/cc/module.cxx index 36cdd1a..064d954 100644 --- a/build2/cc/module.cxx +++ b/build2/cc/module.cxx @@ -41,9 +41,13 @@ namespace build2 config::save_module (rs, x, 250); - const variable& config_c_poptions (var_pool["config.cc.poptions"]); - const variable& config_c_coptions (var_pool["config.cc.coptions"]); - const variable& config_c_loptions (var_pool["config.cc.loptions"]); + auto& vp (rs.ctx.var_pool.rw (rs)); + + // Must already exist. + // + const variable& config_c_poptions (vp["config.cc.poptions"]); + const variable& config_c_coptions (vp["config.cc.coptions"]); + const variable& config_c_loptions (vp["config.cc.loptions"]); // config.x // @@ -63,8 +67,6 @@ namespace build2 // if (!cc_loaded) { - auto& vp (var_pool.rw (rs)); - for (const char* const* pm (x_hinters); *pm != nullptr; ++pm) { string m (*pm); @@ -201,7 +203,7 @@ namespace build2 { // Prepare configuration hints. // - variable_map h; + variable_map h (rs.ctx); // Note that all these variables have already been registered. // @@ -545,7 +547,7 @@ namespace build2 // if (!cast_false (rs["cc.core.config.loaded"])) { - variable_map h; + variable_map h (rs.ctx); if (!ci.bin_pattern.empty ()) h.assign ("config.bin.pattern") = ci.bin_pattern; diff --git a/build2/cc/msvc.cxx b/build2/cc/msvc.cxx index 6125fdd..7d8c3f5 100644 --- a/build2/cc/msvc.cxx +++ b/build2/cc/msvc.cxx @@ -365,6 +365,7 @@ namespace build2 { // Pretty similar logic to search_library(). // + assert (p.scope != nullptr); const optional& ext (p.tk.ext); const string& name (*p.tk.name); @@ -403,7 +404,7 @@ namespace build2 // Enter the target. // T* t; - common::insert_library (t, name, d, e, exist, trace); + common::insert_library (p.scope->ctx, t, name, d, e, exist, trace); t->mtime (mt); t->path (move (f)); @@ -453,6 +454,8 @@ namespace build2 { tracer trace (x, "msvc_search_shared"); + assert (pk.scope != nullptr); + libs* s (nullptr); auto search = [&s, &ld, &d, &pk, exist, &trace] ( @@ -461,7 +464,9 @@ namespace build2 if (libi* i = msvc_search_library ( ld, d, pk, otype::s, pf, sf, exist, trace)) { - ulock l (insert_library (s, *pk.tk.name, d, nullopt, exist, trace)); + ulock l ( + insert_library ( + pk.scope->ctx, s, *pk.tk.name, d, nullopt, exist, trace)); if (!exist) { diff --git a/build2/cc/pkgconfig.cxx b/build2/cc/pkgconfig.cxx index c23b746..13cc752 100644 --- a/build2/cc/pkgconfig.cxx +++ b/build2/cc/pkgconfig.cxx @@ -1027,7 +1027,7 @@ namespace build2 // Parse modules and add them to the prerequisites. // - auto parse_modules = [&trace, &next, this] + auto parse_modules = [&trace, &next, &s, this] (const pkgconf& pc, prerequisites& ps) { string mstr (pc.variable ("cxx_modules")); @@ -1057,7 +1057,7 @@ namespace build2 // For now there are only C++ modules. // auto tl ( - targets.insert_locked ( + s.ctx.targets.insert_locked ( *x_mod, mp.directory (), dir_path (), diff --git a/build2/cc/utility.cxx b/build2/cc/utility.cxx index 3271f7c..ff807c9 100644 --- a/build2/cc/utility.cxx +++ b/build2/cc/utility.cxx @@ -72,7 +72,7 @@ namespace build2 // return phase == run_phase::match && !exist ? &search (x, tt, x.dir, x.out, x.name) - : search_existing (tt, x.dir, x.out, x.name); + : search_existing (x.ctx, tt, x.dir, x.out, x.name); } else { diff --git a/build2/cli/init.cxx b/build2/cli/init.cxx index 6d20aa0..2e553f7 100644 --- a/build2/cli/init.cxx +++ b/build2/cli/init.cxx @@ -43,7 +43,7 @@ namespace build2 // if (first) { - auto& v (var_pool.rw (rs)); + auto& v (rs.ctx.var_pool.rw (rs)); // Note: some overridable, some not. // diff --git a/build2/cli/rule.cxx b/build2/cli/rule.cxx index f6bebee..f6c0763 100644 --- a/build2/cli/rule.cxx +++ b/build2/cli/rule.cxx @@ -112,7 +112,7 @@ namespace build2 // Check if there is a corresponding cli.cxx{} group. // - const cli_cxx* g (targets.find (t.dir, t.out, t.name)); + const cli_cxx* g (t.ctx.targets.find (t.dir, t.out, t.name)); // If not or if it has no prerequisites (happens when we use it to // set cli.options) and this target has a cli{} prerequisite, then @@ -124,7 +124,7 @@ namespace build2 prerequisite_members (a, t))) { if (g == nullptr) - g = &targets.insert (t.dir, t.out, t.name, trace); + g = &t.ctx.targets.insert (t.dir, t.out, t.name, trace); g->prerequisites (prerequisites {p->as_prerequisite ()}); } diff --git a/build2/cli/target.cxx b/build2/cli/target.cxx index 096295a..caa12b0 100644 --- a/build2/cli/target.cxx +++ b/build2/cli/target.cxx @@ -45,7 +45,8 @@ namespace build2 } static target* - cli_cxx_factory (const target_type&, dir_path d, dir_path o, string n) + cli_cxx_factory (context& ctx, + const target_type&, dir_path d, dir_path o, string n) { tracer trace ("cli::cli_cxx_factory"); @@ -55,11 +56,11 @@ namespace build2 // // Also required for the src-out remapping logic. // - targets.insert (d, o, n, trace); - targets.insert (d, o, n, trace); - targets.insert (d, o, n, trace); + ctx.targets.insert (d, o, n, trace); + ctx.targets.insert (d, o, n, trace); + ctx.targets.insert (d, o, n, trace); - return new cli_cxx (move (d), move (o), move (n)); + return new cli_cxx (ctx, move (d), move (o), move (n)); } const target_type cli_cxx::static_type diff --git a/build2/cxx/init.cxx b/build2/cxx/init.cxx index c355763..1ffa098 100644 --- a/build2/cxx/init.cxx +++ b/build2/cxx/init.cxx @@ -62,7 +62,8 @@ namespace build2 // auto enter = [&rs] (const char* v) -> const variable& { - return var_pool.rw (rs).insert (v, variable_visibility::project); + return rs.ctx.var_pool.rw (rs).insert ( + v, variable_visibility::project); }; // NOTE: see also module sidebuild subproject if changing anything about @@ -370,7 +371,7 @@ namespace build2 // Enter all the variables and initialize the module data. // - auto& v (var_pool.rw (rs)); + auto& v (rs.ctx.var_pool.rw (rs)); cc::config_data d { cc::lang::cxx, @@ -572,7 +573,7 @@ namespace build2 config_module& cm (*rs.lookup_module ("cxx.guess")); - auto& vp (var_pool.rw (rs)); + auto& vp (rs.ctx.var_pool.rw (rs)); bool modules (cast (rs["cxx.features.modules"])); -- cgit v1.1