diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2016-06-26 17:05:07 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2016-06-26 17:05:07 +0200 |
commit | 5f924ea1926fe17acf699a43713b7f5881e9d30d (patch) | |
tree | eccff3428e8a1b689e79b07088fc00b520a9485b | |
parent | 61617d7bb990f04970c6357d8e9a9095174d8fc4 (diff) |
Add support for passing configuration hints via module init()
-rw-r--r-- | build2/bin/module | 9 | ||||
-rw-r--r-- | build2/bin/module.cxx | 5 | ||||
-rw-r--r-- | build2/cli/module | 9 | ||||
-rw-r--r-- | build2/cli/module.cxx | 5 | ||||
-rw-r--r-- | build2/config/module | 9 | ||||
-rw-r--r-- | build2/config/module.cxx | 5 | ||||
-rw-r--r-- | build2/cxx/module | 9 | ||||
-rw-r--r-- | build2/cxx/module.cxx | 5 | ||||
-rw-r--r-- | build2/dist/module | 9 | ||||
-rw-r--r-- | build2/dist/module.cxx | 5 | ||||
-rw-r--r-- | build2/install/module | 9 | ||||
-rw-r--r-- | build2/install/module.cxx | 5 | ||||
-rw-r--r-- | build2/module | 15 | ||||
-rw-r--r-- | build2/module.cxx | 6 | ||||
-rw-r--r-- | build2/test/module | 9 | ||||
-rw-r--r-- | build2/test/module.cxx | 8 | ||||
-rw-r--r-- | build2/variable | 3 |
17 files changed, 97 insertions, 28 deletions
diff --git a/build2/bin/module b/build2/bin/module index 44dfbc7..0b9d44e 100644 --- a/build2/bin/module +++ b/build2/bin/module @@ -15,8 +15,13 @@ namespace build2 namespace bin { extern "C" bool - bin_init ( - scope&, scope&, const location&, unique_ptr<module_base>&, bool, bool); + bin_init (scope&, + scope&, + const location&, + unique_ptr<module_base>&, + bool, + bool, + const variable_map&); } } diff --git a/build2/bin/module.cxx b/build2/bin/module.cxx index 1ab29f9..d5df054 100644 --- a/build2/bin/module.cxx +++ b/build2/bin/module.cxx @@ -36,11 +36,14 @@ namespace build2 const location&, unique_ptr<module_base>&, bool first, - bool) + bool, + const variable_map& config_hints) { tracer trace ("bin::init"); l5 ([&]{trace << "for " << b.out_path ();}); + assert (config_hints.empty ()); // We don't known any hints. + // Enter module variables. // if (first) diff --git a/build2/cli/module b/build2/cli/module index 0469b2c..f55e03c 100644 --- a/build2/cli/module +++ b/build2/cli/module @@ -15,8 +15,13 @@ namespace build2 namespace cli { extern "C" bool - cli_init ( - scope&, scope&, const location&, unique_ptr<module_base>&, bool, bool); + cli_init (scope&, + scope&, + const location&, + unique_ptr<module_base>&, + bool, + bool, + const variable_map&); } } diff --git a/build2/cli/module.cxx b/build2/cli/module.cxx index 478c8a8..13325d9 100644 --- a/build2/cli/module.cxx +++ b/build2/cli/module.cxx @@ -31,11 +31,14 @@ namespace build2 const location& loc, unique_ptr<module_base>&, bool first, - bool optional) + bool optional, + const variable_map& config_hints) { tracer trace ("cli::init"); l5 ([&]{trace << "for " << base.out_path ();}); + assert (config_hints.empty ()); // We don't known any hints. + // Make sure the cxx module has been loaded since we need its targets // types (?xx{}). Note that we don't try to load it ourselves because of // the non-trivial variable merging semantics. So it is better to let diff --git a/build2/config/module b/build2/config/module index 6012442..912ab57 100644 --- a/build2/config/module +++ b/build2/config/module @@ -32,8 +32,13 @@ namespace build2 config_boot (scope&, const location&, unique_ptr<module_base>&); extern "C" bool - config_init ( - scope&, scope&, const location&, unique_ptr<module_base>&, bool, bool); + config_init (scope&, + scope&, + const location&, + unique_ptr<module_base>&, + bool, + bool, + const variable_map&); } } diff --git a/build2/config/module.cxx b/build2/config/module.cxx index 16eabe9..70301c5 100644 --- a/build2/config/module.cxx +++ b/build2/config/module.cxx @@ -59,7 +59,8 @@ namespace build2 const location& l, unique_ptr<module_base>& mod, bool first, - bool) + bool, + const variable_map& config_hints) { tracer trace ("config::init"); @@ -71,6 +72,8 @@ namespace build2 l5 ([&]{trace << "for " << root.out_path ();}); + assert (config_hints.empty ()); // We don't known any hints. + // Only create the module if we are configuring. // if (current_mif->id == configure_id) diff --git a/build2/cxx/module b/build2/cxx/module index 39d1218..254eb44 100644 --- a/build2/cxx/module +++ b/build2/cxx/module @@ -15,8 +15,13 @@ namespace build2 namespace cxx { extern "C" bool - cxx_init ( - scope&, scope&, const location&, unique_ptr<module_base>&, bool, bool); + cxx_init (scope&, + scope&, + const location&, + unique_ptr<module_base>&, + bool, + bool, + const variable_map&); } } diff --git a/build2/cxx/module.cxx b/build2/cxx/module.cxx index c03763f..7e9b5e2 100644 --- a/build2/cxx/module.cxx +++ b/build2/cxx/module.cxx @@ -35,11 +35,14 @@ namespace build2 const location& loc, unique_ptr<module_base>&, bool first, - bool) + bool, + const variable_map& config_hints) { tracer trace ("cxx::init"); l5 ([&]{trace << "for " << b.out_path ();}); + assert (config_hints.empty ()); // We don't known any hints. + // Initialize the bin module. Only do this if it hasn't already been // loaded so that we don't overwrite user's bin.* settings. // diff --git a/build2/dist/module b/build2/dist/module index 61e44c3..984a969 100644 --- a/build2/dist/module +++ b/build2/dist/module @@ -18,8 +18,13 @@ namespace build2 dist_boot (scope&, const location&, unique_ptr<module_base>&); extern "C" bool - dist_init ( - scope&, scope&, const location&, unique_ptr<module_base>&, bool, bool); + dist_init (scope&, + scope&, + const location&, + unique_ptr<module_base>&, + bool, + bool, + const variable_map&); } } diff --git a/build2/dist/module.cxx b/build2/dist/module.cxx index 5ae05a4..58bfc6f 100644 --- a/build2/dist/module.cxx +++ b/build2/dist/module.cxx @@ -60,7 +60,8 @@ namespace build2 const location& l, unique_ptr<module_base>&, bool first, - bool) + bool, + const variable_map& config_hints) { tracer trace ("dist::init"); @@ -73,6 +74,8 @@ namespace build2 const dir_path& out_root (r.out_path ()); l5 ([&]{trace << "for " << out_root;}); + assert (config_hints.empty ()); // We don't known any hints. + // Register our wildcard rule. Do it explicitly for the alias // to prevent something like insert<target>(dist_id, test_id) // taking precedence. diff --git a/build2/install/module b/build2/install/module index f81b6ac..b2a3301 100644 --- a/build2/install/module +++ b/build2/install/module @@ -18,8 +18,13 @@ namespace build2 install_boot (scope&, const location&, unique_ptr<module_base>&); extern "C" bool - install_init ( - scope&, scope&, const location&, unique_ptr<module_base>&, bool, bool); + install_init (scope&, + scope&, + const location&, + unique_ptr<module_base>&, + bool, + bool, + const variable_map&); } } diff --git a/build2/install/module.cxx b/build2/install/module.cxx index 15c6ea8..6a7e500 100644 --- a/build2/install/module.cxx +++ b/build2/install/module.cxx @@ -118,7 +118,8 @@ namespace build2 const location& l, unique_ptr<module_base>&, bool first, - bool) + bool, + const variable_map& config_hints) { tracer trace ("install::init"); @@ -131,6 +132,8 @@ namespace build2 const dir_path& out_root (r.out_path ()); l5 ([&]{trace << "for " << out_root;}); + assert (config_hints.empty ()); // We don't known any hints. + // Enter module variables. // // Note that the set_dir() calls below enter some more. diff --git a/build2/module b/build2/module index dcfe5d0..314f5a6 100644 --- a/build2/module +++ b/build2/module @@ -10,6 +10,7 @@ #include <build2/types> #include <build2/utility> +#include <build2/variable> #include <build2/diagnostics> namespace build2 @@ -40,8 +41,9 @@ namespace build2 scope& base, const location&, unique_ptr<module_base>&, - bool first, // First time for this project. - bool optional); // Loaded with 'using?' (optional module). + bool first, // First time for this project. + bool optional, // Loaded with using? (optional module). + const variable_map& hints); // Configuration hints (see below). struct module_state @@ -75,12 +77,19 @@ namespace build2 // Return true if the module was both successfully loaded and configured // (false can only be returned if optional). // + // The config_hints variable map can be used to pass configuration hints + // from one module to another. For example, the cxx modude may pass the + // target platform (which was extracted from the C++ compiler) to the bin + // module (which may not always be able to extract the same information from + // its tools). + // bool load_module (const string& name, scope& root, scope& base, const location&, - bool optional = false); + bool optional = false, + const variable_map& config_hints = variable_map ()); // Builtin modules. // diff --git a/build2/module.cxx b/build2/module.cxx index 1334689..e1e8afd 100644 --- a/build2/module.cxx +++ b/build2/module.cxx @@ -54,7 +54,8 @@ namespace build2 scope& rs, scope& bs, const location& loc, - bool opt) + bool opt, + const variable_map& hints) { // First see if this modules has already been loaded for this project. // @@ -96,7 +97,8 @@ namespace build2 } bool l (i != lm.end ()); - bool c (l && i->second.init (rs, bs, loc, i->second.module, f, opt)); + bool c (l && + i->second.init (rs, bs, loc, i->second.module, f, opt, hints)); const variable& lv (var_pool.insert<bool> (name + ".loaded", false, diff --git a/build2/test/module b/build2/test/module index 756b4f6..b9c3ea5 100644 --- a/build2/test/module +++ b/build2/test/module @@ -18,8 +18,13 @@ namespace build2 test_boot (scope&, const location&, unique_ptr<module_base>&); extern "C" bool - test_init ( - scope&, scope&, const location&, unique_ptr<module_base>&, bool, bool); + test_init (scope&, + scope&, + const location&, + unique_ptr<module_base>&, + bool, + bool, + const variable_map&); } } diff --git a/build2/test/module.cxx b/build2/test/module.cxx index e5b044a..c20e274 100644 --- a/build2/test/module.cxx +++ b/build2/test/module.cxx @@ -55,7 +55,8 @@ namespace build2 const location& l, unique_ptr<module_base>&, bool first, - bool) + bool, + const variable_map& config_hints) { tracer trace ("test::init"); @@ -68,7 +69,10 @@ namespace build2 const dir_path& out_root (root.out_path ()); l5 ([&]{trace << "for " << out_root;}); - //@@ Need ability to specify extra diff options (--strip-trailing-cr). + assert (config_hints.empty ()); // We don't known any hints. + + //@@ TODO: Need ability to specify extra diff options (e.g., + // --strip-trailing-cr, now hardcoded). // Register rules. // diff --git a/build2/variable b/build2/variable index c506a3e..5c567da 100644 --- a/build2/variable +++ b/build2/variable @@ -663,8 +663,9 @@ namespace build2 // variable_map // - struct variable_map + class variable_map { + public: using map_type = butl::prefix_map<variable_cref, value, '.'>; using size_type = map_type::size_type; |