OLD | NEW |
1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 # This file introduces two related templates that act like action and | 5 # This file introduces two related templates that act like action and |
6 # action_foreach but instead of running a Python script, it will compile a | 6 # action_foreach but instead of running a Python script, it will compile a |
7 # given tool in the host toolchain and run that (either once or over the list | 7 # given tool in the host toolchain and run that (either once or over the list |
8 # of inputs, depending on the variant). | 8 # of inputs, depending on the variant). |
9 # | 9 # |
10 # Parameters | 10 # Parameters |
11 # | 11 # |
12 # tool (required) | 12 # tool (required) |
13 # [label] Label of the tool to run. This should be an executable, and | 13 # [label] Label of the tool to run. This should be an executable, and |
14 # this label should not include a toolchain (anything in parens). The | 14 # this label should not include a toolchain (anything in parens). The |
15 # host compile of this tool will be used. | 15 # host compile of this tool will be used. |
16 # | 16 # |
17 # outputs (required) | 17 # outputs (required) |
18 # [list of files] Like the outputs of action (if using "compiled_action", | 18 # [list of files] Like the outputs of action (if using "compiled_action", |
19 # this would be just the list of outputs), or action_foreach (if using | 19 # this would be just the list of outputs), or action_foreach (if using |
20 # "compiled_action_foreach", this would contain source expansions mapping | 20 # "compiled_action_foreach", this would contain source expansions mapping |
21 # input to output files). | 21 # input to output files). |
22 # | 22 # |
23 # args (required) | 23 # args (required) |
24 # [list of strings] Same meaning as action/action_foreach. | 24 # [list of strings] Same meaning as action/action_foreach. |
25 # | 25 # |
26 # visibility | 26 # visibility |
27 # source_prereqs | 27 # inputs |
28 # deps | 28 # deps |
29 # args (all optional) | 29 # args (all optional) |
30 # Same meaning as action/action_foreach. | 30 # Same meaning as action/action_foreach. |
31 # | 31 # |
32 # | 32 # |
33 # Example of usage: | 33 # Example of usage: |
34 # | 34 # |
35 # compiled_action("run_my_tool") { | 35 # compiled_action("run_my_tool") { |
36 # tool = "//tools/something:mytool" | 36 # tool = "//tools/something:mytool" |
37 # outputs = [ | 37 # outputs = [ |
38 # "$target_gen_dir/mysource.cc", | 38 # "$target_gen_dir/mysource.cc", |
39 # "$target_gen_dir/mysource.h", | 39 # "$target_gen_dir/mysource.h", |
40 # ] | 40 # ] |
41 # | 41 # |
42 # # The tool takes this input. | 42 # # The tool takes this input. |
43 # source_prereqs = [ "my_input_file.idl" ] | 43 # inputs = [ "my_input_file.idl" ] |
44 # | 44 # |
45 # # In this case, the tool takes as arguments the input file and the output | 45 # # In this case, the tool takes as arguments the input file and the output |
46 # # build dir (both relative to the "cd" that the script will be run in) | 46 # # build dir (both relative to the "cd" that the script will be run in) |
47 # # and will produce the output files listed above. | 47 # # and will produce the output files listed above. |
48 # args = [ | 48 # args = [ |
49 # rebase_path("my_input_file.idl", root_build_dir), | 49 # rebase_path("my_input_file.idl", root_build_dir), |
50 # "--output-dir", rebase_path(target_gen_dir, root_build_dir), | 50 # "--output-dir", rebase_path(target_gen_dir, root_build_dir), |
51 # ] | 51 # ] |
52 # } | 52 # } |
53 # | 53 # |
(...skipping 13 matching lines...) Expand all Loading... |
67 assert(defined(invoker.outputs), "outputs must be defined for $target_name") | 67 assert(defined(invoker.outputs), "outputs must be defined for $target_name") |
68 assert(defined(invoker.args), "args must be defined for $target_name") | 68 assert(defined(invoker.args), "args must be defined for $target_name") |
69 | 69 |
70 action(target_name) { | 70 action(target_name) { |
71 if (defined(invoker.visibility)) { | 71 if (defined(invoker.visibility)) { |
72 visibility = invoker.visibility | 72 visibility = invoker.visibility |
73 } | 73 } |
74 | 74 |
75 script = "//build/gn_run_binary.py" | 75 script = "//build/gn_run_binary.py" |
76 | 76 |
77 if (defined(invoker.source_prereqs)) { | 77 if (defined(invoker.inputs)) { |
78 source_prereqs = invoker.source_prereqs | 78 inputs = invoker.inputs |
79 } | 79 } |
80 outputs = invoker.outputs | 80 outputs = invoker.outputs |
81 | 81 |
82 # Constuct the host toolchain version of the tool. | 82 # Constuct the host toolchain version of the tool. |
83 host_tool = invoker.tool + "($host_toolchain)" | 83 host_tool = invoker.tool + "($host_toolchain)" |
84 | 84 |
85 # Get the path to the executable. Currently, this assumes that the tool | 85 # Get the path to the executable. Currently, this assumes that the tool |
86 # does not specify output_name so that the target name is the name to use. | 86 # does not specify output_name so that the target name is the name to use. |
87 # If that's not the case, we'll need another argument to the script to | 87 # If that's not the case, we'll need another argument to the script to |
88 # specify this, since we can't know what the output name is (it might be in | 88 # specify this, since we can't know what the output name is (it might be in |
(...skipping 22 matching lines...) Expand all Loading... |
111 | 111 |
112 action_foreach(target_name) { | 112 action_foreach(target_name) { |
113 # Otherwise this is a standalone action, define visibility if requested. | 113 # Otherwise this is a standalone action, define visibility if requested. |
114 if (defined(invoker.visibility)) { | 114 if (defined(invoker.visibility)) { |
115 visibility = invoker.visibility | 115 visibility = invoker.visibility |
116 } | 116 } |
117 | 117 |
118 script = "//build/gn_run_binary.py" | 118 script = "//build/gn_run_binary.py" |
119 sources = invoker.sources | 119 sources = invoker.sources |
120 | 120 |
121 if (defined(invoker.source_prereqs)) { | 121 if (defined(invoker.inputs)) { |
122 source_prereqs = invoker.source_prereqs | 122 inputs = invoker.inputs |
123 } | 123 } |
124 outputs = invoker.outputs | 124 outputs = invoker.outputs |
125 | 125 |
126 # Constuct the host toolchain version of the tool. | 126 # Constuct the host toolchain version of the tool. |
127 host_tool = invoker.tool + "($host_toolchain)" | 127 host_tool = invoker.tool + "($host_toolchain)" |
128 | 128 |
129 # Get the path to the executable. Currently, this assumes that the tool | 129 # Get the path to the executable. Currently, this assumes that the tool |
130 # does not specify output_name so that the target name is the name to use. | 130 # does not specify output_name so that the target name is the name to use. |
131 # If that's not the case, we'll need another argument to the script to | 131 # If that's not the case, we'll need another argument to the script to |
132 # specify this, since we can't know what the output name is (it might be in | 132 # specify this, since we can't know what the output name is (it might be in |
133 # another file not processed yet). | 133 # another file not processed yet). |
134 host_executable = get_label_info(host_tool, "root_out_dir") + "/" + | 134 host_executable = get_label_info(host_tool, "root_out_dir") + "/" + |
135 get_label_info(host_tool, "name") | 135 get_label_info(host_tool, "name") |
136 | 136 |
137 deps = [ host_tool ] | 137 deps = [ host_tool ] |
138 if (defined(invoker.deps)) { | 138 if (defined(invoker.deps)) { |
139 deps += invoker.deps | 139 deps += invoker.deps |
140 } | 140 } |
141 | 141 |
142 # The script takes as arguments the binary to run, and then the arguments | 142 # The script takes as arguments the binary to run, and then the arguments |
143 # to pass it. | 143 # to pass it. |
144 args = [ | 144 args = [ |
145 rebase_path(host_executable, root_build_dir) | 145 rebase_path(host_executable, root_build_dir) |
146 ] + invoker.args | 146 ] + invoker.args |
147 } | 147 } |
148 } | 148 } |
OLD | NEW |