aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2022-01-21 09:22:20 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2022-01-21 09:22:20 +0200
commit614ac547aabbf9c6168e3ad42dad6ee022de2080 (patch)
tree41328a8f20340cc18b7e120c1aa75e4b420b4fee
parentd2b8ba3e586a17e78b480c129bfcf24d6e05bade (diff)
Add another overload of to_target(), declare in functions-name.hxx
-rw-r--r--libbuild2/cc/functions.cxx5
-rw-r--r--libbuild2/functions-name.cxx15
-rw-r--r--libbuild2/functions-name.hxx30
3 files changed, 44 insertions, 6 deletions
diff --git a/libbuild2/cc/functions.cxx b/libbuild2/cc/functions.cxx
index abfd32f..e05c707 100644
--- a/libbuild2/cc/functions.cxx
+++ b/libbuild2/cc/functions.cxx
@@ -13,11 +13,10 @@
#include <libbuild2/cc/module.hxx>
#include <libbuild2/cc/utility.hxx>
+#include <libbuild2/functions-name.hxx> // to_target()
+
namespace build2
{
- const target&
- to_target (const scope&, name&&, name&&); // libbuild2/functions-name.cxx
-
namespace cc
{
using namespace bin;
diff --git a/libbuild2/functions-name.cxx b/libbuild2/functions-name.cxx
index 800c377..72ac2bd 100644
--- a/libbuild2/functions-name.cxx
+++ b/libbuild2/functions-name.cxx
@@ -1,6 +1,8 @@
// file : libbuild2/functions-name.cxx -*- C++ -*-
// license : MIT; see accompanying LICENSE file
+#include <libbuild2/functions-name.hxx>
+
#include <libbuild2/scope.hxx>
#include <libbuild2/function.hxx>
#include <libbuild2/variable.hxx>
@@ -39,9 +41,7 @@ namespace build2
return make_pair (move (n), move (e));
}
- // Note: this helper mey be used by other functions that operate on targets.
- //
- LIBBUILD2_SYMEXPORT const target&
+ const target&
to_target (const scope& s, name&& n, name&& o)
{
if (const target* r = search_existing (n, s, o.dir))
@@ -52,6 +52,15 @@ namespace build2
<< " not found" << endf;
}
+ const target&
+ to_target (const scope& s, names&& ns)
+ {
+ assert (ns.size () == (ns[0].pair ? 2 : 1));
+
+ name o;
+ return to_target (s, move (ns[0]), move (ns[0].pair ? ns[1] : o));
+ }
+
void
name_functions (function_map& m)
{
diff --git a/libbuild2/functions-name.hxx b/libbuild2/functions-name.hxx
new file mode 100644
index 0000000..34fa4b8
--- /dev/null
+++ b/libbuild2/functions-name.hxx
@@ -0,0 +1,30 @@
+// file : libbuild2/functions-name.hxx -*- C++ -*-
+// license : MIT; see accompanying LICENSE file
+
+#ifndef LIBBUILD2_FUNCTIONS_NAME_HXX
+#define LIBBUILD2_FUNCTIONS_NAME_HXX
+
+#include <libbuild2/types.hxx>
+#include <libbuild2/forward.hxx>
+#include <libbuild2/utility.hxx>
+
+#include <libbuild2/export.hxx>
+
+namespace build2
+{
+ // Helpers that may be useful to other functions that operate on target
+ // name.
+
+ // Resolve the name to target issuing diagnostics and failing if not found.
+ //
+ LIBBUILD2_SYMEXPORT const target&
+ to_target (const scope&, name&&, name&& out);
+
+ // As above but from the names vector which should contain a single name
+ // or an out-qualified name pair (asserted).
+ //
+ LIBBUILD2_SYMEXPORT const target&
+ to_target (const scope&, names&&);
+}
+
+#endif // LIBBUILD2_FUNCTIONS_NAME_HXX