[M73 Dev][EFL] Fix errors to generate ninja files
[platform/framework/web/chromium-efl.git] / build / split_static_library.gni
1 # Copyright 2016 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
4
5 import("//build/config/compiler/compiler.gni")
6
7 template("split_static_library") {
8   assert(defined(invoker.split_count),
9          "Must define split_count for split_static_library")
10
11   # In many conditions the number of inputs will be 1 (because the
12   # count will be conditional on platform or configuration) and for
13   # some build configurations it's unnecessary to split libraries
14   # since the tooling will never create files of a problematic size.
15   if (invoker.split_count == 1 || use_lld) {
16     static_library(target_name) {
17       forward_variables_from(invoker, "*")
18     }
19   } else {
20     group_name = target_name
21
22     generated_static_libraries = []
23     current_library_index = 0
24     foreach(current_sources, split_list(invoker.sources, invoker.split_count)) {
25       current_name = "${target_name}_$current_library_index"
26       assert(
27           current_sources != [],
28           "Your values for splitting a static library generate one that has no sources.")
29       generated_static_libraries += [ ":$current_name" ]
30
31       static_library(current_name) {
32         # Generated static library shard gets everything but sources (which
33         # we're redefining) and visibility (which is set to be the group
34         # below).
35         forward_variables_from(invoker,
36                                "*",
37                                [
38                                  "check_includes",
39                                  "sources",
40                                  "visibility",
41                                ])
42         sources = current_sources
43         visibility = [ ":$group_name" ]
44
45         # When splitting a target's sources up into a series of static
46         # libraries, those targets will naturally include headers from each
47         # other arbitrarily. We could theoretically generate a web of
48         # dependencies and allow_circular_includes_from between all pairs of
49         # targets, but that's very cumbersome. Typical usage in Chrome is that
50         # only official Windows builds use split static libraries due to the
51         # Visual Studio size limits, and this means we'll still get header
52         # checking coverage for the other configurations.
53         check_includes = false
54
55         # Uniquify the output name if one is specified.
56         if (defined(invoker.output_name)) {
57           output_name = "${invoker.output_name}_$current_library_index"
58         }
59       }
60
61       current_library_index = current_library_index + 1
62     }
63
64     group(group_name) {
65       public_deps = generated_static_libraries
66       forward_variables_from(invoker,
67                              [
68                                "testonly",
69                                "visibility",
70                              ])
71     }
72   }
73 }
74
75 if (!use_efl) {
76   set_defaults("split_static_library") {
77     configs = default_compiler_configs
78   }
79 }