From 566554303848b3015c87a05d8e1cff097d613a08 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 22 Mar 2022 13:52:05 +0200 Subject: 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 --- libbuild2/config/init.cxx | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'libbuild2') 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 ("config.version", false /*ovr*/, v_p)); auto& c_l (vp.insert ("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 ("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 (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) -- cgit v1.1