From 3e9c6f5d168387e6e5d9240b9e0e201f661da913 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 23 Aug 2016 06:43:00 +0200 Subject: Add cc.config in addition to cc --- build2/cc/init.cxx | 75 ++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 56 insertions(+), 19 deletions(-) (limited to 'build2/cc/init.cxx') diff --git a/build2/cc/init.cxx b/build2/cc/init.cxx index 63341d5..474db70 100644 --- a/build2/cc/init.cxx +++ b/build2/cc/init.cxx @@ -282,45 +282,82 @@ namespace build2 return true; } - bool - init (scope& r, - scope& b, - const location& loc, - unique_ptr&, - bool, - bool, - const variable_map&) + // The cc module is an "alias" for c and cxx. Its intended use is to make + // sure that the C/C++ configuration is captured in an amalgamation rather + // than subprojects. + // + static inline bool + init_alias (tracer& trace, + const char* c, + const char* c_loaded, + const char* cxx, + const char* cxx_loaded, + scope& r, + scope& b, + const location& loc, + const variable_map& hints) { - tracer trace ("cc::init"); l5 ([&]{trace << "for " << b.out_path ();}); - // This module is an "alias" for c.config and cxx.config. Its intended - // use is to make sure that the C/C++ configuration is captured in an - // amalgamation rather than subprojects. - // // We want to order the loading to match what user specified on the // command line (config.c or config.cxx). This way the first loaded // module (with user-specified config.*) will hint the compiler to the // second. // - bool lc (!cast_false (b["c.config.loaded"])); - bool lp (!cast_false (b["cxx.config.loaded"])); + bool lc (!cast_false (b[c_loaded])); + bool lp (!cast_false (b[cxx_loaded])); // If none of them are already loaded, load c first only if config.c // is specified. // if (lc && lp && r["config.c"]) { - load_module ("c.config", r, b, loc); - load_module ("cxx.config", r, b, loc); + load_module (c, r, b, loc, false, hints); + load_module (cxx, r, b, loc, false, hints); } else { - if (lp) load_module ("cxx.config", r, b, loc); - if (lc) load_module ("c.config", r, b, loc); + if (lp) load_module (cxx, r, b, loc, false, hints); + if (lc) load_module (c, r, b, loc, false, hints); } return true; } + + bool + config_init (scope& r, + scope& b, + const location& loc, + unique_ptr&, + bool, + bool, + const variable_map& hints) + { + tracer trace ("cc::config_init"); + return init_alias (trace, + "c.config", "c.config.loaded", + "cxx.config", "cxx.config.loaded", + r, b, + loc, + hints); + } + + bool + init (scope& r, + scope& b, + const location& loc, + unique_ptr&, + bool, + bool, + const variable_map& hints) + { + tracer trace ("cc::init"); + return init_alias (trace, + "c", "c.loaded", + "cxx", "cxx.loaded", + r, b, + loc, + hints); + } } } -- cgit v1.1