Index: build/secondary/tools/grit/grit_rule.gni |
diff --git a/build/secondary/tools/grit/grit_rule.gni b/build/secondary/tools/grit/grit_rule.gni |
index a5cf81a67568c6f40a10bfbd1c7e3fb8feafa662..083e3d93e437b8c73b8690ebba73feb43a34e858 100644 |
--- a/build/secondary/tools/grit/grit_rule.gni |
+++ b/build/secondary/tools/grit/grit_rule.gni |
@@ -83,6 +83,11 @@ import("//build/config/crypto.gni") |
import("//build/config/features.gni") |
import("//build/config/ui.gni") |
+declare_args() { |
+ # Enables used resource whitelist generation. |
+ enable_resource_whitelist_generation = false |
+} |
+ |
grit_defines = [] |
# Mac and iOS want Title Case strings. |
@@ -335,10 +340,17 @@ template("grit") { |
rebased_output_dir = rebase_path(output_dir, root_build_dir) |
source_path = rebase_path(invoker.source, root_build_dir) |
+ grit_flags = [] |
+ if (enable_resource_whitelist_generation) { |
+ grit_flags += [ "-h" ] |
+ if (is_win) { |
+ grit_flags += [ "#define {textual_id} __pragma(message(\"whitelisted_resource_{numeric_id}\")) {numeric_id}" ] |
+ } else { |
+ grit_flags += [ "#define {textual_id} _Pragma(\"whitelisted_resource_{numeric_id}\") {numeric_id}" ] |
+ } |
+ } |
if (defined(invoker.grit_flags)) { |
- grit_flags = invoker.grit_flags |
- } else { |
- grit_flags = [] # These are optional so default to empty list. |
+ grit_flags += invoker.grit_flags |
} |
assert_files_flags = [] |
@@ -371,6 +383,13 @@ template("grit") { |
!invoker.use_qualified_include) { |
include_dirs = [ output_dir ] |
} |
+ |
+ if ((is_linux || is_android) && enable_resource_whitelist_generation) { |
+ cflags = [ |
+ "-Wunknown-pragmas", |
+ "-Wno-error=unknown-pragmas", |
+ ] |
+ } |
visibility = target_visibility |
} |