~lattis/muon

6e13d4e257bf32fa8665702ce01eb4d51b56e8bd — Stone Tickle 2 years ago 33e0cb5
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.
1 files changed, 16 insertions(+), 0 deletions(-)

M src/functions/default/custom_target.c
M src/functions/default/custom_target.c => src/functions/default/custom_target.c +16 -0
@@ 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;
}