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

Side by Side Diff: build/config/jumbo.gni

Issue 2963733003: Scripts for unity/jumbo (default disabled) compilation (Closed)
Patch Set: Moved files and changed some names Created 3 years, 5 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 unified diff | Download patch
« no previous file with comments | « no previous file | build/config/jumbo.py » ('j') | build/config/jumbo.py » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 # found in the LICENSE file.
4
5 import("//build/split_static_library.gni") # When someone uses that target_type
6
7 declare_args() {
8 # If true, use a jumbo build (files compiled together) to speed up
9 # compilation.
Dirk Pranke 2017/06/30 21:38:46 We should document in more details somewhere what
Daniel Bratell 2017/07/03 09:21:17 I will move some text from the current Google Doc
10 use_jumbo_build = false
11
12 # A target to exclude from jumbo builds, for optimal round trip time
13 # when frequently changing a single cpp file.
14 jumbo_build_excluded = ""
15
16 # How many files to group at most. Smaller numbers give more
17 # parallellism, higher numbers give less total CPU usage. Higher
18 # numbers also give longer single-file recompilation times.
19 #
20 # Recommendations:
21 # Higher numbers than 200 does not reduce wall clock compile times
22 # for 4 cores or less.
23 # 200 uses 8% less total CPU than 100 when compiling content and 10%
24 # less wall clock when compiling with 4 cores.
brucedawson 2017/06/30 18:49:15 I would expect that we would want to tune this for
Dirk Pranke 2017/06/30 21:38:46 I feel similarly :). 200 is fine for now.
Daniel Bratell 2017/07/03 09:21:17 Looking forward to numbers from other computers. 4
25 jumbo_file_merge_limit = 200
26 }
27
28 # Use this to generate a target which merges sources if possible to
29 # compile much faster.
30 #
31 # Special values.
32 #
33 # target_type
34 # The kind of target to build. For example the string
35 # "static_library".
Dirk Pranke 2017/06/30 21:38:46 Given the set_defaults() call on line 138, this me
Daniel Bratell 2017/07/03 09:21:17 I have considered making one jumbo_source_set, one
36 #
37 # always_build_jumbo
38 # If set and set to true, then use jumbo compile even when it is
39 # globally disabled. Otherwise it has no effect
Dirk Pranke 2017/06/30 21:38:46 Nit: add periods after "no effect", here and on li
Daniel Bratell 2017/07/03 09:21:17 Done.
40 #
41 # never_build_jumbo
42 # If set and set to true, then do not jumbo compile even if it is
43 # globally enabled. Otherwise it has no effect
44 #
45 # jumbo_excluded_sources
46 # If set to a list of files, those files will not be merged with
47 # the rest. Can be used if files are problematic.
Dirk Pranke 2017/06/30 21:38:45 s/Can be used if files are problematic/This can be
Daniel Bratell 2017/07/03 09:21:17 Done.
48 template("jumbo_target") {
49 use_jumbo_build_for_target = use_jumbo_build
50 if (defined(invoker.always_build_jumbo) && invoker.always_build_jumbo) {
51 use_jumbo_build_for_target = true
52 }
53 if (defined(invoker.never_build_jumbo) && invoker.never_build_jumbo) {
54 use_jumbo_build_for_target = false
55 }
56 if (target_name == jumbo_build_excluded) {
57 use_jumbo_build_for_target = false
58 }
59
60 excluded_sources = []
61 if (defined(invoker.jumbo_excluded_sources)) {
62 excluded_sources += invoker.jumbo_excluded_sources
63 }
64
65 invoker_sources = invoker.sources
66 gen_target_dir = get_path_info(invoker_sources[0], "gen_dir")
67 assert(excluded_sources != [] || true) # Prevent "unused variable".
68 assert(gen_target_dir != "") # Prevent "unused variable".
69
70 if (use_jumbo_build_for_target) {
71 jumbo_files = []
72
73 # Split the sources list into chunks that are not excessively large
74 files_per_chunk = jumbo_file_merge_limit
75 current_file_index = 0
76 next_chunk_start = 0
77 next_chunk_number = 1
78 foreach(source_file, invoker.sources) {
79 if (current_file_index == next_chunk_start) {
80 jumbo_files += [ "$gen_target_dir/" + target_name + "_jumbo_" +
81 next_chunk_number + ".cc" ]
82 next_chunk_number += 1
83 next_chunk_start += files_per_chunk
84 }
85 current_file_index += 1
86 }
87
88 # Create an action that calls a script that merges all the source files.
89 action(target_name + "_jumbo") {
Dirk Pranke 2017/06/30 21:38:45 I'd pull target_name + "_jumbo" into a variable so
Daniel Bratell 2017/07/03 09:21:17 Done.
90 script = "//build/config/jumbo.py"
91 response_file_contents =
92 rebase_path(invoker.sources - excluded_sources, gen_target_dir)
93 outputs = jumbo_files
94 args = [ "--outputs" ] + rebase_path(outputs, root_build_dir) +
95 [ "--file-list={{response_file_name}}" ]
Dirk Pranke 2017/06/30 21:38:46 I think you need to set inputs = invoker.sources -
Daniel Bratell 2017/07/03 09:21:17 Not for the #include method since the contents of
96 }
97 }
98
99 target_type = invoker.target_type
100 if (use_jumbo_build_for_target && target_type == "split_static_library") {
101 # Meaningless and also impossible if split_count > len(jumbo_files)
102 target_type = "static_library"
103
104 # Prevent "unused variable" warning.
105 assert(!defined(invoker.split_count) || invoker.split_count > 0)
106 }
107
108 # Perform the actual operation, either on the original sources or
109 # the sources post-jumbo merging.
110 target(target_type, target_name) {
111 deps = []
112 if (defined(invoker.deps)) {
113 deps += invoker.deps
114 }
115
116 # Take everything else not handled above from the invoker.
117 variables_to_not_forward = [ "deps" ]
118 if (use_jumbo_build_for_target) {
119 deps += [ ":" + target_name + "_jumbo" ]
120 variables_to_not_forward += [ "sources" ]
121 assert(jumbo_files != [])
122 sources = jumbo_files + excluded_sources
123
124 # Need to keep the headers in sources so that dependency checks
125 # work, and we need to keep Objective-C code since they
126 # cannot be merged into a cc file (FIXME).
127 foreach(source_file, invoker.sources) {
128 source_ext = get_path_info(source_file, "extension")
129 if (source_ext == "h" || source_ext == "mm") {
130 sources += [ source_file ]
131 }
132 }
133 }
134 forward_variables_from(invoker, "*", variables_to_not_forward)
135 }
136 }
137
138 set_defaults("jumbo_target") {
139 # This sets the default list of configs when the content_source_set target
140 # is defined. The default_compiler_configs comes from BUILDCONFIG.gn and
141 # is the list normally applied to static libraries and source sets.
142 configs = default_compiler_configs
143 }
OLDNEW
« no previous file with comments | « no previous file | build/config/jumbo.py » ('j') | build/config/jumbo.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698