diff options
Diffstat (limited to 'libbuild2/bash/rule.cxx')
-rw-r--r-- | libbuild2/bash/rule.cxx | 34 |
1 files changed, 22 insertions, 12 deletions
diff --git a/libbuild2/bash/rule.cxx b/libbuild2/bash/rule.cxx index 55f3cf0..6e96b34 100644 --- a/libbuild2/bash/rule.cxx +++ b/libbuild2/bash/rule.cxx @@ -63,16 +63,18 @@ namespace build2 // in_rule // bool in_rule:: - match (action a, target& t) const + match (action a, target& xt, const string& hint, match_extra&) const { tracer trace ("bash::in_rule::match"); - // Note that for bash{} we match even if the target does not depend on - // any modules (while it could have been handled by the in module, that - // would require loading it). + file& t (xt.as<file> ()); // Only registered for exe{} and bash{}. + + // Note that for bash{} and for exe{} with hint we match even if the + // target does not depend on any modules (while it could have been + // handled by the in module, that would require loading it). // - bool fi (false); // Found in. - bool fm (t.is_a<bash> ()); // Found module. + bool fi (false); // Found in. + bool fm (!hint.empty () || t.is_a<bash> ()); // Found module. for (prerequisite_member p: group_prerequisite_members (a, t)) { if (include (a, t, p) != include_type::normal) // Excluded/ad hoc. @@ -86,7 +88,14 @@ namespace build2 l4 ([&]{trace << "no in file prerequisite for target " << t;}); if (!fm) - l4 ([&]{trace << "no bash module prerequisite for target " << t;}); + l4 ([&]{trace << "no bash module prerequisite or hint for target " + << t;}); + + // If we match, derive the file name early as recommended by the in + // rule. + // + if (fi && fm) + t.derive_path (); return fi && fm; } @@ -213,13 +222,14 @@ namespace build2 const string& n, optional<uint64_t> flags, bool strict, + const substitution_map* smap, const optional<string>& null) const { assert (!flags); return n.compare (0, 6, "import") == 0 && (n[6] == ' ' || n[6] == '\t') ? substitute_import (l, a, t, trim (string (n, 7))) - : rule::substitute (l, a, t, n, nullopt, strict, null); + : rule::substitute (l, a, t, n, nullopt, strict, smap, null); } string in_rule:: @@ -404,7 +414,7 @@ namespace build2 "source \"$(dirname" " \"$(readlink -f" " \"${BASH_SOURCE[0]}\")\")/" - + iip.string () + "\""; + + iip.string () + '"'; } else { @@ -425,7 +435,7 @@ namespace build2 return "source \"$(dirname" " \"${BASH_SOURCE[0]}\")/" - + o + iip.string () + "\""; + + o + iip.string () + '"'; } } else @@ -445,9 +455,9 @@ namespace build2 } recipe install_rule:: - apply (action a, target& t) const + apply (action a, target& t, match_extra& me) const { - recipe r (file_rule::apply_impl (a, t)); + recipe r (file_rule::apply_impl (a, t, me)); if (r == nullptr) return noop_recipe; |