aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/target-type.hxx
diff options
context:
space:
mode:
Diffstat (limited to 'libbuild2/target-type.hxx')
-rw-r--r--libbuild2/target-type.hxx31
1 files changed, 23 insertions, 8 deletions
diff --git a/libbuild2/target-type.hxx b/libbuild2/target-type.hxx
index 09bc316..93c5744 100644
--- a/libbuild2/target-type.hxx
+++ b/libbuild2/target-type.hxx
@@ -89,9 +89,18 @@ namespace build2
const location&,
bool reverse);
- void (*print) (ostream&, const target_key&);
+ // See to_stream(ostream,target_key) for details.
+ //
+ bool (*print) (ostream&, const target_key&, bool name_only);
- const target* (*search) (const target&, const prerequisite_key&);
+ // Target type-specific prerequisite to target search.
+ //
+ // If passed target is NULL, then only search for an existing target (and
+ // which can be performed during execute, not only match).
+ //
+ const target* (*search) (context&,
+ const target*,
+ const prerequisite_key&);
// Target type flags.
//
@@ -100,12 +109,15 @@ namespace build2
// group link-up only happens during match, then the hint would be looked
// up before the group is known.
//
+ // Note: consider exposing as an attribute in define if adding a new flag.
+ //
enum class flag: uint64_t
{
none = 0,
group = 0x01, // A (non-adhoc) group.
see_through = group | 0x02, // A group with "see through" semantics.
- member_hint = group | 0x04 // Untyped rule hint applies to members.
+ member_hint = group | 0x04, // Untyped rule hint applies to members.
+ dyn_members = group | 0x08 // A group with dynamic members.
};
flag flags;
@@ -129,6 +141,9 @@ namespace build2
bool
is_a (const char*) const; // Defined in target.cxx
+
+ target_type& operator= (target_type&&) = delete;
+ target_type& operator= (const target_type&) = delete;
};
inline bool
@@ -189,18 +204,18 @@ namespace build2
return type_map_.empty ();
}
- const target_type&
+ pair<reference_wrapper<const target_type>, bool>
insert (const target_type& tt)
{
- type_map_.emplace (tt.name, target_type_ref (tt));
- return tt;
+ auto r (type_map_.emplace (tt.name, target_type_ref (tt)));
+ return {r.second ? tt : r.first->second.get (), r.second};
}
template <typename T>
const target_type&
insert ()
{
- return insert (T::static_type);
+ return insert (T::static_type).first;
}
pair<reference_wrapper<const target_type>, bool>
@@ -246,7 +261,7 @@ namespace build2
target_type_ref (unique_ptr<target_type>&& p)
: p_ (p.release ()), d_ (true) {}
- target_type_ref (target_type_ref&& r)
+ target_type_ref (target_type_ref&& r) noexcept
: p_ (r.p_), d_ (r.d_) {r.p_ = nullptr;}
~target_type_ref () {if (p_ != nullptr && d_) delete p_;}