From 6e13d4e257bf32fa8665702ce01eb4d51b56e8bd Mon Sep 17 00:00:00 2001 From: Stone Tickle Date: Tue, 14 Sep 2021 09:12:36 -0500 Subject: [PATCH] absolutize first element of custom target cmdline this is because we add the first element of the command line as an implicit dependency in the build.ninja, so ninja needs to know the full path to the file. --- src/functions/default/custom_target.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/functions/default/custom_target.c b/src/functions/default/custom_target.c index 0240c918..684e04b8 100644 --- a/src/functions/default/custom_target.c +++ b/src/functions/default/custom_target.c @@ -8,6 +8,8 @@ #include "functions/string.h" #include "lang/interpreter.h" #include "log.h" +#include "platform/path.h" +#include "platform/filesystem.h" struct custom_target_cmd_fmt_ctx { uint32_t arr, err_node; @@ -202,6 +204,20 @@ process_custom_target_commandline(struct workspace *wk, uint32_t err_node, return false; } + obj cmd; + obj_array_index(wk, *res, 0, &cmd); + + if (!path_is_absolute(wk_objstr(wk, cmd))) { + const char *cmd_path; + if (!fs_find_cmd(wk_objstr(wk, cmd), &cmd_path)) { + interp_error(wk, err_node, "command '%s' not found", + wk_objstr(wk, cmd)); + return false; + } + + obj_array_set(wk, *res, 0, make_str(wk, cmd_path)); + } + return true; } -- 2.38.5