diff options
Diffstat (limited to 'build2/c')
-rw-r--r-- | build2/c/init.cxx | 62 | ||||
-rw-r--r-- | build2/c/init.hxx | 9 |
2 files changed, 55 insertions, 16 deletions
diff --git a/build2/c/init.cxx b/build2/c/init.cxx index 79cfec7..1190eae 100644 --- a/build2/c/init.cxx +++ b/build2/c/init.cxx @@ -30,7 +30,7 @@ namespace build2 config_module (config_data&& d) : config_data (move (d)), cc::config_module (move (d)) {} - strings + virtual strings translate_std (const compiler_info&, scope&, const string*) const override; @@ -106,22 +106,24 @@ namespace build2 return r; } + // See cc::module for details on guess_init vs config_init. + // bool - config_init (scope& rs, - scope& bs, - const location& loc, - unique_ptr<module_base>& mod, - bool, - bool, - const variable_map& hints) + guess_init (scope& rs, + scope& bs, + const location& loc, + unique_ptr<module_base>& mod, + bool, + bool, + const variable_map& hints) { - tracer trace ("c::config_init"); + tracer trace ("c::guess_init"); l5 ([&]{trace << "for " << bs.out_path ();}); // We only support root loading (which means there can only be one). // if (&rs != &bs) - fail (loc) << "c.config module must be loaded in project root"; + fail (loc) << "c.guess module must be loaded in project root"; // Load cc.core.vars so that we can cache all the cc.* variables. // @@ -207,10 +209,38 @@ namespace build2 assert (mod == nullptr); config_module* m (new config_module (move (d))); mod.reset (m); - m->init (rs, loc, hints); + m->guess (rs, loc, hints); return true; } + bool + config_init (scope& rs, + scope& bs, + const location& loc, + unique_ptr<module_base>&, + bool, + bool, + const variable_map& hints) + { + tracer trace ("c::config_init"); + l5 ([&]{trace << "for " << bs.out_path ();}); + + // We only support root loading (which means there can only be one). + // + if (&rs != &bs) + fail (loc) << "c.config module must be loaded in project root"; + + // Load c.guess. + // + if (!cast_false<bool> (rs["c.guess.loaded"])) + load_module (rs, rs, "c.guess", loc, false, hints); + + config_module& cm (*rs.modules.lookup<config_module> ("c.guess")); + cm.init (rs, loc, hints); + return true; + } + + static const target_type* const hdr[] = { &h::static_type, @@ -246,7 +276,7 @@ namespace build2 if (!cast_false<bool> (rs["c.config.loaded"])) load_module (rs, rs, "c.config", loc, false, hints); - config_module& cm (*rs.modules.lookup<config_module> ("c.config")); + config_module& cm (*rs.modules.lookup<config_module> ("c.guess")); cc::data d { cm, @@ -256,10 +286,10 @@ namespace build2 "c.install", "c.uninstall", - cm.cid, - cast<string> (rs[cm.x_id_variant]), - cast<uint64_t> (rs[cm.x_version_major]), - cast<uint64_t> (rs[cm.x_version_minor]), + cm.ci.id.value (), + cm.ci.id.variant, + cm.ci.version.major, + cm.ci.version.minor, cast<process_path> (rs[cm.x_path]), cast<target_triplet> (rs[cm.x_target]), diff --git a/build2/c/init.hxx b/build2/c/init.hxx index e18a5df..5fd7c84 100644 --- a/build2/c/init.hxx +++ b/build2/c/init.hxx @@ -15,6 +15,15 @@ namespace build2 namespace c { bool + guess_init (scope&, + scope&, + const location&, + unique_ptr<module_base>&, + bool, + bool, + const variable_map&); + + bool config_init (scope&, scope&, const location&, |