From 758a50eb1825f2e0c1acd5c61d36bb5b866585b8 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 8 Jun 2020 09:18:11 +0200 Subject: Adjust rule_match name for ad hoc recipes --- libbuild2/rule.cxx | 5 ++++- libbuild2/rule.hxx | 12 +++++++++--- libbuild2/target.hxx | 2 +- 3 files changed, 14 insertions(+), 5 deletions(-) (limited to 'libbuild2') diff --git a/libbuild2/rule.cxx b/libbuild2/rule.cxx index f257b62..0df6517 100644 --- a/libbuild2/rule.cxx +++ b/libbuild2/rule.cxx @@ -894,7 +894,10 @@ namespace build2 // adhoc_cxx_rule:: adhoc_cxx_rule (const location& l, size_t b, uint64_t v, optional s) - : adhoc_rule (l, b), version (v), separator (move (s)), impl (nullptr) + : adhoc_rule ("", l, b), + version (v), + separator (move (s)), + impl (nullptr) { if (v != 1) fail (l) << "unsupported c++ recipe version " << v; diff --git a/libbuild2/rule.hxx b/libbuild2/rule.hxx index aa2f003..f3581c8 100644 --- a/libbuild2/rule.hxx +++ b/libbuild2/rule.hxx @@ -124,10 +124,10 @@ namespace build2 location_value loc; // Buildfile location of the recipe. size_t braces; // Number of braces in multi-brace tokens. - adhoc_rule (const location& l, size_t b) + adhoc_rule (const char* name, const location& l, size_t b) : loc (l), braces (b), - rule_match ("adhoc", static_cast (*this)) {} + rule_match (name, static_cast (*this)) {} // Set the rule text, handle any recipe-specific attributes, and return // true if the recipe builds anything in the build/recipes/ directory and @@ -164,6 +164,11 @@ namespace build2 // Implementation details. // public: + // The name in rule_match is used as a hint and as a name in diagnostics. + // The former does not apply to us (but will apply to ad hoc rules) while + // latter does. As a result, we use special-looking "" + // names. + // build2::rule_match rule_match; static const dir_path recipes_build_dir; @@ -193,7 +198,8 @@ namespace build2 target_state default_action (action, const target&) const; - adhoc_script_rule (const location& l, size_t b): adhoc_rule (l, b) {} + adhoc_script_rule (const location& l, size_t b) + : adhoc_rule ("", l, b) {} virtual bool recipe_text (context&, const target&, string&&, attributes&) override; diff --git a/libbuild2/target.hxx b/libbuild2/target.hxx index 667ef79..26bb135 100644 --- a/libbuild2/target.hxx +++ b/libbuild2/target.hxx @@ -195,7 +195,7 @@ namespace build2 // would be much easier and more consistent to make these extra files // proper targets. // - // So to support this requirement we have "ad hoc" groups. The idea is + // So to support this requirement we have ad hoc groups. The idea is // that any target can be turned either by a user's declaration in a // buildfile or by the rule that matches it into an ad hoc group by // chaining several targets together. -- cgit v1.1