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

Unified Diff: build/split_static_library.gni

Issue 2105513002: Use split_static_library in GN build. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@split_list
Patch Set: merge 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 | « build/config/BUILDCONFIG.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/split_static_library.gni
diff --git a/build/split_static_library.gni b/build/split_static_library.gni
new file mode 100644
index 0000000000000000000000000000000000000000..68718acccee2b677f958f1a4a2c5cf1784bbba30
--- /dev/null
+++ b/build/split_static_library.gni
@@ -0,0 +1,53 @@
+# Copyright 2016 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+template("split_static_library") {
+ assert(defined(invoker.split_count),
+ "Must define split_count for split_static_library")
+
+ # In many conditions the number of inputs will be 1 (because the count will
+ # be conditional on platform or configuration) so optimize that.
+ if (invoker.split_count == 1) {
+ static_library(target_name) {
+ forward_variables_from(invoker, "*")
+ }
+ } else {
+ group_name = target_name
+
+ generated_static_libraries = []
+ current_library_index = 0
+ foreach(current_sources, split_list(invoker.sources, invoker.split_count)) {
+ current_name = "${target_name}_$current_library_index"
+ assert(
+ current_sources != [],
+ "Your values for splitting a static library generate one that has no sources.")
+ generated_static_libraries += [ ":$current_name" ]
+
+ static_library(current_name) {
+ # Generated static library shard gets everything but sources (which
+ # we're redefining) and visibility (which is set to be the group
+ # below).
+ forward_variables_from(invoker,
+ "*",
+ [
+ "sources",
+ "visibility",
+ ])
+ sources = current_sources
+ visibility = [ ":$group_name" ]
+ }
+
+ current_library_index = current_library_index + 1
+ }
+
+ group(group_name) {
+ public_deps = generated_static_libraries
+ forward_variables_from(invoker,
+ [
+ "testonly",
+ "visibility",
+ ])
+ }
+ }
+}
« no previous file with comments | « build/config/BUILDCONFIG.gn ('k') | chrome/browser/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698