From a778f312902ad5036bc940ac63169f0b48e1f556 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 23 Oct 2023 11:24:13 +0200 Subject: WIP: forward reapply() call to C++ ad hoc rule/recipe --- libbuild2/adhoc-rule-buildscript.cxx | 4 +++- libbuild2/adhoc-rule-cxx.cxx | 12 +++++++++++- libbuild2/adhoc-rule-cxx.hxx | 3 +++ libbuild2/algorithm.cxx | 7 +++++-- 4 files changed, 22 insertions(+), 4 deletions(-) diff --git a/libbuild2/adhoc-rule-buildscript.cxx b/libbuild2/adhoc-rule-buildscript.cxx index 3c42e66..0263ddd 100644 --- a/libbuild2/adhoc-rule-buildscript.cxx +++ b/libbuild2/adhoc-rule-buildscript.cxx @@ -301,7 +301,9 @@ namespace build2 // if (const group* g = t.group != nullptr ? t.group->is_a () : nullptr) { - match_sync (a, *g); + // Note: this looks very similar to how we handle ad hoc group members. + // + match_sync (a, *g, 0 /* options */); return group_recipe; // Execute the group's recipe. } diff --git a/libbuild2/adhoc-rule-cxx.cxx b/libbuild2/adhoc-rule-cxx.cxx index e3dfe92..637f9af 100644 --- a/libbuild2/adhoc-rule-cxx.cxx +++ b/libbuild2/adhoc-rule-cxx.cxx @@ -691,10 +691,20 @@ namespace build2 ? t.group->is_a () : nullptr)) { - match_sync (a, *g); + // @@ Hm, this looks very similar to how we handle ad hoc group members. + // Shouldn't impl be given a chance to translate options or some + // such? + // + match_sync (a, *g, 0 /* options */); return group_recipe; // Execute the group's recipe. } return impl.load (memory_order_relaxed)->apply (a, t, me); } + + void adhoc_cxx_rule:: + reapply (action a, target& t, match_extra& me) const + { + return impl.load (memory_order_relaxed)->reapply (a, t, me); + } } diff --git a/libbuild2/adhoc-rule-cxx.hxx b/libbuild2/adhoc-rule-cxx.hxx index b563881..89bc05f 100644 --- a/libbuild2/adhoc-rule-cxx.hxx +++ b/libbuild2/adhoc-rule-cxx.hxx @@ -70,6 +70,9 @@ namespace build2 virtual recipe apply (action, target&, match_extra&) const override; + virtual void + reapply (action, target&, match_extra&) const override; + adhoc_cxx_rule (string, const location&, size_t, uint64_t ver, optional sep); diff --git a/libbuild2/algorithm.cxx b/libbuild2/algorithm.cxx index b34c175..0c90642 100644 --- a/libbuild2/algorithm.cxx +++ b/libbuild2/algorithm.cxx @@ -591,7 +591,7 @@ namespace build2 const rule_match* r (g->state[a].rule); assert (r != nullptr); // Shouldn't happen with dyn_members. - me.new_options = options; // Currently unused but maybe in future. + me.new_options = options; return r; } @@ -622,7 +622,7 @@ namespace build2 true /* try_match */, &gme)) { - me.new_options = options; // Currently unused but maybe in future. + me.new_options = options; return r; } @@ -1129,6 +1129,9 @@ namespace build2 // 4. Continue matching the group passing the translated options. // 5. Keep track of member options in member's cur_options to handle // member rematches (if already offset_{applied,executed}). + // + // Note: see also similar semantics but for explicit groups in + // adhoc-rule-*.cxx. assert (!step && options == match_extra::all_options); -- cgit v1.1