Chromium Code Reviews| 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 (required) | 10 # source (required) |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 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) | 30 # defines (optional) |
| 31 # Extra defines to pass to grit (on top of the global grit_defines list). | 31 # Extra defines to pass to grit (on top of the global grit_defines list). |
| 32 # | 32 # |
| 33 # grit_flags (optional) | 33 # grit_flags (optional) |
| 34 # 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. |
| 35 # | 35 # |
| 36 # resource_ids (optional) | 36 # resource_ids (optional) |
| 37 # Path to a grit "firstidsfile". Default is | 37 # Path to a grit "firstidsfile". Default is |
| 38 # //tools/gritsettings/resource_ids. Set to "" to use the value specified in | 38 # //tools/gritsettings/resource_ids. Set to "" to use the value specified |
| 39 # the <grit> nodes of the processed files. | 39 # in the <grit> nodes of the processed files. |
| 40 # | 40 # |
| 41 # output_dir (optional) | 41 # output_dir (optional) |
| 42 # Directory for generated files. | 42 # Directory for generated files. If you specify this, you will often |
| 43 # want to specify output_name if the target name is not particularly | |
| 44 # unique, since this can cause files from multiple grit targets to | |
| 45 # overwrite each other. | |
| 46 # | |
| 47 # output_name (optiona) | |
| 48 # Provide an alternate base name for the generated files, like the .d | |
| 49 # files. Normally these are based on the target name and go in the | |
| 50 # output_dir, but if multiple targets with the same name end up in | |
| 51 # the same output_dir, they can collide. | |
| 43 # | 52 # |
| 44 # use_qualified_include (optional) | 53 # use_qualified_include (optional) |
| 45 # If set, output_dir is not added to include_dirs. | 54 # If set, output_dir is not added to include_dirs. |
| 46 # | 55 # |
| 47 # deps (optional) | 56 # deps (optional) |
| 48 # visibility (optional) | 57 # visibility (optional) |
| 49 # Normal meaning. | 58 # Normal meaning. |
| 50 # | 59 # |
| 51 # Example | 60 # Example |
| 52 # | 61 # |
| 53 # grit("my_resources") { | 62 # grit("my_resources") { |
| 54 # # Source and outputs are required. | 63 # # Source and outputs are required. |
| 55 # source = "myfile.grd" | 64 # source = "myfile.grd" |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 200 } else { | 209 } else { |
| 201 resource_ids = grit_resource_id_file | 210 resource_ids = grit_resource_id_file |
| 202 } | 211 } |
| 203 | 212 |
| 204 if (defined(invoker.output_dir)) { | 213 if (defined(invoker.output_dir)) { |
| 205 output_dir = invoker.output_dir | 214 output_dir = invoker.output_dir |
| 206 } else { | 215 } else { |
| 207 output_dir = target_gen_dir | 216 output_dir = target_gen_dir |
| 208 } | 217 } |
| 209 | 218 |
| 219 if (defined(invoker.output_name)) { | |
| 220 grit_output_name = invoker.output_name | |
| 221 } else { | |
| 222 grit_output_name = target_name | |
| 223 } | |
| 224 | |
| 210 # These are all passed as arguments to the script so have to be relative to | 225 # These are all passed as arguments to the script so have to be relative to |
| 211 # the build directory. | 226 # the build directory. |
| 212 if (resource_ids != "") { | 227 if (resource_ids != "") { |
| 213 resource_ids = rebase_path(resource_ids, root_build_dir) | 228 resource_ids = rebase_path(resource_ids, root_build_dir) |
| 214 } | 229 } |
| 215 rebased_output_dir = rebase_path(output_dir, root_build_dir) | 230 rebased_output_dir = rebase_path(output_dir, root_build_dir) |
| 216 source_path = rebase_path(invoker.source, root_build_dir) | 231 source_path = rebase_path(invoker.source, root_build_dir) |
| 217 | 232 |
| 218 if (defined(invoker.grit_flags)) { | 233 if (defined(invoker.grit_flags)) { |
| 219 grit_flags = invoker.grit_flags | 234 grit_flags = invoker.grit_flags |
| 220 } else { | 235 } else { |
| 221 grit_flags = [] # These are optional so default to empty list. | 236 grit_flags = [] # These are optional so default to empty list. |
| 222 } | 237 } |
| 223 | 238 |
| 224 grit_inputs = [ invoker.source ] | 239 grit_inputs = [ invoker.source ] |
| 225 | 240 |
| 226 assert_files_flags = [] | 241 assert_files_flags = [] |
| 227 | 242 |
| 228 # We want to make sure the declared outputs actually match what Grit is | 243 # We want to make sure the declared outputs actually match what Grit is |
| 229 # writing. We write the list to a file (some of the output lists are long | 244 # writing. We write the list to a file (some of the output lists are long |
| 230 # enough to not fit on a Windows command line) and ask Grit to verify those | 245 # enough to not fit on a Windows command line) and ask Grit to verify those |
| 231 # are the actual outputs at runtime. | 246 # are the actual outputs at runtime. |
| 232 asserted_list_file = "$target_out_dir/${target_name}_expected_outputs.txt" | 247 asserted_list_file = |
| 248 "$target_out_dir/${grit_output_name}_expected_outputs.txt" | |
| 233 write_file(asserted_list_file, | 249 write_file(asserted_list_file, |
| 234 rebase_path(invoker.outputs, root_build_dir, output_dir)) | 250 rebase_path(invoker.outputs, root_build_dir, output_dir)) |
| 235 assert_files_flags += [ | 251 assert_files_flags += [ |
| 236 "--assert-file-list=" + rebase_path(asserted_list_file, root_build_dir), | 252 "--assert-file-list=" + rebase_path(asserted_list_file, root_build_dir), |
| 237 ] | 253 ] |
| 238 grit_outputs = get_path_info( | 254 grit_outputs = get_path_info( |
| 239 rebase_path(invoker.outputs, ".", output_dir), | 255 rebase_path(invoker.outputs, ".", output_dir), |
| 240 "abspath") | 256 "abspath") |
| 241 | 257 |
| 242 # The config and the action below get this visibility son only the generated | 258 # The config and the action below get this visibility son only the generated |
|
Joao da Silva
2014/08/13 20:47:27
nit: son -> so
| |
| 243 # source set can depend on them. The variable "target_name" will get | 259 # source set can depend on them. The variable "target_name" will get |
| 244 # overwritten inside the innter classes so we need to compute it here. | 260 # overwritten inside the inner classes so we need to compute it here. |
| 245 target_visibility = ":$target_name" | 261 target_visibility = ":$target_name" |
| 246 | 262 |
| 247 # The current grit setup makes an file in $output_dir/grit/foo.h that | 263 # The current grit setup makes an file in $output_dir/grit/foo.h that |
| 248 # the source code expects to include via "grit/foo.h". It would be nice to | 264 # the source code expects to include via "grit/foo.h". It would be nice to |
| 249 # change this to including absolute paths relative to the root gen directory | 265 # change this to including absolute paths relative to the root gen directory |
| 250 # (like "mycomponent/foo.h"). This config sets up the include path. | 266 # (like "mycomponent/foo.h"). This config sets up the include path. |
| 251 grit_config = target_name + "_grit_config" | 267 grit_config = target_name + "_grit_config" |
| 252 config(grit_config) { | 268 config(grit_config) { |
| 253 if (!defined(invoker.use_qualified_include) || | 269 if (!defined(invoker.use_qualified_include) || |
| 254 !invoker.use_qualified_include) { | 270 !invoker.use_qualified_include) { |
| 255 include_dirs = [ output_dir ] | 271 include_dirs = [ output_dir ] |
| 256 } | 272 } |
| 257 visibility = target_visibility | 273 visibility = target_visibility |
| 258 } | 274 } |
| 259 | 275 |
| 260 grit_custom_target = target_name + "_grit" | 276 grit_custom_target = target_name + "_grit" |
| 261 action(grit_custom_target) { | 277 action(grit_custom_target) { |
| 262 script = "//tools/grit/grit.py" | 278 script = "//tools/grit/grit.py" |
| 263 inputs = grit_inputs | 279 inputs = grit_inputs |
| 264 outputs = grit_outputs | 280 outputs = grit_outputs |
| 265 depfile = "$output_dir/${target_name}.d" | 281 depfile = "$output_dir/${grit_output_name}.d" |
| 266 | 282 |
| 267 args = [ | 283 args = [ |
| 268 "-i", source_path, "build", | 284 "-i", source_path, "build", |
| 269 "-f", resource_ids, | 285 "-f", resource_ids, |
| 270 "-o", rebased_output_dir, | 286 "-o", rebased_output_dir, |
| 271 "--depdir", ".", | 287 "--depdir", ".", |
| 272 "--depfile", rebase_path(depfile, root_build_dir), | 288 "--depfile", rebase_path(depfile, root_build_dir), |
| 273 ] + grit_defines | 289 ] + grit_defines |
| 274 | 290 |
| 275 # Add extra defines with -D flags. | 291 # Add extra defines with -D flags. |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 297 sources = grit_outputs | 313 sources = grit_outputs |
| 298 | 314 |
| 299 # Deps set on the template invocation will go on the grit script running | 315 # Deps set on the template invocation will go on the grit script running |
| 300 # target rather than this library. | 316 # target rather than this library. |
| 301 deps = [ ":$grit_custom_target" ] | 317 deps = [ ":$grit_custom_target" ] |
| 302 direct_dependent_configs = [ ":$grit_config" ] | 318 direct_dependent_configs = [ ":$grit_config" ] |
| 303 | 319 |
| 304 if (defined(invoker.visibility)) { | 320 if (defined(invoker.visibility)) { |
| 305 visibility = invoker.visibility | 321 visibility = invoker.visibility |
| 306 } | 322 } |
| 307 if (defined(invoker.output_name)) { | 323 output_name = grit_output_name |
| 308 output_name = invoker.output_name | |
| 309 } | |
| 310 } | 324 } |
| 311 } | 325 } |
| OLD | NEW |