aboutsummaryrefslogtreecommitdiff
path: root/build2/config
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2016-07-23 09:20:18 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2016-07-25 08:05:43 +0200
commita8bef4ff20100c518816c641ae1ff9783306c167 (patch)
treefcd6589100ca7ecb02e76c045880926f2b3e28d5 /build2/config
parentcb7168f9a7db37b5c733ed4ccb15e00037420388 (diff)
Fix surprising config override behavior now that they are amalgamation-wide
Diffstat (limited to 'build2/config')
-rw-r--r--build2/config/operation.cxx26
1 files changed, 24 insertions, 2 deletions
diff --git a/build2/config/operation.cxx b/build2/config/operation.cxx
index 6a83273..59d5349 100644
--- a/build2/config/operation.cxx
+++ b/build2/config/operation.cxx
@@ -64,7 +64,7 @@ namespace build2
}
static void
- save_config (scope& root)
+ save_config (scope& root, const set<scope*>& projects)
{
const dir_path& out_root (root.out_path ());
path f (out_root / config_file);
@@ -131,6 +131,12 @@ namespace build2
// will be dropped from the amalgamation's config.build. Let's
// also warn the user just in case.
//
+ // There is also another case that falls under this now that
+ // overrides are by default amalgamation-wide rather than just
+ // "project and subprojects": we may be (re-)configuring a
+ // subproject but the override is now set on the outer project's
+ // root.
+ //
bool found (false);
scope* r (&root);
while ((r = r->parent_scope ()->root_scope ()) != nullptr)
@@ -150,11 +156,27 @@ namespace build2
// Find the variable. For now we do linear search.
//
const saved_variables& sv (i->second);
+
found = find_if (
sv.begin (),
sv.end (),
[&var] (const saved_variable& v) {
return var == v.var;}) != sv.end ();
+
+ // Handle that other case: if this is an override but
+ // the outer project itself is not being configured,
+ // then we need to save this override.
+ //
+ // One problem with using the already configured project
+ // set is that the outer project may be configured only
+ // after us in which case both projects will save the
+ // value. But perhaps this is a feature, not a bug since
+ // this is how project-local (%) override behaves.
+ //
+ if (found &&
+ org.first != ovr.first &&
+ projects.find (r) == projects.end ())
+ found = false;
}
}
@@ -293,7 +315,7 @@ namespace build2
// Save config.build.
//
- save_config (root);
+ save_config (root, projects);
}
else
{