From 19af3f6b0873a92582e4787a87a6f14df53ff6ae Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 10 Oct 2022 18:22:31 +0200 Subject: Preparatory work for public/private variable distinction We still always use the public var_pool from context but where required, all access now goes through scope::var_pool(). --- libbuild2/cc/common.cxx | 7 +++++-- libbuild2/cc/compile-rule.cxx | 4 ++++ libbuild2/cc/init.cxx | 7 ++++--- libbuild2/cc/link-rule.cxx | 8 +++++++- libbuild2/cc/module.cxx | 8 +++++--- libbuild2/cc/pkgconfig.cxx | 8 +++++++- 6 files changed, 32 insertions(+), 10 deletions(-) (limited to 'libbuild2/cc') diff --git a/libbuild2/cc/common.cxx b/libbuild2/cc/common.cxx index 4a0c4b1..2d344f1 100644 --- a/libbuild2/cc/common.cxx +++ b/libbuild2/cc/common.cxx @@ -164,6 +164,9 @@ namespace build2 if (self && proc_lib) chain->push_back (&l); + // We only lookup public variables so go straight for the public + // variable pool. + // auto& vp (top_bs.ctx.var_pool); do // Breakout loop. @@ -347,7 +350,7 @@ namespace build2 // Find system search directories corresponding to this library, i.e., // from its project and for its type (C, C++, etc). // - auto find_sysd = [&top_sysd, t, cc, same, &bs, &sysd, this] () + auto find_sysd = [&top_sysd, &vp, t, cc, same, &bs, &sysd, this] () { // Use the search dirs corresponding to this library scope/type. // @@ -356,7 +359,7 @@ namespace build2 : &cast ( bs.root_scope ()->vars[same ? x_sys_lib_dirs - : bs.ctx.var_pool[t + ".sys_lib_dirs"]]); + : vp[t + ".sys_lib_dirs"]]); }; auto find_linfo = [top_li, t, cc, &bs, &l, &li] () diff --git a/libbuild2/cc/compile-rule.cxx b/libbuild2/cc/compile-rule.cxx index fdc1416..fda97a0 100644 --- a/libbuild2/cc/compile-rule.cxx +++ b/libbuild2/cc/compile-rule.cxx @@ -530,6 +530,8 @@ namespace build2 if (find (d.ls.begin (), d.ls.end (), &l) != d.ls.end ()) return false; + // Note: go straight for the public variable pool. + // const variable& var ( com ? c_export_poptions @@ -781,6 +783,8 @@ namespace build2 // if (const scope* rs = l.base_scope ().root_scope ()) { + // Note: go straight for the public variable pool. + // const variable& var ( com ? c_export_poptions diff --git a/libbuild2/cc/init.cxx b/libbuild2/cc/init.cxx index 062e750..b2f35aa 100644 --- a/libbuild2/cc/init.cxx +++ b/libbuild2/cc/init.cxx @@ -338,10 +338,11 @@ namespace build2 // if (!cast_false (rs["bin.config.loaded"])) { - // Prepare configuration hints. They are only used on the first load - // of bin.config so we only populate them on our first load. + // Prepare configuration hints (pretend it belongs to root scope). + // They are only used on the first load of bin.config so we only + // populate them on our first load. // - variable_map h (rs.ctx); + variable_map h (rs); if (first) { diff --git a/libbuild2/cc/link-rule.cxx b/libbuild2/cc/link-rule.cxx index 8bc073a..94e885f 100644 --- a/libbuild2/cc/link-rule.cxx +++ b/libbuild2/cc/link-rule.cxx @@ -1914,6 +1914,8 @@ namespace build2 bool u; if ((u = pt->is_a ()) || pt->is_a ()) { + // Note: go straight for the public variable pool. + // const variable& var (ctx.var_pool["bin.whole"]); // @@ Cache. // See the bin module for the lookup semantics discussion. Note @@ -2364,6 +2366,8 @@ namespace build2 // if (const target* g = exp && l.is_a () ? l.group : &l) { + // Note: go straight for the public variable pool. + // const variable& var ( com ? (exp ? c_export_loptions : c_loptions) @@ -2751,7 +2755,7 @@ namespace build2 // those that don't match. Note that we have to do it after updating // prerequisites to keep the dependency counts straight. // - if (const variable* var_fi = ctx.var_pool.find ("for_install")) + if (const variable* var_fi = rs.var_pool ().find ("for_install")) { // Parallel prerequisites/prerequisite_targets loop. // @@ -3007,6 +3011,8 @@ namespace build2 { // For VC we use link.exe directly. // + // Note: go straight for the public variable pool. + // const string& cs ( cast ( rs[tsys == "win32-msvc" diff --git a/libbuild2/cc/module.cxx b/libbuild2/cc/module.cxx index c930d49..27f9d9e 100644 --- a/libbuild2/cc/module.cxx +++ b/libbuild2/cc/module.cxx @@ -265,9 +265,9 @@ namespace build2 // if (!cc_loaded) { - // Prepare configuration hints. + // Prepare configuration hints (pretend it belongs to root scope). // - variable_map h (rs.ctx); + variable_map h (rs); // Note that all these variables have already been registered. // @@ -376,7 +376,9 @@ namespace build2 // if (!cast_false (rs["cc.core.config.loaded"])) { - variable_map h (rs.ctx); + // Prepare configuration hints (pretend it belongs to root scope). + // + variable_map h (rs); if (!xi.bin_pattern.empty ()) h.assign ("config.bin.pattern") = xi.bin_pattern; diff --git a/libbuild2/cc/pkgconfig.cxx b/libbuild2/cc/pkgconfig.cxx index 5efab0d..6023b45 100644 --- a/libbuild2/cc/pkgconfig.cxx +++ b/libbuild2/cc/pkgconfig.cxx @@ -802,6 +802,11 @@ namespace build2 context& ctx (t.ctx); + // These should be public (qualified) variables so go straight for + // the public variable pool. + // + auto& vp (ctx.var_pool.rw ()); // Load phase. + optional ver; optional pfx; @@ -865,7 +870,6 @@ namespace build2 : name (move (s))); } - auto& vp (ctx.var_pool.rw ()); // Load phase. const variable& var (vp.insert (move (vn))); value& v (t.assign (var)); @@ -1974,6 +1978,8 @@ namespace build2 // if (la) { + // Note: go straight for the public variable pool. + // if (cast_false (l.lookup_original ( ctx.var_pool["bin.whole"], true /* target_only */).first)) -- cgit v1.1