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-Commit-Position: refs/heads/master@{#399633}
diff --git a/chrome/browser/BUILD.gn b/chrome/browser/BUILD.gn
index 3885324..2c62857 100644
--- a/chrome/browser/BUILD.gn
+++ b/chrome/browser/BUILD.gn
@@ -78,7 +78,20 @@
}
}
-source_set("browser") {
+# Use a static library here because many test binaries depend on this but don't
+# require many files from it. This makes linking more efficient. However, on
+# x64 official builds the static library will be too large (> 32-bits) so use
+# source sets in that case.
+if (is_mac || (current_cpu == "x64" && is_official_build)) {
+ # TODO(brettw) bug 618797: Remove the mac condition. On Mac making this
+ # target a static_library causes a crash on startup and the browser_tests all
+ # fail. My guess is this is due to a required static initializer not being
+ # brought in.
+ chrome_browser_target_type = "source_set"
+} else {
+ chrome_browser_target_type = "static_library"
+}
+target(chrome_browser_target_type, "browser") {
configs += [
"//build/config/compiler:wexit_time_destructors",
"//build/config:precompiled_headers",
@@ -1053,7 +1066,10 @@
}
# In GYP this is part of test_support_common.
-source_set("test_support") {
+#
+# Use a static library here because many test binaries depend on this but don't
+# require many files from it. This makes linking more efficient.
+static_library("test_support") {
testonly = true
# Always include this via the main test support target.