aboutsummaryrefslogtreecommitdiff
path: root/build2/b.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2016-07-22 09:23:55 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2016-07-22 09:23:55 +0200
commit4c3e451a852b537c04f5b73af23639902117b94f (patch)
tree951c165070ebf531580dcecef85976dc194e735d /build2/b.cxx
parentc1d08dbc56d0c8d3346deaba5d6b1946b6d711f4 (diff)
Change default var override from 'projects and subprojects' to amalgamation
The 'projects and subprojects' semantics resulted in some counter-intuitive behavior. For example, in a project with tests/ as a subproject if one builds one of the tests directly with a non-global override (say C++ compiler), then the main project would be built without the overrides. I this light, overriding in the whole amalgamation seems like the right thing to do. The old behavior can still be obtained with scope qualification, for example: b ./:foo=bar
Diffstat (limited to 'build2/b.cxx')
-rw-r--r--build2/b.cxx36
1 files changed, 33 insertions, 3 deletions
diff --git a/build2/b.cxx b/build2/b.cxx
index 3cd8793..d16c0c6 100644
--- a/build2/b.cxx
+++ b/build2/b.cxx
@@ -790,14 +790,44 @@ main (int argc, char* argv[])
// second sitution so if it is already set, then it can only be the
// first case.
//
- bool first (true);
+ // This is further complicated by the project vs amalgamation logic
+ // (we may have already done the amalgamation but not the project).
+ //
+ bool first_a (true);
for (const variable_override& o: var_ovs)
{
+ if (o.ovr.visibility != variable_visibility::normal)
+ continue;
+
+ auto p (rs.weak_scope ()->vars.insert (o.ovr));
+
+ if (!p.second)
+ {
+ if (first_a)
+ break;
+
+ fail << "multiple amalgamation overrides of variable "
+ << o.var.name;
+ }
+
+ value& v (p.first);
+ v = o.val;
+ first_a = false;
+ }
+
+ bool first_p (true);
+ for (const variable_override& o: var_ovs)
+ {
+ // Ours is either project (%foo) or scope (/foo).
+ //
+ if (o.ovr.visibility == variable_visibility::normal)
+ continue;
+
auto p (rs.vars.insert (o.ovr));
if (!p.second)
{
- if (first)
+ if (first_p)
break;
fail << "multiple project overrides of variable " << o.var.name;
@@ -805,7 +835,7 @@ main (int argc, char* argv[])
value& v (p.first);
v = o.val;
- first = false;
+ first_p = false;
}
ts.root_scope = &rs;