aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/install/rule.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2021-09-13 17:00:08 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2021-09-14 09:48:59 +0200
commitd552de5d028e1dfb108f343810604d0dfd74c2e6 (patch)
tree3ed1a320b0c3788001a1c61ff468f3392630f789 /libbuild2/install/rule.cxx
parentb9ea935ac2e31144db8ebdc2a98ebfc3f94357cc (diff)
Consistently install prerequisites from any scope by default
It is also now possible to adjust this behavior with global config.install.scope override. Valid values for this variable are: project -- only from project strong -- from strong amalgamation weak -- from weak amalgamation global -- from all projects (default)
Diffstat (limited to 'libbuild2/install/rule.cxx')
-rw-r--r--libbuild2/install/rule.cxx43
1 files changed, 29 insertions, 14 deletions
diff --git a/libbuild2/install/rule.cxx b/libbuild2/install/rule.cxx
index 388400a..5092d42 100644
--- a/libbuild2/install/rule.cxx
+++ b/libbuild2/install/rule.cxx
@@ -54,16 +54,19 @@ namespace build2
}
const target* alias_rule::
- filter (action a, const target& t, prerequisite_iterator& i) const
+ filter (const scope* is,
+ action a, const target& t, prerequisite_iterator& i) const
{
assert (i->member == nullptr);
- return filter (a, t, i->prerequisite);
+ return filter (is, a, t, i->prerequisite);
}
const target* alias_rule::
- filter (action, const target& t, const prerequisite& p) const
+ filter (const scope* is,
+ action, const target& t, const prerequisite& p) const
{
- return &search (t, p);
+ const target& pt (search (t, p));
+ return is == nullptr || pt.in (*is) ? &pt : nullptr;
}
recipe alias_rule::
@@ -75,8 +78,9 @@ namespace build2
//
// @@ Shouldn't we do match in parallel (here and below)?
//
- auto& pts (t.prerequisite_targets[a]);
+ optional<const scope*> is; // Installation scope (resolve lazily).
+ auto& pts (t.prerequisite_targets[a]);
auto pms (group_prerequisite_members (a, t, members_mode::never));
for (auto i (pms.begin ()), e (pms.end ()); i != e; ++i)
{
@@ -100,7 +104,10 @@ namespace build2
// Note: we assume that if the filter enters the group, then it
// iterates over all its members.
//
- const target* pt (filter (a, t, i));
+ if (!is)
+ is = install_scope (t);
+
+ const target* pt (filter (*is, a, t, i));
if (pt == nullptr)
{
l5 ([&]{trace << "ignoring " << p << " (filtered out)";});
@@ -217,7 +224,6 @@ namespace build2
if (gv.members != nullptr)
{
auto& pts (t.prerequisite_targets[a]);
-
for (size_t i (0); i != gv.count; ++i)
{
const target* m (gv.members[i]);
@@ -271,17 +277,19 @@ namespace build2
}
const target* file_rule::
- filter (action a, const target& t, prerequisite_iterator& i) const
+ filter (const scope* is,
+ action a, const target& t, prerequisite_iterator& i) const
{
assert (i->member == nullptr);
- return filter (a, t, i->prerequisite);
+ return filter (is, a, t, i->prerequisite);
}
const target* file_rule::
- filter (action, const target& t, const prerequisite& p) const
+ filter (const scope* is,
+ action, const target& t, const prerequisite& p) const
{
const target& pt (search (t, p));
- return pt.in (t.root_scope ()) ? &pt : nullptr;
+ return is == nullptr || pt.in (*is) ? &pt : nullptr;
}
recipe file_rule::
@@ -314,8 +322,9 @@ namespace build2
if (a.operation () == update_id)
unchanged = match_inner (a, t, unmatch::unchanged).first;
- auto& pts (t.prerequisite_targets[a]);
+ optional<const scope*> is; // Installation scope (resolve lazily).
+ auto& pts (t.prerequisite_targets[a]);
auto pms (group_prerequisite_members (a, t, members_mode::never));
for (auto i (pms.begin ()), e (pms.end ()); i != e; ++i)
{
@@ -339,7 +348,11 @@ namespace build2
// Note: we assume that if the filter enters the group, then it
// iterates over all its members.
//
- const target* pt (filter (a, t, i));
+ if (!is)
+ is = install_scope (t);
+
+ const target* pt (filter (*is, a, t, i));
+
if (pt == nullptr)
{
l5 ([&]{trace << "ignoring " << p << " (filtered out)";});
@@ -541,7 +554,9 @@ namespace build2
{
if (fail_unknown)
fail << "unknown installation directory name '" << sn << "'" <<
- info << "did you forget to specify config." << var << "?";
+ info << "did you forget to specify config." << var << "?" <<
+ info << "specify !config." << var << "=... if installing "
+ << "from multiple projects";
return rs; // Empty.
}