blob: 92be15a41a034e28d50e87fdcebbc37faf966436 [file] [log] [blame]
# Copyright 2020 The Chromium Authors. All rights reserved.
# 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_ash || is_chromeos_lacros || 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}",
"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.
if (current_toolchain != host_toolchain) {
_target_platform = ""
if (is_android) {
_target_platform = "android"
}
if (is_fuchsia) {
_target_platform = "fuchsia"
}
if (is_ios) {
_target_platform = "ios"
}
if (is_linux || is_chromeos) {
_target_platform = "linux"
}
if (is_mac) {
_target_platform = "darwin"
}
if (is_win) {
_target_platform = "win32"
}
if (_target_platform != "") {
grit_args += [
"-t",
_target_platform,
]
}
}