Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1936)

Unified Diff: build/config/BUILDCONFIG.gn

Issue 2043873004: Default components to static libraries in GN build (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: no vpx hack Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/BUILD.gn ('k') | chrome/browser/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/config/BUILDCONFIG.gn
diff --git a/build/config/BUILDCONFIG.gn b/build/config/BUILDCONFIG.gn
index a55a56582fb4912befa3719d03e1fc7a9fb1c489..c5632550252a8999f40091b1ccff2b75629b72c4 100644
--- a/build/config/BUILDCONFIG.gn
+++ b/build/config/BUILDCONFIG.gn
@@ -596,23 +596,32 @@ 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) {
+ # When there are no sources defined, use a source set to avoid creating
+ # an empty static library (which generally don't work).
+ #
+ # TODO(brettw) bug 618797: 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.
« no previous file with comments | « base/BUILD.gn ('k') | chrome/browser/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698