diff options
-rw-r--r-- | build2/bash/rule.cxx | 15 | ||||
-rw-r--r-- | build2/bash/rule.hxx | 11 | ||||
-rw-r--r-- | build2/cc/install-rule.hxx | 2 | ||||
-rw-r--r-- | build2/install/rule.hxx | 8 |
4 files changed, 31 insertions, 5 deletions
diff --git a/build2/bash/rule.cxx b/build2/bash/rule.cxx index 4266c89..d12e743 100644 --- a/build2/bash/rule.cxx +++ b/build2/bash/rule.cxx @@ -422,5 +422,20 @@ namespace build2 return r; } + + const target* install_rule:: + filter (action a, const target& t, const prerequisite& p) const + { + // If this is a module prerequisite, install it as long as it is in the + // same amalgamation as we are. + // + if (p.is_a<bash> ()) + { + const target& pt (search (t, p)); + return pt.in (t.weak_scope ()) ? &pt : nullptr; + } + else + return file_rule::filter (a, t, p); + } } } diff --git a/build2/bash/rule.hxx b/build2/bash/rule.hxx index 9957970..5110f97 100644 --- a/build2/bash/rule.hxx +++ b/build2/bash/rule.hxx @@ -58,8 +58,12 @@ namespace build2 const string&) const; }; - // Installation rule for bash scripts (exe{}) and modules (bash{}) that - // signals to in_rule that this is update for install. + // Installation rule for bash scripts (exe{}) and modules (bash{}). Here + // we do: + // + // 1. Signal to in_rule that this is update for install. + // + // 2. Custom filtering of prerequisites. // class install_rule: public install::file_rule { @@ -72,6 +76,9 @@ namespace build2 virtual recipe apply (action, target&) const override; + virtual const target* + filter (action, const target&, const prerequisite&) const override; + private: const in_rule& in_; }; diff --git a/build2/cc/install-rule.hxx b/build2/cc/install-rule.hxx index db098d4..25d2d08 100644 --- a/build2/cc/install-rule.hxx +++ b/build2/cc/install-rule.hxx @@ -23,7 +23,7 @@ namespace build2 // // 1. Signal to the link rule that this is update for install. // - // 2. Additional filtering of prerequisites (e.g., headers of an exe{}). + // 2. Custom filtering of prerequisites (e.g., headers of an exe{}). // // 3. Extra un/installation (e.g., libs{} symlinks). // diff --git a/build2/install/rule.hxx b/build2/install/rule.hxx index 20b30a1..1ce2830 100644 --- a/build2/install/rule.hxx +++ b/build2/install/rule.hxx @@ -27,7 +27,7 @@ namespace build2 // target otherwise. The default implementation accepts all prerequsites // from the target's (weak) amalgamation. // - // The prerequisite it passed as an iterator allowing the filter to + // The prerequisite is passed as an iterator allowing the filter to // "see" inside groups. // using prerequisite_iterator = @@ -105,7 +105,11 @@ namespace build2 // target otherwise. The default implementation ignores prerequsites // that are outside of this target's project. // - // The prerequisite it passed as an iterator allowing the filter to + // @@ 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... + // + // The prerequisite is passed as an iterator allowing the filter to // "see" inside groups. // using prerequisite_iterator = |