1 # Defines compiled_action().
3 # compiled_action() is like action(), except that it runs a built binary
9 # [label] Label of the tool to run. This should be an executable, and
10 # this label should not include a toolchain (anything in parens). This
11 # tool will be built for the host.
14 # [list of files] Same meaning as for action().
17 # [list of strings] Flags to pass to the built binary. Almost identical
18 # to action()'s `args`, except that `tool` is implicitly added as first
24 # visibility (all optional)
25 # Same meaning as for action().
29 # compiled_action("run_my_tool") {
30 # tool = "//tools/something:mytool"
31 # inputs = [ "my_input_file.txt" ]
32 # outputs = [ "$target_gen_dir/mysource.inc" ]
34 # rebase_path(inputs[0], root_build_dir),
35 # rebase_path(outputs[0], root_build_dir),
39 # You would typically declare your tool like this:
40 # if (host_toolchain == current_toolchain) {
41 # executable("mytool") {
45 # The if statement around the executable is optional. It means "I only care
46 # about this target in the host toolchain". Usually this is what you want, and
47 # saves unnecessarily compiling your tool for the target platform. If you
48 # need a target build of your tool as well, omit the if statement.
50 template("compiled_action") {
51 assert(defined(invoker.args), "must set 'args' in $target_name")
52 assert(defined(invoker.outputs), "must set 'outputs' in $target_name")
53 assert(defined(invoker.tool), "must set 'tool' in $target_name")
54 assert(!defined(invoker.sources),
55 "use 'inputs' instead of 'sources' in $target_name")
58 forward_variables_from(invoker,
66 host_tool = invoker.tool + "($host_toolchain)"
67 host_executable = get_label_info(host_tool, "root_out_dir") + "/bin/" +
68 get_label_info(host_tool, "name")
70 script = "//llvm/utils/gn/build/run_built_binary.py"
71 args = [ rebase_path(host_executable, root_build_dir) ] + invoker.args