From 8ac1daf33da807635eddd881f2b178af8e22863a Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 12 Nov 2019 14:51:02 +0200 Subject: Infra work for customizable config var persistence (config.config.persist) --- libbuild2/config/init.cxx | 35 ++++++++++++++++++++++++++++------- 1 file changed, 28 insertions(+), 7 deletions(-) (limited to 'libbuild2/config/init.cxx') 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 ("config.config.save", true /* ovr */); + vp.insert ("config.config.save", true /* ovr */); + + // @@ TODO + // + // Use the NULL value to clear. + // + auto& c_p (vp.insert>> ( + "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 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&, + unique_ptr& 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 (*mod).persist = + cast_null>> ( + 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., -- cgit v1.1