aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/target.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2023-05-23 09:23:16 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2023-05-29 10:21:12 +0200
commite05f7c7383cc48823bd408c0bc5187191a9a1c48 (patch)
tree024bb9c3be9c876b8822388baf1622cad03d7563 /libbuild2/target.cxx
parent349b34108752e2fcf1ead648ffec8e5acfe4a91c (diff)
Explicit group: static members
Diffstat (limited to 'libbuild2/target.cxx')
-rw-r--r--libbuild2/target.cxx38
1 files changed, 38 insertions, 0 deletions
diff --git a/libbuild2/target.cxx b/libbuild2/target.cxx
index a9ae47a..c1002b9 100644
--- a/libbuild2/target.cxx
+++ b/libbuild2/target.cxx
@@ -1217,6 +1217,42 @@ namespace build2
target_type::flag::none
};
+ // group
+ //
+ group_view group::
+ group_members (action a) const
+ {
+ if (members_on == 0) // Not yet discovered.
+ return group_view {nullptr, 0};
+
+ // Members discovered during anything other than perform_update are only
+ // good for that operation. For example, we only return the static members
+ // ("representative sample") for perform_configure.
+ //
+ // We also re-discover the members on each update and clean not to
+ // overcomplicate the already twisted adhoc_buildscript_rule::apply()
+ // logic.
+ //
+ if (members_on != ctx.current_on)
+ {
+ if (members_action != perform_update_id ||
+ a == perform_update_id ||
+ a == perform_clean_id)
+ return group_view {nullptr, 0};
+ }
+
+ // Note that we may have no members (e.g., perform_configure and there are
+ // no static members). However, whether std::vector returns a non-NULL
+ // pointer in this case is undefined.
+ //
+ size_t n (members.size ());
+ return group_view {
+ n != 0
+ ? members.data ()
+ : reinterpret_cast<const target* const*> (this),
+ n};
+ }
+
const target_type group::static_type
{
"group",
@@ -1230,6 +1266,8 @@ namespace build2
target_type::flag::group
};
+ // alias
+ //
static const target*
alias_search (const target& t, const prerequisite_key& pk)
{