From b262d2c9c56eed18d043dccefac02b54a6ae2f95 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 30 Jan 2017 11:12:25 +0200 Subject: Implement pattern-based variable typing, tighten variable type update --- build2/config/init.cxx | 4 ++++ build2/config/utility | 6 +++--- build2/config/utility.cxx | 18 ++++++++++-------- 3 files changed, 17 insertions(+), 11 deletions(-) (limited to 'build2/config') diff --git a/build2/config/init.cxx b/build2/config/init.cxx index 1f0b391..cfb69e0 100644 --- a/build2/config/init.cxx +++ b/build2/config/init.cxx @@ -40,6 +40,10 @@ namespace build2 auto& vp (var_pool.rw (rs)); + // utility.cxx:unconfigured() + // + vp.insert_pattern ("config.*.configured"); + // Load config.build if one exists. // // Note that we have to do this during bootstrap since the order in diff --git a/build2/config/utility b/build2/config/utility index e4e463d..041277a 100644 --- a/build2/config/utility +++ b/build2/config/utility @@ -116,21 +116,21 @@ namespace build2 // running the tests, etc). // bool - specified (scope& root, const string& ns); + specified (scope& root, const string& name); // Check if there is a false config.*.configured value. This mechanism can // be used to "remember" that the module is left unconfigured in order to // avoid re-running the tests, etc. // bool - unconfigured (scope& root, const string& ns); + unconfigured (scope& root, const string& name); // Set the config.*.configured value. Note that you only need to set it to // false. It will be automatically ignored if there are any other config.* // values for this module. Return true if this sets a new value. // bool - unconfigured (scope& root, const string& ns, bool); + unconfigured (scope& root, const string& name, bool); // Enter the variable so that it is saved during configuration. See // config::module for details. diff --git a/build2/config/utility.cxx b/build2/config/utility.cxx index 7db4555..08faeeb 100644 --- a/build2/config/utility.cxx +++ b/build2/config/utility.cxx @@ -62,7 +62,7 @@ namespace build2 } bool - specified (scope& r, const string& ns) + specified (scope& r, const string& n) { // Search all outer scopes for any value in this namespace. // @@ -72,7 +72,7 @@ namespace build2 // any original values, they will be "visible"; see find_override() for // details. // - const variable& vns (var_pool.rw (r).insert (ns)); + const variable& vns (var_pool.rw (r).insert ("config." + n)); for (scope* s (&r); s != nullptr; s = s->parent_scope ()) { for (auto p (s->vars.find_namespace (vns)); @@ -93,11 +93,12 @@ namespace build2 } bool - unconfigured (scope& rs, const string& ns) + unconfigured (scope& rs, const string& n) { - // Note: not overridable. + // Pattern-typed in boot() as bool. // - const variable& var (var_pool.rw (rs).insert (ns + ".configured")); + const variable& var ( + var_pool.rw (rs).insert ("config." + n + ".configured")); if (current_mif->id == configure_id) save_variable (rs, var); @@ -107,11 +108,12 @@ namespace build2 } bool - unconfigured (scope& rs, const string& ns, bool v) + unconfigured (scope& rs, const string& n, bool v) { - // Note: not overridable. + // Pattern-typed in boot() as bool. // - const variable& var (var_pool.rw (rs).insert (ns + ".configured")); + const variable& var ( + var_pool.rw (rs).insert ("config." + n + ".configured")); if (current_mif->id == configure_id) save_variable (rs, var); -- cgit v1.1