| 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 import("//testing/test.gni") # When someone uses the test target_type |
| 6 | 7 |
| 7 declare_args() { | 8 declare_args() { |
| 8 # If true, use a jumbo build (files compiled together) to speed up | 9 # If true, use a jumbo build (files compiled together) to speed up |
| 9 # compilation. | 10 # compilation. Enabled by default for everything official builds and |
| 10 use_jumbo_build = false | 11 # Android+gcc builds because of a warning that prevents builds. |
| 12 use_jumbo_build = !is_official_build && !(is_android && !is_clang) |
| 11 | 13 |
| 12 # A target to exclude from jumbo builds, for optimal round trip time | 14 # A target to exclude from jumbo builds, for optimal round trip time |
| 13 # when frequently changing a single cpp file. | 15 # when frequently changing a single cpp file. |
| 14 jumbo_build_excluded = "" | 16 jumbo_build_excluded = "" |
| 15 | 17 |
| 16 # How many files to group at most. Smaller numbers give more | 18 # How many files to group at most. Smaller numbers give more |
| 17 # parallellism, higher numbers give less total CPU usage. Higher | 19 # parallellism, higher numbers give less total CPU usage. Higher |
| 18 # numbers also give longer single-file recompilation times. | 20 # numbers also give longer single-file recompilation times. |
| 19 # | 21 # |
| 20 # Recommendations: | 22 # Recommendations: |
| 21 # Higher numbers than 200 does not reduce wall clock compile times | 23 # Higher numbers than 200 does not reduce wall clock compile times |
| 22 # for 4 cores or less. | 24 # even for 4 cores or less so no reason to go (much) higher than 200. |
| 23 # 200 uses 8% less total CPU than 100 when compiling content and 10% | 25 # 200 uses 8% less total CPU than 100 when compiling content and 10% |
| 24 # less wall clock when compiling with 4 cores. | 26 # less wall clock when compiling with 4 cores but content is extreme so |
| 27 # the total negative effect of 100 is smaller. |
| 25 jumbo_file_merge_limit = 200 | 28 jumbo_file_merge_limit = 200 |
| 26 } | 29 } |
| 27 | 30 |
| 28 # Use one of the targets jumbo_target or jumbo_component to generate a | 31 # Use one of the targets jumbo_target or jumbo_component to generate a |
| 29 # target which merges sources if possible to compile much faster. | 32 # target which merges sources if possible to compile much faster. |
| 30 # | 33 # |
| 31 # Special values. | 34 # Special values. |
| 32 # | 35 # |
| 33 # target_type | 36 # target_type |
| 34 # The kind of target to build. For example the string | 37 # The kind of target to build. For example the string |
| 35 # "static_library". | 38 # "static_library". |
| 36 # | 39 # |
| 37 # always_build_jumbo | 40 # always_build_jumbo |
| 38 # If set and set to true, then use jumbo compile even when it is | 41 # If set and set to true, then use jumbo compile even when it is |
| 39 # globally disabled. Otherwise it has no effect. | 42 # globally disabled. Otherwise it has no effect. |
| 40 # | 43 # |
| 41 # never_build_jumbo | 44 # never_build_jumbo |
| 42 # If set and set to true, then do not jumbo compile even if it is | 45 # If set and set to true, then do not jumbo compile even if it is |
| 43 # globally enabled. Otherwise it has no effect. | 46 # globally enabled. Otherwise it has no effect. |
| 44 # | 47 # |
| 45 # jumbo_excluded_sources | 48 # jumbo_excluded_sources |
| 46 # If set to a list of files, those files will not be merged with | 49 # If set to a list of files, those files will not be merged with |
| 47 # the rest. This can be necessary if merging the files causes | 50 # the rest. This can be necessary if merging the files causes |
| 48 # compilation issues and fixing the issues is impractical. | 51 # compilation issues and fixing the issues is impractical. |
| 52 # |
| 53 # jumbo_gen_dir |
| 54 # If set, this overrides the default location for the generated |
| 55 # jumbo files. This can be needed if the default location is too |
| 56 # deep for the build tools. By default the location is based on |
| 57 # the first file in sources. (Might not be neeeded one Chromium |
| 58 # has the fix for |
| 59 # https://github.com/ninja-build/ninja/issues/1161. |
| 49 template("internal_jumbo_target") { | 60 template("internal_jumbo_target") { |
| 50 use_jumbo_build_for_target = use_jumbo_build | 61 use_jumbo_build_for_target = use_jumbo_build |
| 51 if (defined(invoker.always_build_jumbo) && invoker.always_build_jumbo) { | 62 if (defined(invoker.always_build_jumbo) && invoker.always_build_jumbo) { |
| 52 use_jumbo_build_for_target = true | 63 use_jumbo_build_for_target = true |
| 53 } | 64 } |
| 54 if (defined(invoker.never_build_jumbo) && invoker.never_build_jumbo) { | 65 if (defined(invoker.never_build_jumbo) && invoker.never_build_jumbo) { |
| 55 use_jumbo_build_for_target = false | 66 use_jumbo_build_for_target = false |
| 56 } | 67 } |
| 57 if (target_name == jumbo_build_excluded) { | 68 if (target_name == jumbo_build_excluded) { |
| 58 use_jumbo_build_for_target = false | 69 use_jumbo_build_for_target = false |
| 59 } | 70 } |
| 60 | 71 |
| 61 excluded_sources = [] | 72 excluded_sources = [] |
| 62 if (defined(invoker.jumbo_excluded_sources)) { | 73 if (defined(invoker.jumbo_excluded_sources)) { |
| 63 excluded_sources += invoker.jumbo_excluded_sources | 74 excluded_sources += invoker.jumbo_excluded_sources |
| 64 } | 75 } |
| 65 | 76 |
| 66 invoker_sources = invoker.sources | 77 invoker_sources = invoker.sources |
| 67 gen_target_dir = get_path_info(invoker_sources[0], "gen_dir") | 78 if (defined(invoker.jumbo_gen_dir)) { |
| 68 assert(excluded_sources != [] || true) # Prevent "unused variable". | 79 gen_target_dir = invoker.jumbo_gen_dir |
| 80 } else { |
| 81 gen_target_dir = get_path_info(invoker_sources[0], "gen_dir") |
| 82 } |
| 69 | 83 |
| 70 # Find the gen_target_dir directory with shortest path. Short paths | 84 # Find the gen_target_dir directory with shortest path. Short paths |
| 71 # are nice in themselves since they mean shorter error messages and | 85 # are nice in themselves since they mean shorter error messages and |
| 72 # fewer bytes to parse, but the currently deployed version of ninja | 86 # fewer bytes to parse, but the currently deployed version of ninja |
| 73 # also has a limitation where it only allows 32 path components in | 87 # also has a limitation where it only allows 32 path components in |
| 74 # Windows. | 88 # Windows. |
| 75 # See https://crbug.com/738186 and | 89 # See https://crbug.com/738186 and |
| 76 # https://github.com/ninja-build/ninja/issues/1161 | 90 # https://github.com/ninja-build/ninja/issues/1161 |
| 77 foreach(source_file, invoker.sources) { | 91 foreach(source_file, invoker.sources) { |
| 78 possibly_better_gen_target_dir = get_path_info(gen_target_dir, "dir") | 92 possibly_better_gen_target_dir = get_path_info(gen_target_dir, "dir") |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 set_defaults("jumbo_target") { | 201 set_defaults("jumbo_target") { |
| 188 # This sets the default list of configs when the content_source_set target | 202 # This sets the default list of configs when the content_source_set target |
| 189 # is defined. The default_compiler_configs comes from BUILDCONFIG.gn and | 203 # is defined. The default_compiler_configs comes from BUILDCONFIG.gn and |
| 190 # is the list normally applied to static libraries and source sets. | 204 # is the list normally applied to static libraries and source sets. |
| 191 configs = default_compiler_configs | 205 configs = default_compiler_configs |
| 192 } | 206 } |
| 193 | 207 |
| 194 # See documentation above by "internal_jumbo_target". | 208 # See documentation above by "internal_jumbo_target". |
| 195 template("jumbo_component") { | 209 template("jumbo_component") { |
| 196 internal_jumbo_target(target_name) { | 210 internal_jumbo_target(target_name) { |
| 211 target_type = "component" |
| 197 forward_variables_from(invoker, "*") | 212 forward_variables_from(invoker, "*") |
| 198 } | 213 } |
| 199 } | 214 } |
| 200 | 215 |
| 201 set_defaults("jumbo_component") { | 216 set_defaults("jumbo_component") { |
| 202 # This sets the default list of configs when the content_source_set | 217 # This sets the default list of configs when the content_source_set |
| 203 # target is defined. This code is a clone of set_defaults for the | 218 # target is defined. This code is a clone of set_defaults for the |
| 204 # ordinary "component" template. | 219 # ordinary "component" template. |
| 205 if (is_component_build) { | 220 if (is_component_build) { |
| 206 configs = default_shared_library_configs | 221 configs = default_shared_library_configs |
| 207 if (is_android) { | 222 if (is_android) { |
| 208 configs -= [ "//build/config/android:hide_all_but_jni_onload" ] | 223 configs -= [ "//build/config/android:hide_all_but_jni_onload" ] |
| 209 } | 224 } |
| 210 } else { | 225 } else { |
| 211 configs = default_compiler_configs | 226 configs = default_compiler_configs |
| 212 } | 227 } |
| 213 } | 228 } |
| OLD | NEW |