aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/config/init.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2019-11-12 14:51:02 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2019-11-12 14:51:02 +0200
commit8ac1daf33da807635eddd881f2b178af8e22863a (patch)
tree3a3e91538f4665b0d721bc91d935eb01a5a3b61d /libbuild2/config/init.cxx
parent8725010c51811c7ff91013e2caca3c45ea96b371 (diff)
Infra work for customizable config var persistence (config.config.persist)
Diffstat (limited to 'libbuild2/config/init.cxx')
-rw-r--r--libbuild2/config/init.cxx35
1 files changed, 28 insertions, 7 deletions
diff --git a/libbuild2/config/init.cxx b/libbuild2/config/init.cxx
index 9fc914c..1f053e9 100644
--- a/libbuild2/config/init.cxx
+++ b/libbuild2/config/init.cxx
@@ -47,14 +47,23 @@ namespace build2
//
auto& vp (rs.ctx.var_pool.rw (rs));
- // While config.config.load could theoretically be specified in a
- // buildfile, config.config.save is expected to always be specified as a
- // command line override.
+ // While config.config.load (see below) could theoretically be specified
+ // in a buildfile, config.config.save is expected to always be specified
+ // as a command line override.
//
// Note: must be entered during bootstrap since we need it in
// configure_execute().
//
- vp.insert<path> ("config.config.save", true /* ovr */);
+ vp.insert<path> ("config.config.save", true /* ovr */);
+
+ // @@ TODO
+ //
+ // Use the NULL value to clear.
+ //
+ auto& c_p (vp.insert<vector<pair<string, string>>> (
+ "config.config.persist",
+ true /* ovr */,
+ variable_visibility::project));
// Only create the module if we are configuring or creating or if it was
// requested with config.config.module (useful if we need to call
@@ -78,11 +87,14 @@ namespace build2
unique_ptr<module> m (new module);
- // Adjust priority for the import pseudo-module so that
- // config.import.* values come first in config.build.
+ // Adjust priority for the config module and import pseudo-module so
+ // that their variables come first in config.build.
//
+ m->save_module ("config", INT32_MIN);
m->save_module ("import", INT32_MIN);
+ m->save_variable (c_p, omit_null);
+
mod = move (m);
}
@@ -109,7 +121,7 @@ namespace build2
init (scope& rs,
scope&,
const location& l,
- unique_ptr<module_base>&,
+ unique_ptr<module_base>& mod,
bool first,
bool,
const variable_map& config_hints)
@@ -224,6 +236,15 @@ namespace build2
}
}
+ // Cache the config.config.persist value, if any.
+ //
+ if (mod != nullptr)
+ {
+ static_cast<module&> (*mod).persist =
+ cast_null<vector<pair<string, string>>> (
+ rs["config.config.persist"]);
+ }
+
// Register alias and fallback rule for the configure meta-operation.
//
// We need this rule for out-of-any-project dependencies (e.g.,