aboutsummaryrefslogtreecommitdiff
path: root/build2/variable.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2017-02-10 14:26:16 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2017-02-13 12:42:42 +0200
commitdbd30777d1c60bdcdff226b5f97582dba0bba4ba (patch)
tree30b2beaf482201e11282eb884243f301678305b5 /build2/variable.cxx
parent92b98aee1eb9f9550634720b96eec0be1831ebb7 (diff)
Allow back overriding variables specified in buildfiles
It is still not clear whether this is the right thing to allow, conceptually, but with this disallowed it's hard to test this functionality. Perhaps we should have an attribute [overridable]. The problem is one will also have to set this variable to some value (e.g., [null]) which is not exactly the same as undefined (especially when testing).
Diffstat (limited to 'build2/variable.cxx')
-rw-r--r--build2/variable.cxx14
1 files changed, 10 insertions, 4 deletions
diff --git a/build2/variable.cxx b/build2/variable.cxx
index 78f7c04..48f3345 100644
--- a/build2/variable.cxx
+++ b/build2/variable.cxx
@@ -1003,7 +1003,14 @@ namespace build2
if (o == nullptr)
o = &*p.overridable;
else if (p.match)
- assert (*o == *p.overridable);
+ {
+ // Allow the pattern to restrict but not relax.
+ //
+ if (*o)
+ o = &*p.overridable;
+ else
+ assert (*o == *p.overridable);
+ }
}
}
@@ -1046,9 +1053,8 @@ namespace build2
{
if (t != nullptr || v != nullptr || o != nullptr)
update (r, t, v, o); // Not changing the key.
- else
- if (r.override != nullptr)
- fail << "variable " << r.name << " cannot be overridden";
+ else if (r.override != nullptr)
+ fail << "variable " << r.name << " cannot be overridden";
}
return r;