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 # Instantiate grit. This will produce a script target to run grit, and a | 5 # Instantiate grit. This will produce a script target to run grit, and a |
6 # static library that compiles the .cc files. | 6 # static library that compiles the .cc files. |
7 # | 7 # |
8 # Parameters | 8 # Parameters |
9 # | 9 # |
10 # source | 10 # source |
11 # Path to .grd file. | 11 # Path to .grd file. |
12 # | 12 # |
13 # outputs (optional) | 13 # outputs (optional) |
14 # List of outputs from grit, relative to the target_gen_dir. If supplied, | 14 # List of outputs from grit, relative to the target_gen_dir. If supplied, |
15 # a call to Grit to compute the outputs can be skipped which will make | 15 # a call to Grit to compute the outputs can be skipped which will make |
16 # GN run faster. Grit will verify at build time that this list is correct | 16 # GN run faster. Grit will verify at build time that this list is correct |
17 # and will fail if there is a mismatch between the outputs specified by | 17 # and will fail if there is a mismatch between the outputs specified by |
18 # the .grd file and the outputs list here. | 18 # the .grd file and the outputs list here. |
19 # | 19 # |
20 # To get this list, you can look in the .grd file for | 20 # To get this list, you can look in the .grd file for |
21 # <output filename="..." and put those filename here. The base directory | 21 # <output filename="..." and put those filename here. The base directory |
22 # of the list in Grit and the output list specified in the GN grit target | 22 # of the list in Grit and the output list specified in the GN grit target |
23 # are the same (the target_gen_dir) so you can generally copy the names | 23 # are the same (the target_gen_dir) so you can generally copy the names |
24 # exactly. | 24 # exactly. |
25 # | 25 # |
26 # To get the list of outputs programatically, run: | 26 # To get the list of outputs programatically, run: |
27 # python tools/grit/grit_info.py --outputs . path/to/your.grd | 27 # python tools/grit/grit_info.py --outputs . path/to/your.grd |
28 # And strip the leading "./" from the output files. | 28 # And strip the leading "./" from the output files. |
29 # | 29 # |
| 30 # defines (optional) |
| 31 # Extra defines to pass to grit (on top of the global grit_defines list). |
| 32 # |
30 # grit_flags (optional) | 33 # grit_flags (optional) |
31 # List of strings containing extra command-line flags to pass to Grit. | 34 # List of strings containing extra command-line flags to pass to Grit. |
32 # | 35 # |
33 # resource_ids (optional) | 36 # resource_ids (optional) |
34 # Path to a grit "firstidsfile". Default is | 37 # Path to a grit "firstidsfile". Default is |
35 # //tools/gritsettings/resource_ids. Set to "" to use the value specified in | 38 # //tools/gritsettings/resource_ids. Set to "" to use the value specified in |
36 # the <grit> nodes of the processed files. | 39 # the <grit> nodes of the processed files. |
37 # | 40 # |
38 # output_dir (optional) | 41 # output_dir (optional) |
39 # Directory for generated files. | 42 # Directory for generated files. |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
262 inputs = grit_inputs | 265 inputs = grit_inputs |
263 outputs = grit_outputs | 266 outputs = grit_outputs |
264 depfile = "$target_out_dir/${target_name}.d" | 267 depfile = "$target_out_dir/${target_name}.d" |
265 | 268 |
266 args = [ | 269 args = [ |
267 "-i", source_path, "build", | 270 "-i", source_path, "build", |
268 "-f", resource_ids, | 271 "-f", resource_ids, |
269 "-o", rebased_output_dir, | 272 "-o", rebased_output_dir, |
270 "--depdir", ".", | 273 "--depdir", ".", |
271 "--depfile", rebase_path(depfile, root_build_dir), | 274 "--depfile", rebase_path(depfile, root_build_dir), |
272 ] + grit_defines + grit_flags + assert_files_flags | 275 ] + grit_defines |
| 276 |
| 277 # Add extra defines with -D flags. |
| 278 if (defined(invoker.defines)) { |
| 279 foreach (i, invoker.defines) { |
| 280 args += [ "-D", i ] |
| 281 } |
| 282 } |
| 283 |
| 284 args += grit_flags + assert_files_flags |
273 | 285 |
274 visibility = target_visibility | 286 visibility = target_visibility |
275 | 287 |
276 deps = [ "//tools/grit:grit_sources" ] | 288 deps = [ "//tools/grit:grit_sources" ] |
277 if (defined(invoker.deps)) { | 289 if (defined(invoker.deps)) { |
278 deps += invoker.deps | 290 deps += invoker.deps |
279 } | 291 } |
280 } | 292 } |
281 | 293 |
282 # This is the thing that people actually link with, it must be named the | 294 # This is the thing that people actually link with, it must be named the |
283 # same as the argument the template was invoked with. | 295 # same as the argument the template was invoked with. |
284 source_set(target_name) { | 296 source_set(target_name) { |
285 # Since we generate a file, we need to be run before the targets that | 297 # Since we generate a file, we need to be run before the targets that |
286 # depend on us. | 298 # depend on us. |
287 sources = grit_outputs | 299 sources = grit_outputs |
288 | 300 |
289 # Deps set on the template invocation will go on the grit script running | 301 # Deps set on the template invocation will go on the grit script running |
290 # target rather than this library. | 302 # target rather than this library. |
291 deps = [ ":$grit_custom_target" ] | 303 deps = [ ":$grit_custom_target" ] |
292 direct_dependent_configs = [ ":$grit_config" ] | 304 direct_dependent_configs = [ ":$grit_config" ] |
293 | 305 |
294 if (defined(invoker.visibility)) { | 306 if (defined(invoker.visibility)) { |
295 visibility = invoker.visibility | 307 visibility = invoker.visibility |
296 } | 308 } |
297 if (defined(invoker.output_name)) { | 309 if (defined(invoker.output_name)) { |
298 output_name = invoker.output_name | 310 output_name = invoker.output_name |
299 } | 311 } |
300 } | 312 } |
301 } | 313 } |
OLD | NEW |