aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/config
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2022-05-19 12:39:35 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2022-05-19 12:39:35 +0200
commit5139b4e0f76076f3fb40b30e99a461fe0947d73e (patch)
treef67b0911da2fe068bb0976d00da3421a637c5c59 /libbuild2/config
parent84b88448b3e71855d9a788696276c11c5cc5d005 (diff)
Add config.config.unload variable to omit loading config.build
Note that the configuration is still loaded from config.config.load if specified. Note also that similar to config.config.load, only values specified on this project's root scope and global scope are considered.
Diffstat (limited to 'libbuild2/config')
-rw-r--r--libbuild2/config/init.cxx41
1 files changed, 34 insertions, 7 deletions
diff --git a/libbuild2/config/init.cxx b/libbuild2/config/init.cxx
index 774ffb8..73c9d37 100644
--- a/libbuild2/config/init.cxx
+++ b/libbuild2/config/init.cxx
@@ -243,12 +243,23 @@ 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 */));
+ // Omit loading the configuration from the config.build file (it is
+ // still loaded from config.config.load if specified). Similar to
+ // config.config.load, only values specified on this project's root
+ // scope and global scope are considered.
+ //
+ // Note that this variable is not saved in config.build and is expected
+ // to always be specified as a command line override.
+ //
+ auto& c_u (vp.insert<bool> ("config.config.unload", 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).
+ // implementation undefined them after loading config.build). See also
+ // config.config.unload.
//
// Note that this variable is not saved in config.build and is expected
// to always be specified as a command line override.
@@ -352,9 +363,10 @@ namespace build2
save_null_omitted | save_empty_omitted | save_base,
&save_environment);
- // Load config.build if one exists followed by extra files specified in
- // config.config.load (we don't need to worry about disfigure since we
- // will never be init'ed).
+ // Load config.build if one exists (and unless config.config.unload is
+ // specified) followed by extra files specified in config.config.load
+ // (we don't need to worry about disfigure since we will never be
+ // init'ed).
//
auto load_config = [&rs, &c_v] (istream& is,
const path_name& in,
@@ -403,11 +415,26 @@ namespace build2
load_config (open_file_or_stdin (fn, ifs), fn, l);
};
+ // Load config.build unless requested not to.
+ //
{
- path f (config_file (rs));
+ // The same semantics as in config.config.load below.
+ //
+ bool u;
+ {
+ lookup l (rs[c_u]);
+ u = (l &&
+ (l.belongs (rs) || l.belongs (ctx.global_scope)) &&
+ cast_false<bool> (l));
+ }
- if (exists (f))
- load_config_file (f, l);
+ if (!u)
+ {
+ path f (config_file (rs));
+
+ if (exists (f))
+ load_config_file (f, l);
+ }
}
if (lookup l = rs[c_l])