| 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 100 does not reduce wall clock compile times | 23   # Higher numbers than 100 does not reduce wall clock compile times | 
| 22   # even for 4 cores or less so no reason to go (much) higher than 100. | 24   # even for 4 cores or less so no reason to go (much) higher than 100. | 
| 23   # 100 uses 8% less total CPU than 50 when compiling content and 10% | 25   # 100 uses 8% less total CPU than 50 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 50 is smaller. | 
| 25   jumbo_file_merge_limit = 100 | 28   jumbo_file_merge_limit = 100 | 
| 26 } | 29 } | 
| 27 | 30 | 
| 28 # Use one of the targets jumbo_source_set, jumbo_static_library, | 31 # Use one of the targets jumbo_source_set, jumbo_static_library, | 
| 29 # jumbo_split_static_library or jumbo_component to generate a target | 32 # jumbo_split_static_library or jumbo_component to generate a target | 
| 30 # which merges sources if possible to compile much faster. | 33 # which merges sources if possible to compile much faster. | 
| 31 # | 34 # | 
| 32 # Special values. | 35 # Special values. | 
| 33 # | 36 # | 
| 34 #   target_type | 37 #   target_type | 
| 35 #      The kind of target to build. For example the string | 38 #      The kind of target to build. For example the string | 
| 36 #      "static_library". | 39 #      "static_library". | 
| 37 # | 40 # | 
| 38 #   always_build_jumbo | 41 #   always_build_jumbo | 
| 39 #      If set and set to true, then use jumbo compile even when it is | 42 #      If set and set to true, then use jumbo compile even when it is | 
| 40 #      globally disabled. Otherwise it has no effect. | 43 #      globally disabled. Otherwise it has no effect. | 
| 41 # | 44 # | 
| 42 #   never_build_jumbo | 45 #   never_build_jumbo | 
| 43 #      If set and set to true, then do not jumbo compile even if it is | 46 #      If set and set to true, then do not jumbo compile even if it is | 
| 44 #      globally enabled. Otherwise it has no effect. | 47 #      globally enabled. Otherwise it has no effect. | 
| 45 # | 48 # | 
| 46 #   jumbo_excluded_sources | 49 #   jumbo_excluded_sources | 
| 47 #      If set to a list of files, those files will not be merged with | 50 #      If set to a list of files, those files will not be merged with | 
| 48 #      the rest. This can be necessary if merging the files causes | 51 #      the rest. This can be necessary if merging the files causes | 
| 49 #      compilation issues and fixing the issues is impractical. | 52 #      compilation issues and fixing the issues is impractical. | 
|  | 53 # | 
|  | 54 #   jumbo_gen_dir | 
|  | 55 #      If set, this overrides the default location for the generated | 
|  | 56 #      jumbo files. This can be needed if the default location is too | 
|  | 57 #      deep for the build tools. By default the location is based on | 
|  | 58 #      the first file in sources. (Might not be neeeded one Chromium | 
|  | 59 #      has the fix for | 
|  | 60 #      https://github.com/ninja-build/ninja/issues/1161. | 
| 50 template("internal_jumbo_target") { | 61 template("internal_jumbo_target") { | 
| 51   use_jumbo_build_for_target = use_jumbo_build | 62   use_jumbo_build_for_target = use_jumbo_build | 
| 52   if (defined(invoker.always_build_jumbo) && invoker.always_build_jumbo) { | 63   if (defined(invoker.always_build_jumbo) && invoker.always_build_jumbo) { | 
| 53     use_jumbo_build_for_target = true | 64     use_jumbo_build_for_target = true | 
| 54   } | 65   } | 
| 55   if (defined(invoker.never_build_jumbo) && invoker.never_build_jumbo) { | 66   if (defined(invoker.never_build_jumbo) && invoker.never_build_jumbo) { | 
| 56     use_jumbo_build_for_target = false | 67     use_jumbo_build_for_target = false | 
| 57   } | 68   } | 
| 58   if (target_name == jumbo_build_excluded) { | 69   if (target_name == jumbo_build_excluded) { | 
| 59     use_jumbo_build_for_target = false | 70     use_jumbo_build_for_target = false | 
| 60   } | 71   } | 
| 61 | 72 | 
| 62   excluded_sources = [] | 73   excluded_sources = [] | 
| 63   if (defined(invoker.jumbo_excluded_sources)) { | 74   if (defined(invoker.jumbo_excluded_sources)) { | 
| 64     excluded_sources += invoker.jumbo_excluded_sources | 75     excluded_sources += invoker.jumbo_excluded_sources | 
| 65   } | 76   } | 
| 66 | 77 | 
| 67   invoker_sources = invoker.sources | 78   invoker_sources = invoker.sources | 
| 68   gen_target_dir = get_path_info(invoker_sources[0], "gen_dir") | 79   if (defined(invoker.jumbo_gen_dir)) { | 
| 69   assert(excluded_sources != [] || true)  # Prevent "unused variable". | 80     gen_target_dir = invoker.jumbo_gen_dir | 
|  | 81   } else { | 
|  | 82     gen_target_dir = get_path_info(invoker_sources[0], "gen_dir") | 
|  | 83   } | 
| 70 | 84 | 
| 71   # Find the gen_target_dir directory with shortest path. Short paths | 85   # Find the gen_target_dir directory with shortest path. Short paths | 
| 72   # are nice in themselves since they mean shorter error messages and | 86   # are nice in themselves since they mean shorter error messages and | 
| 73   # fewer bytes to parse, but the currently deployed version of ninja | 87   # fewer bytes to parse, but the currently deployed version of ninja | 
| 74   # also has a limitation where it only allows 32 path components in | 88   # also has a limitation where it only allows 32 path components in | 
| 75   # Windows. | 89   # Windows. | 
| 76   # See https://crbug.com/738186 and | 90   # See https://crbug.com/738186 and | 
| 77   # https://github.com/ninja-build/ninja/issues/1161 | 91   # https://github.com/ninja-build/ninja/issues/1161 | 
| 78   foreach(source_file, invoker.sources) { | 92   foreach(source_file, invoker.sources) { | 
| 79     possibly_better_gen_target_dir = get_path_info(gen_target_dir, "dir") | 93     possibly_better_gen_target_dir = get_path_info(gen_target_dir, "dir") | 
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 248   # ordinary "component" template. | 262   # ordinary "component" template. | 
| 249   if (is_component_build) { | 263   if (is_component_build) { | 
| 250     configs = default_shared_library_configs | 264     configs = default_shared_library_configs | 
| 251     if (is_android) { | 265     if (is_android) { | 
| 252       configs -= [ "//build/config/android:hide_all_but_jni_onload" ] | 266       configs -= [ "//build/config/android:hide_all_but_jni_onload" ] | 
| 253     } | 267     } | 
| 254   } else { | 268   } else { | 
| 255     configs = default_compiler_configs | 269     configs = default_compiler_configs | 
| 256   } | 270   } | 
| 257 } | 271 } | 
|  | 272 | 
|  | 273 # See documentation above by "internal_jumbo_target". | 
|  | 274 template("jumbo_test") { | 
|  | 275   internal_jumbo_target(target_name) { | 
|  | 276     target_type = "test" | 
|  | 277     forward_variables_from(invoker, "*") | 
|  | 278   } | 
|  | 279 } | 
|  | 280 | 
|  | 281 set_defaults("jumbo_test") { | 
|  | 282   if (is_android) { | 
|  | 283     configs = default_shared_library_configs | 
|  | 284     configs -= [ "//build/config/android:hide_all_but_jni_onload" ] | 
|  | 285     configs += [ "//build/config/android:hide_all_but_jni" ] | 
|  | 286   } else { | 
|  | 287     configs = default_executable_configs | 
|  | 288   } | 
|  | 289 } | 
| OLD | NEW | 
|---|