From be34c36f7b9ab7d2fd0d3a7bc2a0f5f62ff4fe67 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 27 Aug 2019 14:43:37 +0200 Subject: Propagate global var overrides to module build context --- libbuild2/context.cxx | 7 +++++++ libbuild2/context.hxx | 1 + libbuild2/module.cxx | 12 ++++++------ 3 files changed, 14 insertions(+), 6 deletions(-) (limited to 'libbuild2') 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> (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. -- cgit v1.1