aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libbuild2/adhoc-rule-regex-pattern.hxx4
-rw-r--r--libbuild2/rule.hxx3
-rw-r--r--tests/recipe/cxx/testscript13
3 files changed, 13 insertions, 7 deletions
diff --git a/libbuild2/adhoc-rule-regex-pattern.hxx b/libbuild2/adhoc-rule-regex-pattern.hxx
index ed8bf59..4327e72 100644
--- a/libbuild2/adhoc-rule-regex-pattern.hxx
+++ b/libbuild2/adhoc-rule-regex-pattern.hxx
@@ -14,6 +14,10 @@ namespace build2
{
// Ad hoc rule regex pattern.
//
+ // The name signature is stored in match_extra::buffer while the regex
+ // match_results object -- in the target auxiliary data storage. Both must
+ // remain valid until after the apply_*() calls.
+ //
// Note: exported since may be accessed by ad hoc recipe implementation.
//
class LIBBUILD2_SYMEXPORT adhoc_rule_regex_pattern: public adhoc_rule_pattern
diff --git a/libbuild2/rule.hxx b/libbuild2/rule.hxx
index e46c402..ad6b51c 100644
--- a/libbuild2/rule.hxx
+++ b/libbuild2/rule.hxx
@@ -146,7 +146,8 @@ namespace build2
// Used for both ad hoc pattern rules and ad hoc recipes. For recipes, it's
// essentially a rule of one case. Note that when used as part of a pattern,
// the implementation cannot use the match_extra::buffer nor the target
- // auxilary data storage.
+ // auxiliary data storage until the pattern's apply_*() calls have been
+ // made.
//
// Note: not exported.
//
diff --git a/tests/recipe/cxx/testscript b/tests/recipe/cxx/testscript
index 9a87c24..c94148e 100644
--- a/tests/recipe/cxx/testscript
+++ b/tests/recipe/cxx/testscript
@@ -180,19 +180,20 @@ if (!$static && $test.target == $build.host)
--
recipe
- apply (action, target&) const override
+ apply (action, target& t) const override
{
- return [this] (action a, const target& t)
+ const auto& mrs (t.data<regex_match_results> ());
+
+ return [this, mr = mrs.str (1)] (action a, const target& t)
{
- return perform_update (a, t);
+ return perform_update (a, t, mr);
};
}
target_state
- perform_update (action, const target& t) const
+ perform_update (action, const target&, const string& mr) const
{
- const auto& mr (t.data<regex_match_results> ());
- text << pattern->rule_name << ": " << mr.str (1);
+ text << pattern->rule_name << ": " << mr;
return target_state::changed;
}
}}