diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2017-01-31 10:39:55 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2017-02-13 12:42:41 +0200 |
commit | b5e5368e59e038503d3c22e3ed9cbc24c0d99253 (patch) | |
tree | b05b2ef6d186224e015a6dc9ca36f3be9e2e3dc5 /build2/cc/init.cxx | |
parent | 37a3a93c56efb9ed1030debfd7a68d56d8557327 (diff) |
Add bin.vars module
Use in cc to make sure hint variables are already registered.
Diffstat (limited to 'build2/cc/init.cxx')
-rw-r--r-- | build2/cc/init.cxx | 25 |
1 files changed, 13 insertions, 12 deletions
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<module_base>&, 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<bool> (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<strings> ("config.cc.poptions", true); v.insert<strings> ("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<target_triplet> (rs["cc.target"]).string (); + h.assign ("config.bin.target") = + cast<target_triplet> (rs["cc.target"]).string (); if (auto l = hints["config.bin.pattern"]) - { - const variable& p (vp.insert ("config.bin.pattern")); - h.assign (p) = cast<string> (l); - } + h.assign ("config.bin.pattern") = cast<string> (l); } load_module (rs, rs, "bin.config", loc, false, h); |