aboutsummaryrefslogtreecommitdiff
path: root/build2/scope.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2019-03-14 17:19:01 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2019-03-14 17:19:01 +0200
commitd1b3ad7b302d037c8154bab9c4810d499c0bf1e4 (patch)
tree8c6ce63cb0a71bc670c3c5d46c2c1a06366956ad /build2/scope.cxx
parent8d8d7784d5fe0dc3cd8d7fbd4196c2337d389fd1 (diff)
Change variable::override list order, make doubly-linked
Diffstat (limited to 'build2/scope.cxx')
-rw-r--r--build2/scope.cxx15
1 files changed, 11 insertions, 4 deletions
diff --git a/build2/scope.cxx b/build2/scope.cxx
index 69ab4b6..4dd475d 100644
--- a/build2/scope.cxx
+++ b/build2/scope.cxx
@@ -397,6 +397,9 @@ namespace build2
// Then look for an __override that applies.
//
+ // Note that the override list is in the reverse order of appearance and
+ // so we will naturally see the most recent override first.
+ //
for (const variable* o (var.override.get ());
o != nullptr;
o = o->override.get ())
@@ -488,14 +491,18 @@ namespace build2
{
++ovr_depth;
- // Skip any append/prepend overrides that appear before __override,
- // provided it is from this scope.
+ // The override list is in the reverse order of appearance so we need to
+ // iterate backwards in order to apply things in the correct order.
+ //
+ // We also need to skip any append/prepend overrides that appear before
+ // __override (in the command line order), provided it is from this
+ // scope.
//
bool skip (stem_ovr != nullptr && stem_depth == ovr_depth);
- for (const variable* o (var.override.get ());
+ for (const variable* o (var.override->alias); // Last override.
o != nullptr;
- o = o->override.get ())
+ o = (o->alias != var.override->alias ? o->alias : nullptr))
{
if (skip)
{