diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2021-08-04 06:45:02 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2021-08-04 06:45:02 +0200 |
commit | ea57c514dc169afb3ece21ff2e4c1d2ab0c47d6a (patch) | |
tree | e71ca9c5adf25aabb7ddb6a5e887415ecbfb36c0 /libbuild2/adhoc-rule-buildscript.cxx | |
parent | e767684a3462059852f7067a2297b1e18fdb3137 (diff) |
Take into account file-base'ness in ad hoc buildscript recipes
Diffstat (limited to 'libbuild2/adhoc-rule-buildscript.cxx')
-rw-r--r-- | libbuild2/adhoc-rule-buildscript.cxx | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/libbuild2/adhoc-rule-buildscript.cxx b/libbuild2/adhoc-rule-buildscript.cxx index c715ff2..61b4cb2 100644 --- a/libbuild2/adhoc-rule-buildscript.cxx +++ b/libbuild2/adhoc-rule-buildscript.cxx @@ -23,7 +23,10 @@ using namespace std; namespace build2 { bool adhoc_buildscript_rule:: - recipe_text (const scope& s, string&& t, attributes& as) + recipe_text (const scope& s, + const target_type& tt, + string&& t, + attributes& as) { // Handle and erase recipe-specific attributes. // @@ -52,11 +55,12 @@ namespace build2 } checksum = sha256 (t).string (); + ttype = &tt; istringstream is (move (t)); build::script::parser p (s.ctx); - script = p.pre_parse (s, actions, + script = p.pre_parse (s, tt, actions, is, loc.file, loc.line + 1, move (diag), as.loc); @@ -109,6 +113,25 @@ namespace build2 perform_update_id) != actions.end (); } + bool adhoc_buildscript_rule:: + match (action a, target& t, const string& h, match_extra& me) const + { + // We pre-parsed the script with the assumption it will be used on a + // non/file-based target. Note that this should not be possible with + // patterns. + // + if (pattern == nullptr) + { + if ((t.is_a<file> () != nullptr) != ttype->is_a<file> ()) + { + fail (loc) << "incompatible target types used with shared recipe" << + info << "all targets must be file-based or non-file-based"; + } + } + + return adhoc_rule::match (a, t, h, me); + } + recipe adhoc_buildscript_rule:: apply (action a, target& t, match_extra& me) const { |