aboutsummaryrefslogtreecommitdiff
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
parenta3ed04f37c47e2eaa83d87dda2ec4ab060a7a2d0 (diff)
Add $target.process_path() analogous to $target.path()
-rw-r--r--libbuild2/functions-name.cxx30
-rw-r--r--libbuild2/target.cxx2
-rw-r--r--libbuild2/target.hxx4
3 files changed, 33 insertions, 3 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");
diff --git a/libbuild2/target.cxx b/libbuild2/target.cxx
index b9cfea7..b65a4fa 100644
--- a/libbuild2/target.cxx
+++ b/libbuild2/target.cxx
@@ -1073,7 +1073,7 @@ namespace build2
bool search)
{
// If we are searching for an executable that is not a target, then use
- // the build machine executable extension. Otherwise, if this is a target,
+ // the host machine executable extension. Otherwise, if this is a target,
// then we expect the rule to supply the target machine extension. But if
// it doesn't, then fallback to no extension (e.g., a script).
//
diff --git a/libbuild2/target.hxx b/libbuild2/target.hxx
index 72b7acc..9a4aed5 100644
--- a/libbuild2/target.hxx
+++ b/libbuild2/target.hxx
@@ -1684,7 +1684,9 @@ namespace build2
virtual const target_type& dynamic_type () const {return static_type;}
};
- // Executable file.
+ // Executable file (not necessarily binary, though we do fallback to the
+ // host machine executable extension in certain cases; see the default
+ // extension derivation for details).
//
class LIBBUILD2_SYMEXPORT exe: public file
{