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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 # ] | 75 # ] |
76 # | 76 # |
77 # grit_flags = [ "-E", "foo=bar" ] # Optional extra flags. | 77 # grit_flags = [ "-E", "foo=bar" ] # Optional extra flags. |
78 # # You can also put deps here if the grit source depends on generated | 78 # # You can also put deps here if the grit source depends on generated |
79 # # files. | 79 # # files. |
80 # } | 80 # } |
81 import("//build/config/chrome_build.gni") | 81 import("//build/config/chrome_build.gni") |
82 import("//build/config/crypto.gni") | 82 import("//build/config/crypto.gni") |
83 import("//build/config/features.gni") | 83 import("//build/config/features.gni") |
84 import("//build/config/ui.gni") | 84 import("//build/config/ui.gni") |
| 85 import("//third_party/closure_compiler/closure_args.gni") |
85 | 86 |
86 declare_args() { | 87 declare_args() { |
87 # Enables used resource whitelist generation. | 88 # Enables used resource whitelist generation. |
88 enable_resource_whitelist_generation = false | 89 enable_resource_whitelist_generation = false |
89 } | 90 } |
90 | 91 |
91 grit_defines = [] | 92 grit_defines = [] |
92 | 93 |
93 # Mac and iOS want Title Case strings. | 94 # Mac and iOS want Title Case strings. |
94 use_titlecase_in_grd_files = is_mac || is_ios | 95 use_titlecase_in_grd_files = is_mac || is_ios |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
293 "enable_service_discovery", | 294 "enable_service_discovery", |
294 ] | 295 ] |
295 } | 296 } |
296 if (mac_views_browser) { | 297 if (mac_views_browser) { |
297 grit_defines += [ | 298 grit_defines += [ |
298 "-D", | 299 "-D", |
299 "mac_views_browser", | 300 "mac_views_browser", |
300 ] | 301 ] |
301 } | 302 } |
302 | 303 |
| 304 # TODO(aberent): Enable for other platforms once the build machines have |
| 305 # Java on them (and hence can run the closure compiler). |
| 306 _strip_resource_files = is_android |
| 307 _js_minifier = "//third_party/closure_compiler/js_minify.py" |
| 308 |
303 grit_resource_id_file = "//tools/gritsettings/resource_ids" | 309 grit_resource_id_file = "//tools/gritsettings/resource_ids" |
304 grit_info_script = "//tools/grit/grit_info.py" | 310 grit_info_script = "//tools/grit/grit_info.py" |
305 | 311 |
306 template("grit") { | 312 template("grit") { |
307 assert(defined(invoker.source), | 313 assert(defined(invoker.source), |
308 "\"source\" must be defined for the grit template $target_name") | 314 "\"source\" must be defined for the grit template $target_name") |
309 | 315 |
310 grit_inputs = [ invoker.source ] | 316 grit_inputs = [ invoker.source ] |
311 | 317 |
312 if (defined(invoker.resource_ids)) { | 318 if (defined(invoker.resource_ids)) { |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
434 foreach(i, invoker.defines) { | 440 foreach(i, invoker.defines) { |
435 args += [ | 441 args += [ |
436 "-D", | 442 "-D", |
437 i, | 443 i, |
438 ] | 444 ] |
439 } | 445 } |
440 } | 446 } |
441 | 447 |
442 args += grit_flags + assert_files_flags | 448 args += grit_flags + assert_files_flags |
443 | 449 |
| 450 if (_strip_resource_files) { |
| 451 js_minifier_command = rebase_path(_js_minifier) |
| 452 js_minifier_command = "$js_minifier_command --closure_args" |
| 453 foreach(closure_arg, |
| 454 common_closure_args + minifying_closure_args + |
| 455 default_disabled_closure_args) { |
| 456 js_minifier_command = "$js_minifier_command $closure_arg" |
| 457 } |
| 458 args += [ |
| 459 "--js-minifier", |
| 460 js_minifier_command, |
| 461 ] |
| 462 inputs += [ _js_minifier ] |
| 463 } |
| 464 |
444 if (defined(invoker.visibility)) { | 465 if (defined(invoker.visibility)) { |
445 # This needs to include both what the invoker specified (since they | 466 # This needs to include both what the invoker specified (since they |
446 # probably include generated headers from this target), as well as the | 467 # probably include generated headers from this target), as well as the |
447 # generated source set (since there's no guarantee that the visibility | 468 # generated source set (since there's no guarantee that the visibility |
448 # specified by the invoker includes our target). | 469 # specified by the invoker includes our target). |
449 # | 470 # |
450 # Only define visibility at all if the invoker specified it. Otherwise, | 471 # Only define visibility at all if the invoker specified it. Otherwise, |
451 # we want to keep the public "no visibility specified" default. | 472 # we want to keep the public "no visibility specified" default. |
452 visibility = target_visibility + invoker.visibility | 473 visibility = target_visibility + invoker.visibility |
453 } | 474 } |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
486 if (defined(invoker.configs)) { | 507 if (defined(invoker.configs)) { |
487 configs += invoker.configs | 508 configs += invoker.configs |
488 } | 509 } |
489 | 510 |
490 if (defined(invoker.visibility)) { | 511 if (defined(invoker.visibility)) { |
491 visibility = invoker.visibility | 512 visibility = invoker.visibility |
492 } | 513 } |
493 output_name = grit_output_name | 514 output_name = grit_output_name |
494 } | 515 } |
495 } | 516 } |
OLD | NEW |