OLD | NEW |
1 # Copyright 2017 The Chromium Authors. All rights reserved. | 1 # Copyright 2017 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 import("//build/split_static_library.gni") # When someone uses that target_type | 5 import("//build/split_static_library.gni") # When someone uses that target_type |
6 | 6 |
7 declare_args() { | 7 declare_args() { |
8 # If true, use a jumbo build (files compiled together) to speed up | 8 # If true, use a jumbo build (files compiled together) to speed up |
9 # compilation. | 9 # compilation. |
10 use_jumbo_build = false | 10 use_jumbo_build = false |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 foreach(source_file, invoker.sources) { | 79 foreach(source_file, invoker.sources) { |
80 if (current_file_index == next_chunk_start) { | 80 if (current_file_index == next_chunk_start) { |
81 jumbo_files += [ "$gen_target_dir/" + target_name + "_jumbo_" + | 81 jumbo_files += [ "$gen_target_dir/" + target_name + "_jumbo_" + |
82 next_chunk_number + ".cc" ] | 82 next_chunk_number + ".cc" ] |
83 next_chunk_number += 1 | 83 next_chunk_number += 1 |
84 next_chunk_start += files_per_chunk | 84 next_chunk_start += files_per_chunk |
85 } | 85 } |
86 current_file_index += 1 | 86 current_file_index += 1 |
87 } | 87 } |
88 | 88 |
| 89 has_objective_c_file = false |
| 90 has_c_file = false |
| 91 foreach(source_file, invoker.sources) { |
| 92 source_ext = get_path_info(source_file, "extension") |
| 93 if (source_ext == "c") { |
| 94 has_c_file = true |
| 95 } else if (source_ext == "mm") { |
| 96 has_objective_c_file = true |
| 97 } |
| 98 } |
| 99 if (has_c_file) { |
| 100 jumbo_files += [ "$gen_target_dir/" + target_name + "_jumbo_c.c" ] |
| 101 } |
| 102 if (has_objective_c_file) { |
| 103 jumbo_files += [ "$gen_target_dir/" + target_name + "_jumbo_mm.mm" ] |
| 104 } |
| 105 |
89 merge_action_name = target_name + "__jumbo_merge" | 106 merge_action_name = target_name + "__jumbo_merge" |
90 | 107 |
91 # Create an action that calls a script that merges all the source files. | 108 # Create an action that calls a script that merges all the source files. |
92 action(merge_action_name) { | 109 action(merge_action_name) { |
93 script = "//build/config/merge_for_jumbo.py" | 110 script = "//build/config/merge_for_jumbo.py" |
94 response_file_contents = | 111 response_file_contents = |
95 rebase_path(invoker.sources - excluded_sources, gen_target_dir) | 112 rebase_path(invoker.sources - excluded_sources, gen_target_dir) |
96 outputs = jumbo_files | 113 outputs = jumbo_files |
97 args = [ "--outputs" ] + rebase_path(outputs, root_build_dir) + | 114 args = [ "--outputs" ] + rebase_path(outputs, root_build_dir) + |
98 [ "--file-list={{response_file_name}}" ] | 115 [ "--file-list={{response_file_name}}" ] |
(...skipping 19 matching lines...) Expand all Loading... |
118 | 135 |
119 # Take everything else not handled above from the invoker. | 136 # Take everything else not handled above from the invoker. |
120 variables_to_not_forward = [ "deps" ] | 137 variables_to_not_forward = [ "deps" ] |
121 if (use_jumbo_build_for_target) { | 138 if (use_jumbo_build_for_target) { |
122 deps += [ ":" + merge_action_name ] | 139 deps += [ ":" + merge_action_name ] |
123 variables_to_not_forward += [ "sources" ] | 140 variables_to_not_forward += [ "sources" ] |
124 assert(jumbo_files != []) | 141 assert(jumbo_files != []) |
125 sources = jumbo_files + excluded_sources | 142 sources = jumbo_files + excluded_sources |
126 | 143 |
127 # Need to keep the headers in sources so that dependency checks | 144 # Need to keep the headers in sources so that dependency checks |
128 # work, and we need to keep Objective-C code since they | 145 # work. |
129 # cannot be merged into a cc file (FIXME). | |
130 foreach(source_file, invoker.sources) { | 146 foreach(source_file, invoker.sources) { |
131 source_ext = get_path_info(source_file, "extension") | 147 if (get_path_info(source_file, "extension") == "h") { |
132 if (source_ext == "h" || source_ext == "mm") { | |
133 sources += [ source_file ] | 148 sources += [ source_file ] |
134 } | 149 } |
135 } | 150 } |
136 } | 151 } |
137 forward_variables_from(invoker, "*", variables_to_not_forward) | 152 forward_variables_from(invoker, "*", variables_to_not_forward) |
138 } | 153 } |
139 } | 154 } |
140 | 155 |
141 set_defaults("jumbo_target") { | 156 set_defaults("jumbo_target") { |
142 # This sets the default list of configs when the content_source_set target | 157 # This sets the default list of configs when the content_source_set target |
143 # is defined. The default_compiler_configs comes from BUILDCONFIG.gn and | 158 # is defined. The default_compiler_configs comes from BUILDCONFIG.gn and |
144 # is the list normally applied to static libraries and source sets. | 159 # is the list normally applied to static libraries and source sets. |
145 configs = default_compiler_configs | 160 configs = default_compiler_configs |
146 } | 161 } |
OLD | NEW |