diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2022-03-22 13:52:05 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2022-03-22 13:52:05 +0200 |
commit | 566554303848b3015c87a05d8e1cff097d613a08 (patch) | |
tree | ef53cab331287ca916bf25d81b02888c32ff34f2 | |
parent | 27db5f97c0f7460c2c0d2e28660c69cbc6d1207e (diff) |
Add ability to disfigure specific configuration variables
The new config.config.disfigure variable can be used to specify the list
of variables to ignore when loading config.build (and any files specified
in config.config.load), letting them to take on the default values. For
example:
$ b configure config.config.disfigure=config.hello.fancy
-rw-r--r-- | libbuild2/config/init.cxx | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/libbuild2/config/init.cxx b/libbuild2/config/init.cxx index 87b492c..e92db4c 100644 --- a/libbuild2/config/init.cxx +++ b/libbuild2/config/init.cxx @@ -247,6 +247,18 @@ namespace build2 auto& c_v (vp.insert<uint64_t> ("config.version", false /*ovr*/, v_p)); auto& c_l (vp.insert<paths> ("config.config.load", true /* ovr */)); + // Configuration variables to disfigure. + // + // The exact semantics is to ignore these variables when loading + // config.build (and any files specified in config.config.load), letting + // them to take on the default values (more precisely, the current + // implementation undefined them after loading config.build). + // + // Note that this variable is not saved in config.build and is expected + // to always be specified as a command line override. + // + auto& c_d (vp.insert<strings> ("config.config.disfigure", true /*ovr*/)); + // Hermetic configurations. // // A hermetic configuration stores environment variables that affect the @@ -424,6 +436,21 @@ namespace build2 } } + // Undefine variables specified with config.config.disfigure. + // + if (const strings* vs = cast_null<strings> (rs[c_d])) + { + for (const string& v: *vs) + { + // An unknown variable can't possibly be defined. + // + if (const variable* var = vp.find (v)) + { + rs.vars.erase (*var); // Undefine. + } + } + } + // Save and cache the config.config.persist value, if any. // if (m != nullptr) |