diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2019-03-13 13:43:54 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2019-03-13 13:52:32 +0200 |
commit | 355534c22ab547bceae189e11ce36fa0dea4e743 (patch) | |
tree | c93af55fb30dd13da13bbcadd3729ed386f6e824 /build2/scope.cxx | |
parent | e5d55e3245e148d675d4be607f1bfa944c4559e7 (diff) |
Cutoff append/prepend overrides that come before assignment override
For example:
$ b x+=1 x=2 x+=3
Should result in '2 3', not '1 2 3'.
Diffstat (limited to 'build2/scope.cxx')
-rw-r--r-- | build2/scope.cxx | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/build2/scope.cxx b/build2/scope.cxx index bae9818..69ab4b6 100644 --- a/build2/scope.cxx +++ b/build2/scope.cxx @@ -269,8 +269,8 @@ namespace build2 return true; }; - // Return the override value if it is present and (optionally) ends with - // a suffix. + // Return the override value if present in scope s and (optionally) ends + // with the specified suffix. // auto find = [&s, &var] (const variable* o, const char* sf = nullptr) -> lookup @@ -363,6 +363,7 @@ namespace build2 lookup stem; size_t stem_depth (0); const scope* stem_proj (nullptr); + const variable* stem_ovr (nullptr); // __override if found and applies. // Again the special case of a target/rule-specific variable. // @@ -413,6 +414,7 @@ namespace build2 stem = move (l); stem_depth = ovr_depth; stem_proj = s->root_scope (); + stem_ovr = o; done = true; break; } @@ -486,10 +488,23 @@ namespace build2 { ++ovr_depth; + // Skip any append/prepend overrides that appear before __override, + // provided it is from this scope. + // + bool skip (stem_ovr != nullptr && stem_depth == ovr_depth); + for (const variable* o (var.override.get ()); o != nullptr; o = o->override.get ()) { + if (skip) + { + if (stem_ovr == o) // Keep skipping until after we see __override. + skip = false; + + continue; + } + // First see if this override applies. This is tricky: what if the // stem is a "visible" override from an outer project? Shouldn't its // overrides apply? Sure sounds logical. So we use the project of the @@ -507,7 +522,7 @@ namespace build2 if (cl) { - // Note: if we have both, then the prefix is already in the stem. + // Note: if we have both, then one is already in the stem. // if (lp) // No sense to prepend/append if NULL. { |