aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/target-key.hxx
diff options
context:
space:
mode:
Diffstat (limited to 'libbuild2/target-key.hxx')
-rw-r--r--libbuild2/target-key.hxx34
1 files changed, 27 insertions, 7 deletions
diff --git a/libbuild2/target-key.hxx b/libbuild2/target-key.hxx
index 62bcc25..9ac87dc 100644
--- a/libbuild2/target-key.hxx
+++ b/libbuild2/target-key.hxx
@@ -4,7 +4,6 @@
#ifndef LIBBUILD2_TARGET_KEY_HXX
#define LIBBUILD2_TARGET_KEY_HXX
-#include <map>
#include <cstring> // strcmp()
#include <libbuild2/types.hxx>
@@ -22,18 +21,26 @@ namespace build2
class LIBBUILD2_SYMEXPORT target_key
{
public:
- const target_type* const type;
- const dir_path* const dir; // Can be relative if part of prerequisite_key.
- const dir_path* const out; // Can be relative if part of prerequisite_key.
- const string* const name;
+ const target_type* type;
+ const dir_path* dir; // Can be relative if part of prerequisite_key.
+ const dir_path* out; // Can be relative if part of prerequisite_key.
+ const string* name;
mutable optional<string> ext; // Absent - unspecified, empty - none.
template <typename T>
bool is_a () const {return type->is_a<T> ();}
bool is_a (const target_type& tt) const {return type->is_a (tt);}
+ // Return an "effective" name, for example, for pattern matching, that
+ // includes the extension where appropriate.
+ //
+ const string&
+ effective_name (string& storage, bool force_ext = false) const;
+
// Append/return the target name or a pair of names if out-qualified.
//
+ // See also target::as_name() for the returned name stability guarantees.
+ //
void
as_name (names&) const;
@@ -87,8 +94,21 @@ namespace build2
LIBBUILD2_SYMEXPORT ostream&
operator<< (ostream&, const target_key&);
- LIBBUILD2_SYMEXPORT ostream&
- to_stream (ostream&, const target_key&, optional<stream_verbosity> = nullopt);
+ // If name_only is true, then only print the target name (and extension, if
+ // necessary), without the directory or type.
+ //
+ // Return true if the result is regular, that is, in the
+ // <dir>/<type>{<name>}@<out>/ form with the individual components
+ // corresponding directly to the target_key members (that is, without moving
+ // parts around as would be the case for directories). This information is
+ // used when trying to print several targets in a combined form (for
+ // example, {hxx cxx}{foo}) in print_diag().
+ //
+ LIBBUILD2_SYMEXPORT bool
+ to_stream (ostream&,
+ const target_key&,
+ optional<stream_verbosity> = nullopt,
+ bool name_only = false);
}
namespace std