| 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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 | 85 |
| 86 declare_args() { |
| 87 # Enables used resource whitelist generation. |
| 88 enable_resource_whitelist_generation = false |
| 89 } |
| 90 |
| 86 grit_defines = [] | 91 grit_defines = [] |
| 87 | 92 |
| 88 # Mac and iOS want Title Case strings. | 93 # Mac and iOS want Title Case strings. |
| 89 use_titlecase_in_grd_files = is_mac || is_ios | 94 use_titlecase_in_grd_files = is_mac || is_ios |
| 90 if (use_titlecase_in_grd_files) { | 95 if (use_titlecase_in_grd_files) { |
| 91 grit_defines += [ | 96 grit_defines += [ |
| 92 "-D", | 97 "-D", |
| 93 "use_titlecase", | 98 "use_titlecase", |
| 94 ] | 99 ] |
| 95 } | 100 } |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 328 } | 333 } |
| 329 | 334 |
| 330 # These are all passed as arguments to the script so have to be relative to | 335 # These are all passed as arguments to the script so have to be relative to |
| 331 # the build directory. | 336 # the build directory. |
| 332 if (resource_ids != "") { | 337 if (resource_ids != "") { |
| 333 resource_ids = rebase_path(resource_ids, root_build_dir) | 338 resource_ids = rebase_path(resource_ids, root_build_dir) |
| 334 } | 339 } |
| 335 rebased_output_dir = rebase_path(output_dir, root_build_dir) | 340 rebased_output_dir = rebase_path(output_dir, root_build_dir) |
| 336 source_path = rebase_path(invoker.source, root_build_dir) | 341 source_path = rebase_path(invoker.source, root_build_dir) |
| 337 | 342 |
| 343 grit_flags = [] |
| 344 if (enable_resource_whitelist_generation) { |
| 345 grit_flags += [ "-h" ] |
| 346 if (is_win) { |
| 347 grit_flags += [ "#define {textual_id} __pragma(message(\"whitelisted_resou
rce_{numeric_id}\")) {numeric_id}" ] |
| 348 } else { |
| 349 grit_flags += [ "#define {textual_id} _Pragma(\"whitelisted_resource_{nume
ric_id}\") {numeric_id}" ] |
| 350 } |
| 351 } |
| 338 if (defined(invoker.grit_flags)) { | 352 if (defined(invoker.grit_flags)) { |
| 339 grit_flags = invoker.grit_flags | 353 grit_flags += invoker.grit_flags |
| 340 } else { | |
| 341 grit_flags = [] # These are optional so default to empty list. | |
| 342 } | 354 } |
| 343 | 355 |
| 344 assert_files_flags = [] | 356 assert_files_flags = [] |
| 345 | 357 |
| 346 # We want to make sure the declared outputs actually match what Grit is | 358 # We want to make sure the declared outputs actually match what Grit is |
| 347 # writing. We write the list to a file (some of the output lists are long | 359 # writing. We write the list to a file (some of the output lists are long |
| 348 # enough to not fit on a Windows command line) and ask Grit to verify those | 360 # enough to not fit on a Windows command line) and ask Grit to verify those |
| 349 # are the actual outputs at runtime. | 361 # are the actual outputs at runtime. |
| 350 asserted_list_file = | 362 asserted_list_file = |
| 351 "$target_out_dir/${grit_output_name}_expected_outputs.txt" | 363 "$target_out_dir/${grit_output_name}_expected_outputs.txt" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 364 # The current grit setup makes an file in $output_dir/grit/foo.h that | 376 # The current grit setup makes an file in $output_dir/grit/foo.h that |
| 365 # the source code expects to include via "grit/foo.h". It would be nice to | 377 # the source code expects to include via "grit/foo.h". It would be nice to |
| 366 # change this to including absolute paths relative to the root gen directory | 378 # change this to including absolute paths relative to the root gen directory |
| 367 # (like "mycomponent/foo.h"). This config sets up the include path. | 379 # (like "mycomponent/foo.h"). This config sets up the include path. |
| 368 grit_config = target_name + "_grit_config" | 380 grit_config = target_name + "_grit_config" |
| 369 config(grit_config) { | 381 config(grit_config) { |
| 370 if (!defined(invoker.use_qualified_include) || | 382 if (!defined(invoker.use_qualified_include) || |
| 371 !invoker.use_qualified_include) { | 383 !invoker.use_qualified_include) { |
| 372 include_dirs = [ output_dir ] | 384 include_dirs = [ output_dir ] |
| 373 } | 385 } |
| 386 |
| 387 if ((is_linux || is_android) && enable_resource_whitelist_generation) { |
| 388 cflags = [ |
| 389 "-Wunknown-pragmas", |
| 390 "-Wno-error=unknown-pragmas", |
| 391 ] |
| 392 } |
| 374 visibility = target_visibility | 393 visibility = target_visibility |
| 375 } | 394 } |
| 376 | 395 |
| 377 grit_custom_target = target_name + "_grit" | 396 grit_custom_target = target_name + "_grit" |
| 378 action(grit_custom_target) { | 397 action(grit_custom_target) { |
| 379 script = "//tools/grit/grit.py" | 398 script = "//tools/grit/grit.py" |
| 380 inputs = grit_inputs | 399 inputs = grit_inputs |
| 381 | 400 |
| 382 depfile = "$depfile_dir/${grit_output_name}_stamp.d" | 401 depfile = "$depfile_dir/${grit_output_name}_stamp.d" |
| 383 outputs = [ "${depfile}.stamp" ] + grit_outputs | 402 outputs = [ "${depfile}.stamp" ] + grit_outputs |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 461 if (defined(invoker.configs)) { | 480 if (defined(invoker.configs)) { |
| 462 configs += invoker.configs | 481 configs += invoker.configs |
| 463 } | 482 } |
| 464 | 483 |
| 465 if (defined(invoker.visibility)) { | 484 if (defined(invoker.visibility)) { |
| 466 visibility = invoker.visibility | 485 visibility = invoker.visibility |
| 467 } | 486 } |
| 468 output_name = grit_output_name | 487 output_name = grit_output_name |
| 469 } | 488 } |
| 470 } | 489 } |
| OLD | NEW |