From bdcd4211cf76bc75dd6f9a16fa3835632dfb7f20 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 20 Sep 2021 09:57:13 +0200 Subject: Assign pre-defined semantics to config..develop variables This variable allows a project to distinguish between development and consumption builds. While normally there is no distinction between these two modes, sometimes a project may need to provide additional functionality during development. For example, a source code generator which uses its own generated code in its implementation may need to provide a bootstrap step from the pre-generated code. Normally, such a step is only needed during development. See "Project Configuration" in the manual for details. --- libbuild2/config/operation.cxx | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) (limited to 'libbuild2/config/operation.cxx') diff --git a/libbuild2/config/operation.cxx b/libbuild2/config/operation.cxx index c62528f..5883d8c 100644 --- a/libbuild2/config/operation.cxx +++ b/libbuild2/config/operation.cxx @@ -221,17 +221,32 @@ namespace build2 if (size_t n = var->override ()) var = vp.find (string (var->name, 0, n)); + const string& name (var->name); + // Skip special variables. // - if (var->name == "config.booted" || - var->name == "config.loaded" || - var->name == "config.configured" || - var->name.compare (0, 14, "config.config.") == 0) + if (name == "config.booted" || + name == "config.loaded" || + name == "config.configured" || + name.compare (0, 14, "config.config.") == 0) continue; if (mod.find_variable (*var)) // Saved or unsaved. continue; + // Skip config.**.develop variables (see parser::parse_config() for + // details). + // + // In a sense, this variable is always "available" but if the + // package does not distinguish between development and consumption, + // then specifying config.*.develop=true should be noop. + // + { + size_t p (name.rfind ('.')); + if (p != 6 && name.compare (p + 1, string::npos, "develop") == 0) + continue; + } + const value& v (p.first->second); pair r (save_config_variable (*var, @@ -312,9 +327,13 @@ namespace build2 // inherited. We might also not have any value at all (see // unconfigured()). // + // Note that we must check for null() before attempting any + // further tests. + // if (!l.defined () || (l->null ? flags & save_null_omitted : - l->empty () ? flags & save_empty_omitted : false)) + l->empty () ? flags & save_empty_omitted : + (flags & save_false_omitted) != 0 && !cast (*l))) continue; // Handle inherited from outer scope values. -- cgit v1.1