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

Unified Diff: base/BUILD.gn

Issue 1528233002: Make base a static ibrary (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years 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 | « no previous file | base/debug/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/BUILD.gn
diff --git a/base/BUILD.gn b/base/BUILD.gn
index 94c7a86104140110c63c165207da975fef54774e..90716ba43d1c162907a194bb40589ec9ad6eccc0 100644
--- a/base/BUILD.gn
+++ b/base/BUILD.gn
@@ -48,42 +48,58 @@ if (is_nacl_nonsfi) {
}
}
-source_set("base_paths") {
- sources = [
- "base_paths.cc",
- "base_paths.h",
- "base_paths_android.cc",
- "base_paths_android.h",
- "base_paths_mac.h",
- "base_paths_mac.mm",
- "base_paths_posix.cc",
- "base_paths_posix.h",
- "base_paths_win.cc",
- "base_paths_win.h",
- ]
-
- if (is_android || is_mac || is_ios) {
- sources -= [ "base_paths_posix.cc" ]
+if (is_nacl) {
+ # None of the files apply to nacl, and we can't make an empty static library.
+ group("base_paths") {
}
-
- if (is_nacl) {
- sources -= [
+} else {
+ static_library("base_paths") {
+ sources = [
"base_paths.cc",
+ "base_paths.h",
+ "base_paths_android.cc",
+ "base_paths_android.h",
+ "base_paths_mac.h",
+ "base_paths_mac.mm",
"base_paths_posix.cc",
+ "base_paths_posix.h",
+ "base_paths_win.cc",
+ "base_paths_win.h",
]
- }
- configs += [ ":base_implementation" ]
+ if (is_android || is_mac || is_ios) {
+ sources -= [ "base_paths_posix.cc" ]
+ }
- deps = [
- "//base/memory",
- "//base/process",
- ]
+ configs += [ ":base_implementation" ]
- visibility = [ ":base" ]
+ deps = [
+ "//base/memory",
+ "//base/process",
+ ]
+
+ visibility = [ ":base" ]
+ }
}
-component("base") {
+# Base and everything it depends on should be a static library rather than
+# a source set. Base is more of a "library" in the classic sense in that many
+# small parts of it are used in many different contexts. This combined with a
+# few static initializers floating around means that dead code stripping
+# still leaves a lot of code behind that isn't always used. For example, this
+# saves more than 40K for a smaller target like chrome_elf.
+#
+# Use static libraries for the helper stuff as well like //base/debug since
+# those things refer back to base code, which will force base compilation units
+# to be linked in where they wouldn't have otherwise. This does not include
+# test code (test support and anything in the test directory) which should use
+# source_set as is recommended for GN targets).
+if (is_component_build) {
+ base_target_type = "shared_library"
+} else {
+ base_target_type = "static_library"
+}
+target(base_target_type, "base") {
sources = [
"allocator/allocator_extension.cc",
"allocator/allocator_extension.h",
@@ -985,7 +1001,7 @@ component("base") {
# This is the subset of files from base that should not be used with a dynamic
# library. Note that this library cannot depend on base because base depends on
# base_static.
-source_set("base_static") {
+static_library("base_static") {
sources = [
"base_switches.cc",
"base_switches.h",
« no previous file with comments | « no previous file | base/debug/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698