grit_args.gni 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. # Copyright 2020 The Chromium Authors. All rights reserved.
  2. # Use of this source code is governed by a BSD-style license that can be
  3. # found in the LICENSE file.
  4. import("//build/config/chrome_build.gni")
  5. import("//build/config/chromeos/ui_mode.gni")
  6. import("//build/config/devtools.gni")
  7. import("//build/config/ui.gni")
  8. shared_intermediate_dir = rebase_path(root_gen_dir, root_build_dir)
  9. devtools_grd_path = "$shared_intermediate_dir/$devtools_grd_location"
  10. devtools_grd_path_no_ext = get_path_info(devtools_grd_path, "dir") + "/" +
  11. get_path_info(devtools_grd_path, "name")
  12. # Prefer using this (and excluding specific platforms) when a resource applies
  13. # to (most) desktop platforms.
  14. assert(toolkit_views ==
  15. (is_chromeos || is_fuchsia || is_linux || is_mac || is_win))
  16. # Variables that are passed to grit with the -D flag.
  17. _grit_defines = [
  18. "DEVTOOLS_GRD_PATH=" + devtools_grd_path_no_ext,
  19. "SHARED_INTERMEDIATE_DIR=" + shared_intermediate_dir,
  20. "_google_chrome=${is_chrome_branded}",
  21. "chromeos_ash=${is_chromeos_ash}",
  22. "chromeos_lacros=${is_chromeos_lacros}",
  23. # This is related to Chrome OS.
  24. "reven=${is_reven}",
  25. "toolkit_views=${toolkit_views}",
  26. "use_aura=${use_aura}",
  27. "use_ozone=${use_ozone}",
  28. # Mac and iOS want Title Case strings.
  29. "use_titlecase=${is_apple}",
  30. ]
  31. # Must match `enable_hidpi` in ui/base/ui_features.gni.
  32. if (!is_android) {
  33. _grit_defines += [ "scale_factors=2x" ]
  34. }
  35. # Environment variables to be used by grit and its subproceses.
  36. _grit_environment_vars = [
  37. "root_gen_dir=" + rebase_path(root_gen_dir, root_build_dir),
  38. "root_src_dir=" + rebase_path("//", root_build_dir),
  39. ]
  40. if (is_chrome_branded) {
  41. _grit_environment_vars += [ "CHROMIUM_BUILD=google_chrome" ]
  42. } else {
  43. _grit_environment_vars += [ "CHROMIUM_BUILD=chromium" ]
  44. }
  45. if (is_android) {
  46. _grit_environment_vars += [ "ANDROID_JAVA_TAGGED_ONLY=true" ]
  47. }
  48. # Convert |_grit_defines| and |_grit_environment_vars| to command line flags.
  49. grit_args = []
  50. foreach(i, _grit_defines) {
  51. grit_args += [
  52. "-D",
  53. i,
  54. ]
  55. }
  56. foreach(i, _grit_environment_vars) {
  57. grit_args += [
  58. "-E",
  59. i,
  60. ]
  61. }
  62. # When cross-compiling, explicitly pass the target system to grit.
  63. # There's an exception for Chrome OS, as the toolchain can be the same
  64. # as linux, but the target platform still must be set.
  65. if (current_toolchain != host_toolchain || is_chromeos) {
  66. _target_platform = ""
  67. if (is_android) {
  68. _target_platform = "android"
  69. }
  70. if (is_fuchsia) {
  71. _target_platform = "fuchsia"
  72. }
  73. if (is_ios) {
  74. _target_platform = "ios"
  75. }
  76. if (is_linux) {
  77. _target_platform = "linux"
  78. }
  79. if (is_chromeos) {
  80. _target_platform = "chromeos"
  81. }
  82. if (is_mac) {
  83. _target_platform = "darwin"
  84. }
  85. if (is_win) {
  86. _target_platform = "win32"
  87. }
  88. if (_target_platform != "") {
  89. grit_args += [
  90. "-t",
  91. _target_platform,
  92. ]
  93. }
  94. }