From 23b059eea0618220010b30bacbf97db7f642c870 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 16 Nov 2023 13:48:40 +0200 Subject: Fix target::group_state() for unmatched ad hoc group members --- libbuild2/target.hxx | 2 +- libbuild2/target.ixx | 16 +++++++++++++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/libbuild2/target.hxx b/libbuild2/target.hxx index 76b7158..46c0949 100644 --- a/libbuild2/target.hxx +++ b/libbuild2/target.hxx @@ -1037,7 +1037,7 @@ namespace build2 executed_state_impl (action) const; // Return true if the state comes from the group. Target must be at least - // matched. + // matched except for ad hoc group members during the execute phase. // bool group_state (action) const; diff --git a/libbuild2/target.ixx b/libbuild2/target.ixx index 8136fe9..69b2776 100644 --- a/libbuild2/target.ixx +++ b/libbuild2/target.ixx @@ -273,9 +273,6 @@ namespace build2 } } - LIBBUILD2_SYMEXPORT target_state - group_action (action, const target&); // - inline bool target:: group_state (action a) const { @@ -289,6 +286,19 @@ namespace build2 // @@ Hm, I wonder why not just return s.recipe_group_action now that we // cache it. // + + // This special hack allows us to do things like query an ad hoc member's + // state or mtime without matching/executing the member, only the group. + // Requiring matching/executing the member would be too burdensome and + // this feels harmless (ad hoc membership cannot be changed during the + // execute phase). + // + // Note: this test must come first since the member may not be matched and + // thus its state uninitialized. + // + if (ctx.phase == run_phase::execute && adhoc_group_member ()) + return true; + const opstate& s (state[a]); if (s.state == target_state::group) -- cgit v1.1