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 |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 | 74 |
75 template("compiled_action") { | 75 template("compiled_action") { |
76 assert(defined(invoker.tool), "tool must be defined for $target_name") | 76 assert(defined(invoker.tool), "tool must be defined for $target_name") |
77 assert(defined(invoker.outputs), "outputs must be defined for $target_name") | 77 assert(defined(invoker.outputs), "outputs must be defined for $target_name") |
78 assert(defined(invoker.args), "args must be defined for $target_name") | 78 assert(defined(invoker.args), "args must be defined for $target_name") |
79 | 79 |
80 assert(!defined(invoker.sources), | 80 assert(!defined(invoker.sources), |
81 "compiled_action doesn't take a sources arg. Use inputs instead.") | 81 "compiled_action doesn't take a sources arg. Use inputs instead.") |
82 | 82 |
83 action(target_name) { | 83 action(target_name) { |
84 deps = [] | |
85 inputs = [] | |
86 forward_variables_from(invoker, | 84 forward_variables_from(invoker, |
87 [ | 85 [ |
88 "deps", | 86 "deps", |
89 "inputs", | 87 "inputs", |
90 "outputs", | 88 "outputs", |
91 "testonly", | 89 "testonly", |
92 "visibility", | 90 "visibility", |
93 ]) | 91 ]) |
| 92 if (!defined(deps)) { |
| 93 deps = [] |
| 94 } |
| 95 if (!defined(inputs)) { |
| 96 inputs = [] |
| 97 } |
94 | 98 |
95 script = "//build/gn_run_binary.py" | 99 script = "//build/gn_run_binary.py" |
96 | 100 |
97 # Constuct the host toolchain version of the tool. | 101 # Constuct the host toolchain version of the tool. |
98 host_tool = invoker.tool + "($host_toolchain)" | 102 host_tool = invoker.tool + "($host_toolchain)" |
99 | 103 |
100 # Get the path to the executable. Currently, this assumes that the tool | 104 # Get the path to the executable. Currently, this assumes that the tool |
101 # does not specify output_name so that the target name is the name to use. | 105 # does not specify output_name so that the target name is the name to use. |
102 # If that's not the case, we'll need another argument to the script to | 106 # If that's not the case, we'll need another argument to the script to |
103 # specify this, since we can't know what the output name is (it might be in | 107 # specify this, since we can't know what the output name is (it might be in |
(...skipping 13 matching lines...) Expand all Loading... |
117 } | 121 } |
118 } | 122 } |
119 | 123 |
120 template("compiled_action_foreach") { | 124 template("compiled_action_foreach") { |
121 assert(defined(invoker.sources), "sources must be defined for $target_name") | 125 assert(defined(invoker.sources), "sources must be defined for $target_name") |
122 assert(defined(invoker.tool), "tool must be defined for $target_name") | 126 assert(defined(invoker.tool), "tool must be defined for $target_name") |
123 assert(defined(invoker.outputs), "outputs must be defined for $target_name") | 127 assert(defined(invoker.outputs), "outputs must be defined for $target_name") |
124 assert(defined(invoker.args), "args must be defined for $target_name") | 128 assert(defined(invoker.args), "args must be defined for $target_name") |
125 | 129 |
126 action_foreach(target_name) { | 130 action_foreach(target_name) { |
127 deps = [] | |
128 inputs = [] | |
129 forward_variables_from(invoker, | 131 forward_variables_from(invoker, |
130 [ | 132 [ |
131 "deps", | 133 "deps", |
132 "inputs", | 134 "inputs", |
133 "outputs", | 135 "outputs", |
134 "sources", | 136 "sources", |
135 "testonly", | 137 "testonly", |
136 "visibility", | 138 "visibility", |
137 ]) | 139 ]) |
| 140 if (!defined(deps)) { |
| 141 deps = [] |
| 142 } |
| 143 if (!defined(inputs)) { |
| 144 inputs = [] |
| 145 } |
138 | 146 |
139 script = "//build/gn_run_binary.py" | 147 script = "//build/gn_run_binary.py" |
140 | 148 |
141 # Constuct the host toolchain version of the tool. | 149 # Constuct the host toolchain version of the tool. |
142 host_tool = invoker.tool + "($host_toolchain)" | 150 host_tool = invoker.tool + "($host_toolchain)" |
143 | 151 |
144 # Get the path to the executable. Currently, this assumes that the tool | 152 # Get the path to the executable. Currently, this assumes that the tool |
145 # does not specify output_name so that the target name is the name to use. | 153 # does not specify output_name so that the target name is the name to use. |
146 # If that's not the case, we'll need another argument to the script to | 154 # If that's not the case, we'll need another argument to the script to |
147 # specify this, since we can't know what the output name is (it might be in | 155 # specify this, since we can't know what the output name is (it might be in |
148 # another file not processed yet). | 156 # another file not processed yet). |
149 host_executable = | 157 host_executable = |
150 get_label_info(host_tool, "root_out_dir") + "/" + | 158 get_label_info(host_tool, "root_out_dir") + "/" + |
151 get_label_info(host_tool, "name") + _host_executable_suffix | 159 get_label_info(host_tool, "name") + _host_executable_suffix |
152 | 160 |
153 # Add the executable itself as an input. | 161 # Add the executable itself as an input. |
154 inputs += [ host_executable ] | 162 inputs += [ host_executable ] |
155 | 163 |
156 deps += [ host_tool ] | 164 deps += [ host_tool ] |
157 | 165 |
158 # The script takes as arguments the binary to run, and then the arguments | 166 # The script takes as arguments the binary to run, and then the arguments |
159 # to pass it. | 167 # to pass it. |
160 args = [ rebase_path(host_executable, root_build_dir) ] + invoker.args | 168 args = [ rebase_path(host_executable, root_build_dir) ] + invoker.args |
161 } | 169 } |
162 } | 170 } |
OLD | NEW |