blob: dbce402218331c5d969fca1c4e675819774e344e [file]
# Copyright 2018 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/cast.gni")
import("//build/config/chrome_build.gni")
import("//build/config/chromeos/args.gni")
import("//build/config/coverage/coverage.gni")
import("//build/config/sanitizers/sanitizers.gni")
import("//extensions/buildflags/buildflags.gni")
declare_args() {
# Optimize parts of Chrome's UI written with web technologies (HTML/CSS/JS)
# for runtime performance purposes. This does more work at compile time for
# speed benefits at runtime (so we skip in debug builds).
optimize_webui = !is_debug
# Whether to inline source maps during build. Cannot be enabled when
# `optimize_webui=true`.
enable_webui_inline_sourcemaps = use_javascript_coverage
# Flag used for loading WebUI files directly from disk instead of .pak files.
# It causes additional file path info for each file to be added into Grit
# generated '*_resource_map.cc' files during the build, which is then used at
# runtime to read such files.
# Meant to be used during local development only (requires a local checkout
# and build) with the runtime --load-webui-from-disk command line switch.
load_webui_from_disk = false
# Enable generation of compiled JS bytecode for opted-in WebUI scripts for
# compatible build configurations (see comment for the
# `enable_webui_generate_code_cache` update below).
enable_webui_generate_code_cache = true
# Enable the native TypeScript compiler (tsgo) instead of the JS-based one.
# TODO(crbug.com/423789047): Remove this flag once fully committed to v7.
use_typescript_go = true
}
if (enable_cast_receiver || is_cast_android || is_castos) {
enable_webui_bookmarks = false
enable_webui_history = false
enable_webui_ntp = false
enable_webui_contextual_tasks_composebox = false
} else {
declare_args() {
# Enable the WebUI version of the Bookmarks page.
enable_webui_bookmarks =
target_os == "win" || target_os == "mac" || target_os == "linux" ||
target_os == "chromeos" || is_desktop_android
# Enable the WebUI version of the History page.
enable_webui_history =
target_os == "win" || target_os == "mac" || target_os == "linux" ||
target_os == "chromeos" || is_desktop_android
# Enable the WebUI version of the New Tab Page.
enable_webui_ntp =
target_os == "win" || target_os == "mac" || target_os == "linux" ||
target_os == "chromeos" || is_desktop_android
}
declare_args() {
# Enable WebUI Contextual Tasks Composebox.
# TODO(crbug.com/527601593): Revert to only enable for desktop_android if we
# want to disable composebox on Android phones.
enable_webui_contextual_tasks_composebox = enable_webui_ntp || is_android
}
if (enable_webui_ntp) {
# NTP relies on chrome.metricsPrivate, which is an extensions API.
assert(enable_extensions_core)
}
}
# Build-time WebUI code caching is only used in optimize_webui builds. When the
# host and current toolchains are the same there are issues instrumenting the
# code_cache_generator msan binaries, see crbug.com/40055221#comment17.
# Mac builds on Mac hosts generate the cache for either target CPU, including
# the x64 half of a universal build cross-compiled on an arm64 host. The
# generator runs from the V8 snapshot toolchain, which already builds Blink
# for v8_context_snapshot_generator there, and loads the target's snapshot.
# Mac builds on Linux hosts stay off: they skip the context snapshot to avoid
# building Blink twice (see v8_context_snapshot.gni), and the generator would
# bring that cost back. 64-bit ChromeOS device builds generate the cache from
# cros:v8_snapshot using the target's snapshot_blob.bin. See
# //tools/code_cache_generator/README.md.
# TODO(crbug.com/399764218): Enable this build-step on 32-bit ChromeOS device
# builds and other cross-compiled builds.
if (enable_webui_generate_code_cache) {
enable_webui_generate_code_cache =
optimize_webui && !is_msan &&
((host_toolchain == current_toolchain &&
(is_linux || is_chromeos || is_win)) ||
(is_chromeos && is_chromeos_device &&
current_toolchain == default_toolchain &&
(current_cpu == "x64" || current_cpu == "arm64")) ||
(is_mac && host_os == "mac" && current_toolchain == default_toolchain))
}
# The generated code cache is only valid for the V8 snapshot of the target
# architecture. Universal Mac builds merge x64 and arm64 builds into one bundle
# that shares a single resources.pak, so on Mac the cache ships in its own
# per-architecture pak, named like v8_context_snapshot.<arch>.bin.
webui_code_cache_pak_filename = ""
if (is_mac && enable_webui_generate_code_cache) {
if (current_cpu == "x64") {
webui_code_cache_pak_filename = "webui_code_cache.x86_64.pak"
} else if (current_cpu == "arm64") {
webui_code_cache_pak_filename = "webui_code_cache.arm64.pak"
} else {
assert(false, "Unsupported Mac CPU for the WebUI code cache pak")
}
}
if (load_webui_from_disk) {
assert(is_linux || is_mac || is_win || is_chromeos,
"load_webui_from_disk not available")
}