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

Side by Side Diff: build/jumbo.gni

Issue 2824663002: Minimal set of changes for blink core jumbo build. (Closed)
Patch Set: Created 3 years, 8 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/jumbo.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 import("//build/split_static_library.gni") # When someone uses that target_type
2
3 declare_args() {
4 # If true, use a jumbo build (files compiled together) to speed up
5 # compilation.
6 use_blink_jumbo_build = true
7
8 # A target to exclude from jumbo builds, for optimal round trip time
9 # when frequently changing a single cpp file.
10 jumbo_build_excluded = ""
11 }
12
13 template("jumbo_target") {
14 use_jumbo_build = use_blink_jumbo_build
15 if (defined(invoker.jumbo_build_override)) {
16 use_jumbo_build = invoker.jumbo_build_override
17 }
18 if (target_name == jumbo_build_excluded) {
19 use_jumbo_build = false
20 }
21 excluded_sources = []
22 if (defined(invoker.jumbo_excluded_sources)) {
23 excluded_sources += invoker.jumbo_excluded_sources
24 }
25 invoker_sources = invoker.sources
26 gen_target_dir = get_path_info(invoker_sources[0], "gen_dir")
27 assert(excluded_sources != [] || true) # Prevent "unused variable".
28 assert(gen_target_dir != "") # Prevent "unused variable".
29
30 if (use_jumbo_build) {
31 jumbo_files = []
32
33 # Split the sources list into chunks that are not excessively large
34 files_per_chunk = 200
35 current_file_index = 0
36 next_chunk_start = 0
37 next_chunk_number = 1
38 foreach(source_file, invoker.sources) {
39 if (current_file_index == next_chunk_start) {
40 jumbo_files += [ "$gen_target_dir/" + target_name + "_jumbo_" +
41 next_chunk_number + ".cc" ]
42 next_chunk_number += 1
43 next_chunk_start += files_per_chunk
44 }
45 current_file_index += 1
46 }
47
48 # Create an action that calls a script that merges all the source files.
49 action(target_name + "_jumbo") {
50 script = "//build/jumbo.py"
51 response_file_contents =
52 rebase_path(invoker.sources - excluded_sources, gen_target_dir)
53 outputs = jumbo_files
54 args = [ "--outputs" ] + rebase_path(outputs, root_build_dir) +
55 [ "--file-list={{response_file_name}}" ]
56 }
57 }
58
59 target_type = invoker.target_type
60 if (use_jumbo_build && target_type == "split_static_library") {
61 # Meaningless and also impossible if split_count > len(jumbo_files)
62 target_type = "static_library"
63
64 # Prevent "unused variable" warning.
65 assert(!defined(invoker.split_count) || invoker.split_count > 0)
66 }
67
68 # Perform the actual operation, either on the original sources or
69 # the sources post-jumbo merging.
70 target(target_type, target_name) {
71 deps = []
72 if (defined(invoker.deps)) {
73 deps += invoker.deps
74 }
75
76 # Take everything else not handled above from the invoker.
77 variables_to_not_forward = [ "deps" ]
78 if (use_jumbo_build) {
79 deps += [ ":" + target_name + "_jumbo" ]
80 variables_to_not_forward += [ "sources" ]
81 assert(jumbo_files != [])
82 sources = jumbo_files + excluded_sources
83
84 # And the headers so that dependency checks work.
85 foreach(source_file, invoker.sources) {
86 if (get_path_info(source_file, "extension") == "h") {
87 sources += [ source_file ]
88 }
89 }
90 }
91 forward_variables_from(invoker, "*", variables_to_not_forward)
92 }
93 }
94
95 set_defaults("jumbo_target") {
96 # This sets the default list of configs when the content_source_set target
97 # is defined. The default_compiler_configs comes from BUILDCONFIG.gn and
98 # is the list normally applied to static libraries and source sets.
99 configs = default_compiler_configs
100 }
OLDNEW
« no previous file with comments | « no previous file | build/jumbo.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698