From dbb7a5ffefefa1e6439464cac47ebfd90a913aa7 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 8 Nov 2018 12:45:33 +0200 Subject: Fix bug in override logic for command line variable with project visibility --- build2/scope.cxx | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'build2/scope.cxx') diff --git a/build2/scope.cxx b/build2/scope.cxx index b9dabe8..49263d4 100644 --- a/build2/scope.cxx +++ b/build2/scope.cxx @@ -225,9 +225,9 @@ namespace build2 const scope* s; - // Return true if the override applies. Note that it expects vars and proj - // to be not NULL; if there is nothing "more inner", then any override - // will still be "visible". + // Return true if the override applies to a value from vars/proj. Note + // that it expects vars and proj to be not NULL; if there is nothing "more + // inner", then any override will still be "visible". // auto applies = [&s] (const variable* o, const variable_map* vars, @@ -246,9 +246,15 @@ namespace build2 } case variable_visibility::project: { - // Does not apply if in a different project. + // Does not apply if in a subproject. // - if (proj != s->root_scope ()) + // Note that before we used to require the same project but that + // missed values that are "visible" from the outer projects. + // + // If root scope is NULL, then we are looking at the global scope. + // + const scope* rs (s->root_scope ()); + if (rs != nullptr && rs->sub_root (*proj)) return false; break; -- cgit v1.1