aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/install
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2021-09-13 17:00:08 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2021-09-13 17:00:08 +0200
commit2958f39350a067795e4e13080f78b9df394b298c (patch)
tree8fb9f84102a27354ad4a72a6d99d6f502f142efd /libbuild2/install
parentb9ea935ac2e31144db8ebdc2a98ebfc3f94357cc (diff)
Consistently install prerequisites from any scope by defaultinstall-scope
Diffstat (limited to 'libbuild2/install')
-rw-r--r--libbuild2/install/rule.cxx39
-rw-r--r--libbuild2/install/rule.hxx21
-rw-r--r--libbuild2/install/utility.hxx10
3 files changed, 47 insertions, 23 deletions
diff --git a/libbuild2/install/rule.cxx b/libbuild2/install/rule.cxx
index 388400a..9f8fbf7 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)";});
diff --git a/libbuild2/install/rule.hxx b/libbuild2/install/rule.hxx
index 73f2486..ce60bb9 100644
--- a/libbuild2/install/rule.hxx
+++ b/libbuild2/install/rule.hxx
@@ -25,7 +25,9 @@ namespace build2
match (action, target&, const string&) const override;
// Return NULL if this prerequisite should be ignored and pointer to its
- // target otherwise. The default implementation allows all prerequsites.
+ // target otherwise. The default implementation ignores prerequsites
+ // that are outside of the installation scope (see install_scope() for
+ // details).
//
// The prerequisite is passed as an iterator allowing the filter to
// "see" inside groups.
@@ -34,10 +36,11 @@ namespace build2
prerequisite_members_range<group_prerequisites>::iterator;
virtual const target*
- filter (action, const target&, prerequisite_iterator&) const;
+ filter (const scope*,
+ action, const target&, prerequisite_iterator&) const;
virtual const target*
- filter (action, const target&, const prerequisite&) const;
+ filter (const scope*, action, const target&, const prerequisite&) const;
virtual recipe
apply (action, target&) const override;
@@ -103,11 +106,8 @@ namespace build2
// Return NULL if this prerequisite should be ignored and pointer to its
// target otherwise. The default implementation ignores prerequsites
- // that are outside of this target's project.
- //
- // @@ I wonder why we do weak amalgamation for alias but project for
- // file? And then override this for prerequisite libraries/modules
- // in cc::install_rule and bash::install_rule...
+ // that are outside of the installation scope (see install_scope() for
+ // details).
//
// The prerequisite is passed as an iterator allowing the filter to
// "see" inside groups.
@@ -116,10 +116,11 @@ namespace build2
prerequisite_members_range<group_prerequisites>::iterator;
virtual const target*
- filter (action, const target&, prerequisite_iterator&) const;
+ filter (const scope*,
+ action, const target&, prerequisite_iterator&) const;
virtual const target*
- filter (action, const target&, const prerequisite&) const;
+ filter (const scope*, action, const target&, const prerequisite&) const;
virtual recipe
apply (action, target&) const override;
diff --git a/libbuild2/install/utility.hxx b/libbuild2/install/utility.hxx
index 2c0ca56..0104a1c 100644
--- a/libbuild2/install/utility.hxx
+++ b/libbuild2/install/utility.hxx
@@ -56,6 +56,16 @@ namespace build2
return install_mode (s, T::static_type, move (m));
}
+ // Return the "installation scope". We do not install prerequisites (for
+ // example, shared libraries) of targets (for example, executables) that
+ // are outside of this scope. If it's NULL, install all prerequisites.
+ //
+ inline const scope*
+ install_scope (const target&)
+ {
+ return nullptr;
+ }
+
// Resolve relative installation directory path (e.g., include/libfoo) to
// its absolute directory path (e.g., /usr/include/libfoo). If the
// resolution encountered an unknown directory, issue diagnostics and fail