Default components to static libraries in GN build
Previously components would be source sets in non-component mode. Some test targets link large components in chrome but use almost none of them, and including all object files makes these links very slow. Reland of https://codereview.chromium.org/2043873004/ and https://codereview.chromium.org/2063483002 but disabled for official Windows builds. In support of the official condition, is_official_build moved to BUILDCONFIG. Since this is really a different level of debug/release, this may actually make more sense. The documentation around this was enhanced a lot, official now automatically turns off debug, and it will assert if you override both to produce an official debug build. BUG=617837 Review-Url: https://codereview.chromium.org/2060983002 Cr-Original-Commit-Position: refs/heads/master@{#399633} Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src Cr-Mirrored-Commit: 022f8f346d72007cf75469299f894ad4edfda5a8
This commit is contained in:
Родитель
6dcbdfeae8
Коммит
ad3d3c9e01
|
@ -111,11 +111,20 @@ if (current_os == "") {
|
|||
# even if the value is overridden, which is wasteful. See first bullet.
|
||||
|
||||
declare_args() {
|
||||
# Component build.
|
||||
# Component build. Setting to true compiles targets declared as "components"
|
||||
# as shared libraries loaded dynamically. This speeds up development time.
|
||||
# When false, components will be linked statically.
|
||||
is_component_build = false
|
||||
|
||||
# Debug build.
|
||||
is_debug = true
|
||||
# Set to enable the official build level of optimization. This has nothing
|
||||
# to do with branding, but enables an additional level of optimization above
|
||||
# release (!is_debug). This might be better expressed as a tri-state
|
||||
# (debug, release, official) but for historical reasons there are two
|
||||
# separate flags.
|
||||
is_official_build = false
|
||||
|
||||
# Debug build. Enabling official builds automatically sets is_debug to false.
|
||||
is_debug = !is_official_build
|
||||
|
||||
# Whether we're a traditional desktop unix.
|
||||
is_desktop_linux = current_os == "linux"
|
||||
|
@ -136,6 +145,8 @@ declare_args() {
|
|||
# DON'T ADD MORE FLAGS HERE. Read the comment above.
|
||||
}
|
||||
|
||||
assert(!(is_debug && is_official_build), "Can't do official debug builds")
|
||||
|
||||
# ==============================================================================
|
||||
# TOOLCHAIN SETUP
|
||||
# ==============================================================================
|
||||
|
@ -596,23 +607,38 @@ set_defaults("test") {
|
|||
# ==============================================================================
|
||||
|
||||
# Defines a component, which equates to a shared_library when
|
||||
# is_component_build == true and a source_set / static_library otherwise.
|
||||
# is_component_build == true and a static_library otherwise.
|
||||
#
|
||||
# Arguments are the same as a normal library with this addition:
|
||||
# component_never_use_source_set: Whether to use static_library instead of
|
||||
# source_set for non-component builds. Some targets (e.g. //base) should
|
||||
# use static_library rather than source_set to avoid linking unused object
|
||||
# files.
|
||||
# Use static libraries for the static build rather than source sets because
|
||||
# many of of our test binaries link many large dependencies but often don't
|
||||
# use large portions of them. The static libraries are much more efficient to
|
||||
# link in this situation since only the necessary object files are linked.
|
||||
#
|
||||
# The invoker can override the type of the target in the non-component-build
|
||||
# case by setting static_component_type to either "source_set" or
|
||||
# "static_library". If unset, the default will be used.
|
||||
template("component") {
|
||||
_never_use_source_set = defined(invoker.component_never_use_source_set) &&
|
||||
invoker.component_never_use_source_set
|
||||
assert(_never_use_source_set || true) # Mark as used.
|
||||
if (is_component_build) {
|
||||
_component_mode = "shared_library"
|
||||
} else if (_never_use_source_set) {
|
||||
_component_mode = "static_library"
|
||||
} else {
|
||||
} else if (defined(invoker.static_component_type)) {
|
||||
assert(invoker.static_component_type == "static_library" ||
|
||||
invoker.static_component_type == "source_set")
|
||||
_component_mode = invoker.static_component_type
|
||||
} else if (!defined(invoker.sources) || is_mac ||
|
||||
(is_win && is_official_build)) {
|
||||
# When there are no sources defined, use a source set to avoid creating
|
||||
# an empty static library (which generally don't work).
|
||||
#
|
||||
# On Windows official builds, the link time code generation bloats static
|
||||
# libraries to the point where some of them become >32 bits large which
|
||||
# causes lib.exe to fail. Always use source sets for that configuration.
|
||||
#
|
||||
# TODO(brettw) bug 618797: Remove the mac condition. On Mac making these as
|
||||
# static_library causes crashes. Remove the mac condition above when this
|
||||
# is fixed.
|
||||
_component_mode = "source_set"
|
||||
} else {
|
||||
_component_mode = "static_library"
|
||||
}
|
||||
target(_component_mode, target_name) {
|
||||
# Explicitly forward visibility, implicitly forward everything else.
|
||||
|
|
|
@ -3,11 +3,6 @@
|
|||
# found in the LICENSE file.
|
||||
|
||||
declare_args() {
|
||||
# Selects the desired build flavor. Official builds get additional
|
||||
# processing to prepare for release. Normally you will want to develop and
|
||||
# test with this flag off.
|
||||
is_official_build = false
|
||||
|
||||
# Select the desired branding flavor. False means normal Chromium branding,
|
||||
# true means official Google Chrome branding (requires extra Google-internal
|
||||
# resources).
|
||||
|
|
Загрузка…
Ссылка в новой задаче