aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2016-08-23 06:43:00 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2016-08-23 06:43:00 +0200
commit3e9c6f5d168387e6e5d9240b9e0e201f661da913 (patch)
treef80cbea98a6e6ce582c4cce88c88679f3f8aaa6e
parent960b9a32557ad054707cc1540441057808db2d8f (diff)
Add cc.config in addition to cc
-rw-r--r--build2/b.cxx1
-rw-r--r--build2/cc/init9
-rw-r--r--build2/cc/init.cxx75
3 files changed, 66 insertions, 19 deletions
diff --git a/build2/b.cxx b/build2/b.cxx
index 61d120a..8114d78 100644
--- a/build2/b.cxx
+++ b/build2/b.cxx
@@ -231,6 +231,7 @@ main (int argc, char* argv[])
bm["cc.core.vars"] = mf {nullptr, &cc::core_vars_init};
bm["cc.core.config"] = mf {nullptr, &cc::core_config_init};
bm["cc.core"] = mf {nullptr, &cc::core_init};
+ bm["cc.config"] = mf {nullptr, &cc::config_init};
bm["cc"] = mf {nullptr, &cc::init};
bm["c.config"] = mf {nullptr, &c::config_init};
diff --git a/build2/cc/init b/build2/cc/init
index 3e84f51..32d9f3c 100644
--- a/build2/cc/init
+++ b/build2/cc/init
@@ -42,6 +42,15 @@ namespace build2
const variable_map&);
bool
+ config_init (scope&,
+ scope&,
+ const location&,
+ unique_ptr<module_base>&,
+ bool,
+ bool,
+ const variable_map&);
+
+ bool
init (scope&,
scope&,
const location&,
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<module_base>&,
- 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<bool> (b["c.config.loaded"]));
- bool lp (!cast_false<bool> (b["cxx.config.loaded"]));
+ bool lc (!cast_false<bool> (b[c_loaded]));
+ bool lp (!cast_false<bool> (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<module_base>&,
+ 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<module_base>&,
+ bool,
+ bool,
+ const variable_map& hints)
+ {
+ tracer trace ("cc::init");
+ return init_alias (trace,
+ "c", "c.loaded",
+ "cxx", "cxx.loaded",
+ r, b,
+ loc,
+ hints);
+ }
}
}