From b5e5368e59e038503d3c22e3ed9cbc24c0d99253 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 31 Jan 2017 10:39:55 +0200 Subject: Add bin.vars module Use in cc to make sure hint variables are already registered. --- build2/cc/init.cxx | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) (limited to 'build2/cc') diff --git a/build2/cc/init.cxx b/build2/cc/init.cxx index ebe7653..698753e 100644 --- a/build2/cc/init.cxx +++ b/build2/cc/init.cxx @@ -20,22 +20,27 @@ namespace build2 namespace cc { bool - core_vars_init (scope& r, + core_vars_init (scope& rs, scope&, - const location&, + const location& loc, unique_ptr&, bool first, bool, const variable_map&) { tracer trace ("cc::core_vars_init"); - l5 ([&]{trace << "for " << r.out_path ();}); + l5 ([&]{trace << "for " << rs.out_path ();}); assert (first); + // Load bin.vars (we need its config.bin.target/pattern for hints). + // + if (!cast_false (rs["bin.vars.loaded"])) + load_module (rs, rs, "bin.vars", loc); + // Enter variables. Note: some overridable, some not. // - auto& v (var_pool.rw (r)); + auto& v (var_pool.rw (rs)); v.insert ("config.cc.poptions", true); v.insert ("config.cc.coptions", true); @@ -171,17 +176,13 @@ namespace build2 variable_map h; if (first) { - // Note that these variables have not yet been registered (we don't - // yet have the "bin.vars" module). + // Note that all these variables have already been registered. // - const variable& t (vp.insert ("config.bin.target")); - h.assign (t) = cast (rs["cc.target"]).string (); + h.assign ("config.bin.target") = + cast (rs["cc.target"]).string (); if (auto l = hints["config.bin.pattern"]) - { - const variable& p (vp.insert ("config.bin.pattern")); - h.assign (p) = cast (l); - } + h.assign ("config.bin.pattern") = cast (l); } load_module (rs, rs, "bin.config", loc, false, h); -- cgit v1.1