aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2023-11-16 13:48:40 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2023-11-16 13:48:40 +0200
commit23b059eea0618220010b30bacbf97db7f642c870 (patch)
treeb197c61083468530e0fc2305c630f7fa7cd6b97c
parenta7513ddd6250dada74d241abf8551828b16cb554 (diff)
Fix target::group_state() for unmatched ad hoc group members
-rw-r--r--libbuild2/target.hxx2
-rw-r--r--libbuild2/target.ixx16
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&); // <libbuild2/algorithm.hxx>
-
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)