summaryrefslogtreecommitdiff
path: root/chromium/tools/grit/grit_args.gni
blob: b3485588af257f8817cec8e0f4306ab41247b1f8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# Copyright 2020 The Chromium Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import("//build/config/chrome_build.gni")
import("//build/config/chromeos/ui_mode.gni")
import("//build/config/devtools.gni")
import("//build/config/ui.gni")

shared_intermediate_dir = rebase_path(root_gen_dir, root_build_dir)
devtools_grd_path = "$shared_intermediate_dir/$devtools_grd_location"
devtools_grd_path_no_ext = get_path_info(devtools_grd_path, "dir") + "/" +
                           get_path_info(devtools_grd_path, "name")

# Prefer using this (and excluding specific platforms) when a resource applies
# to (most) desktop platforms.
#assert(toolkit_views ==
#       (is_chromeos || is_fuchsia || is_linux || is_mac || is_win))

# Variables that are passed to grit with the -D flag.

_grit_defines = [
  "DEVTOOLS_GRD_PATH=" + devtools_grd_path_no_ext,
  "SHARED_INTERMEDIATE_DIR=" + shared_intermediate_dir,
  "_google_chrome=${is_chrome_branded}",
  "_google_chrome_for_testing=${is_chrome_for_testing_branded}",
  "chromeos_ash=${is_chromeos_ash}",
  "chromeos_lacros=${is_chromeos_lacros}",

  # This is related to Chrome OS.
  "reven=${is_reven}",

  "toolkit_views=${toolkit_views}",
  "use_aura=${use_aura}",
  "use_ozone=${use_ozone}",

  # Mac and iOS want Title Case strings.
  "use_titlecase=${is_apple}",
]

# Must match `enable_hidpi` in ui/base/ui_features.gni.
if (!is_android) {
  _grit_defines += [ "scale_factors=2x" ]
}

# Environment variables to be used by grit and its subproceses.

_grit_environment_vars = [
  "root_gen_dir=" + rebase_path(root_gen_dir, root_build_dir),
  "root_src_dir=" + rebase_path("//", root_build_dir),
]

if (is_chrome_branded) {
  _grit_environment_vars += [ "CHROMIUM_BUILD=google_chrome" ]
} else {
  _grit_environment_vars += [ "CHROMIUM_BUILD=chromium" ]
}

if (is_android) {
  _grit_environment_vars += [ "ANDROID_JAVA_TAGGED_ONLY=true" ]
}

# Convert |_grit_defines| and |_grit_environment_vars| to command line flags.
grit_args = []
foreach(i, _grit_defines) {
  grit_args += [
    "-D",
    i,
  ]
}
foreach(i, _grit_environment_vars) {
  grit_args += [
    "-E",
    i,
  ]
}

# When cross-compiling, explicitly pass the target system to grit.
# There's an exception for Chrome OS, as the toolchain can be the same
# as linux, but the target platform still must be set.
if (current_toolchain != host_toolchain || is_chromeos) {
  _target_platform = ""

  if (is_android) {
    _target_platform = "android"
  }
  if (is_fuchsia) {
    _target_platform = "fuchsia"
  }
  if (is_ios) {
    _target_platform = "ios"
  }
  if (is_linux) {
    _target_platform = "linux"
  }
  if (is_chromeos) {
    _target_platform = "chromeos"
  }
  if (is_mac) {
    _target_platform = "darwin"
  }
  if (is_win) {
    _target_platform = "win32"
  }

  if (_target_platform != "") {
    grit_args += [
      "-t",
      _target_platform,
    ]
  }
}