aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/functions-name.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2020-06-02 08:06:31 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2020-06-02 08:06:31 +0200
commite2445d5d031b9489215cbac4f39db56cd40270df (patch)
treeebc543c30732af9def3e98ad6bb1ae8701c16ef0 /libbuild2/functions-name.cxx
parenta3ed04f37c47e2eaa83d87dda2ec4ab060a7a2d0 (diff)
Add $target.process_path() analogous to $target.path()
Diffstat (limited to 'libbuild2/functions-name.cxx')
-rw-r--r--libbuild2/functions-name.cxx30
1 files changed, 29 insertions, 1 deletions
diff --git a/libbuild2/functions-name.cxx b/libbuild2/functions-name.cxx
index 70659ee..ca0f8ce 100644
--- a/libbuild2/functions-name.cxx
+++ b/libbuild2/functions-name.cxx
@@ -114,7 +114,7 @@ namespace build2
fn["path"] = [](const scope* s, names ns)
{
if (s == nullptr)
- fail << "target.path() called out of scope" << endf;
+ fail << "target.path() called out of scope";
// Most of the time we will have a single target so optimize for that.
//
@@ -150,6 +150,34 @@ namespace build2
make_move_iterator (r.end ())));
};
+ // This one can only be called on a single target since we don't support
+ // containers of process_path's (though we probably could).
+ //
+ fn["process_path"] = [](const scope* s, names ns)
+ {
+ if (s == nullptr)
+ fail << "target.process_path() called out of scope";
+
+ if (ns.empty () || ns.size () != (ns[0].pair ? 2 : 1))
+ fail << "target.process_path() expects single target";
+
+ name o;
+ const target& t (
+ to_target (*s, move (ns[0]), move (ns[0].pair ? ns[1] : o)));
+
+ if (const auto* et = t.is_a<exe> ())
+ {
+ process_path r (et->process_path ());
+
+ if (r.empty ())
+ fail << "target " << t << " path is not assigned";
+
+ return r;
+ }
+ else
+ fail << "target " << t << " is not process_path-based" << endf;
+ };
+
// Name-specific overloads from builtins.
//
function_family fb (m, "builtin");