aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libbuild2/context.cxx7
-rw-r--r--libbuild2/context.hxx1
-rw-r--r--libbuild2/module.cxx12
3 files changed, 14 insertions, 6 deletions
diff --git a/libbuild2/context.cxx b/libbuild2/context.cxx
index 1cf7c7d..f310426 100644
--- a/libbuild2/context.cxx
+++ b/libbuild2/context.cxx
@@ -49,6 +49,7 @@ namespace build2
target_type_map global_target_types;
variable_override_cache global_override_cache;
+ strings global_var_overrides;
data (context& c): scopes (c), targets (c), var_pool (&c /* global */) {}
};
@@ -72,6 +73,7 @@ namespace build2
global_scope (create_global_scope (data_->scopes)),
global_target_types (data_->global_target_types),
global_override_cache (data_->global_override_cache),
+ global_var_overrides (data_->global_var_overrides),
module_context (mc ? *mc : nullptr),
module_context_storage (mc
? optional<unique_ptr<context>> (nullptr)
@@ -455,6 +457,11 @@ namespace build2
else
data_->var_overrides.push_back (
variable_override {var, *o, move (dir), move (r.first)});
+
+ // Save global overrides for nested contexts.
+ //
+ if (c == '!')
+ data_->global_var_overrides.push_back (s);
}
// Enter builtin variables and patterns.
diff --git a/libbuild2/context.hxx b/libbuild2/context.hxx
index b5dbd3c..c2c191e 100644
--- a/libbuild2/context.hxx
+++ b/libbuild2/context.hxx
@@ -290,6 +290,7 @@ namespace build2
const scope& global_scope;
const target_type_map& global_target_types;
variable_override_cache& global_override_cache;
+ const strings& global_var_overrides;
// Cached variables.
//
diff --git a/libbuild2/module.cxx b/libbuild2/module.cxx
index 63ff24c..9f951c3 100644
--- a/libbuild2/module.cxx
+++ b/libbuild2/module.cxx
@@ -146,16 +146,16 @@ namespace build2
assert (*ctx.module_context_storage == nullptr);
- // Since we are using the same scheduler, it makes sense to reuse
- // the same mutex shards. Also disable nested module context for
- // good measure.
+ // Since we are using the same scheduler, it makes sense to reuse the
+ // same mutex shards. Also disable nested module context for good
+ // measure.
//
ctx.module_context_storage->reset (
new context (ctx.sched,
- false, /* dry_run */
+ false, /* dry_run */
ctx.keep_going,
- {}, /* cmd_vars */
- nullopt)); /* module_context */
+ ctx.global_var_overrides, /* cmd_vars */
+ nullopt)); /* module_context */
// We use the same context for building any nested modules that
// might be required while building modules.