aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/adhoc-rule-buildscript.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'libbuild2/adhoc-rule-buildscript.cxx')
-rw-r--r--libbuild2/adhoc-rule-buildscript.cxx27
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
{