@@ -25,145 +25,199 @@ copy("generate_dart_ui") {
2525 ]
2626}
2727
28- # Fuchsia's snapshot requires a different platform with extra dart: libraries.
29- if (! is_fuchsia ) {
30- compiled_action (" generate_snapshot_bin" ) {
31- tool = " //third_party/dart/runtime/bin:gen_snapshot"
32-
33- platform_kernel = " $root_out_dir /flutter_patched_sdk/platform_strong.dill"
34- inputs = [
35- platform_kernel ,
36- ]
37- deps = [
38- " :kernel_platform_files" ,
39- ]
40-
41- vm_snapshot_data = " $target_gen_dir /vm_isolate_snapshot.bin"
42- vm_snapshot_instructions = " $target_gen_dir /vm_snapshot_instructions.bin"
43- isolate_snapshot_data = " $target_gen_dir /isolate_snapshot.bin"
44- isolate_snapshot_instructions =
45- " $target_gen_dir /isolate_snapshot_instructions.bin"
46- outputs = [
47- vm_snapshot_data ,
48- vm_snapshot_instructions ,
49- isolate_snapshot_data ,
50- isolate_snapshot_instructions ,
51- ]
52-
53- args = [
54- " --snapshot_kind=core" ,
55- " --await_is_keyword" ,
56- " --enable_mirrors=false" ,
57- " --vm_snapshot_data=" + rebase_path (vm_snapshot_data ),
58- " --vm_snapshot_instructions=" + rebase_path (vm_snapshot_instructions ),
59- " --isolate_snapshot_data=" + rebase_path (isolate_snapshot_data ),
60- " --isolate_snapshot_instructions=" +
61- rebase_path (isolate_snapshot_instructions ),
62- rebase_path (platform_kernel ),
63- ]
64-
65- if (is_debug ) {
66- args += [
67- " --enable_asserts" ,
68- " --enable_type_checks" ,
69- " --error_on_bad_type" ,
70- " --error_on_bad_override" ,
71- ]
28+ action (" generate_snapshot_bin" ) {
29+ if (is_fuchsia ) {
30+ snapshot_dart = " snapshot_fuchsia.dart"
31+
32+ # TODO(rmacnak ): Fuchsia cross builds use the wrong Dart target
33+ # architecture, and have added steps that depend on this error for
34+ # reasonable build times (e.g., invoking the analyzer).
35+ if (target_cpu == host_cpu ) {
36+ snapshot_kind = " core-jit"
37+ } else {
38+ snapshot_kind = " core"
7239 }
40+ } else {
41+ snapshot_dart = " snapshot.dart"
42+ snapshot_kind = " core"
7343 }
7444
75- # Generates an assembly file defining a given symbol with the bytes from a
76- # binary file. Places the symbol in a text section if 'executable' is true,
77- # otherwise places the symbol in a read-only data section.
78- template (" bin_to_assembly" ) {
79- assert (defined (invoker .deps ), " Must define deps" )
80- assert (defined (invoker .input ), " Must define input binary file" )
81- assert (defined (invoker .output ), " Must define output assembly file" )
82- assert (defined (invoker .symbol ), " Must define symbol name" )
83- assert (defined (invoker .executable ), " Must define boolean executable" )
84-
85- action (target_name ) {
86- deps = invoker .deps
87- script = " //third_party/dart/runtime/tools/bin_to_assembly.py"
88- args = [
89- " --input" ,
90- rebase_path (invoker .input ),
91- " --output" ,
92- rebase_path (invoker .output ),
93- " --symbol_name" ,
94- invoker .symbol ,
95- " --target_os" ,
96- current_os ,
97- ]
98- if (invoker .executable ) {
99- args += [ " --executable" ]
100- }
101- inputs = [
102- script ,
103- invoker .input ,
104- ]
105- outputs = [
106- invoker .output ,
107- ]
108- }
45+ deps = [
46+ " :generate_dart_ui" ,
47+ " //third_party/dart/runtime/bin:gen_snapshot($host_toolchain )" ,
48+ ]
49+ depfile = " $target_gen_dir /core_snapshot.d"
50+
51+ inputs = [
52+ " //third_party/dart/runtime/tools/create_snapshot_bin.py" ,
53+ snapshot_dart ,
54+ ] + dart_ui_files
55+ if (is_fuchsia ) {
56+ inputs += [ " fuchsia_compilation_trace.txt" ]
10957 }
11058
111- bin_to_assembly (" vm_snapshot_data_assembly" ) {
112- deps = [
113- " :generate_snapshot_bin" ,
114- ]
115- input = " $target_gen_dir /vm_isolate_snapshot.bin"
116- output = " $target_gen_dir /vm_snapshot_data.S"
117- symbol = " kDartVmSnapshotData"
118- executable = false
119- }
59+ vm_snapshot_data = " $target_gen_dir /vm_isolate_snapshot.bin"
60+ vm_snapshot_instructions = " $target_gen_dir /vm_snapshot_instructions.bin"
61+ isolate_snapshot_data = " $target_gen_dir /isolate_snapshot.bin"
62+ isolate_snapshot_instructions =
63+ " $target_gen_dir /isolate_snapshot_instructions.bin"
64+ outputs = [
65+ vm_snapshot_data ,
66+ vm_snapshot_instructions ,
67+ isolate_snapshot_data ,
68+ isolate_snapshot_instructions ,
69+ ]
12070
121- bin_to_assembly (" vm_snapshot_instructions_assembly" ) {
122- deps = [
123- " :generate_snapshot_bin" ,
124- ]
125- input = " $target_gen_dir /vm_snapshot_instructions.bin"
126- output = " $target_gen_dir /vm_snapshot_instructions.S"
127- symbol = " kDartVmSnapshotInstructions"
128- executable = true
129- }
71+ rebased_dart_ui_path = rebase_path (dart_ui_path )
72+
73+ gen_snapshot_dir = get_label_info (
74+ " //third_party/dart/runtime/bin:gen_snapshot($host_toolchain )" ,
75+ " root_out_dir" )
76+ script = " //third_party/dart/runtime/tools/create_snapshot_bin.py"
77+
78+ args = [
79+ " --executable" ,
80+ rebase_path (" $gen_snapshot_dir /gen_snapshot" ),
81+ " --script" ,
82+ rebase_path (snapshot_dart ),
83+ " --snapshot_kind" ,
84+ snapshot_kind ,
85+ " --vm_flag" ,
86+ " --await_is_keyword" ,
87+ " --vm_flag" ,
88+ " --enable_mirrors=false" ,
89+ " --vm_output_bin" ,
90+ rebase_path (vm_snapshot_data , root_build_dir ),
91+ " --vm_instructions_output_bin" ,
92+ rebase_path (vm_snapshot_instructions , root_build_dir ),
93+ " --isolate_output_bin" ,
94+ rebase_path (isolate_snapshot_data , root_build_dir ),
95+ " --isolate_instructions_output_bin" ,
96+ rebase_path (isolate_snapshot_instructions , root_build_dir ),
97+ " --url_mapping=dart:ui,$rebased_dart_ui_path " ,
98+ " --vm_flag" ,
99+ " --dependencies=" + rebase_path (depfile ),
100+ ]
130101
131- bin_to_assembly (" isolate_snapshot_data_assembly" ) {
132- deps = [
133- " :generate_snapshot_bin" ,
102+ if (is_debug ) {
103+ args += [
104+ " --vm_flag" ,
105+ " --enable_asserts" ,
106+ " --vm_flag" ,
107+ " --enable_type_checks" ,
108+ " --vm_flag" ,
109+ " --error_on_bad_type" ,
110+ " --vm_flag" ,
111+ " --error_on_bad_override" ,
134112 ]
135- input = " $target_gen_dir /isolate_snapshot.bin"
136- output = " $target_gen_dir /isolate_snapshot_data.S"
137- symbol = " kDartIsolateSnapshotData"
138- executable = false
139113 }
140114
141- bin_to_assembly (" isolate_snapshot_instructions_assembly" ) {
142- deps = [
143- " :generate_snapshot_bin" ,
115+ if (is_fuchsia ) {
116+ inputs += zircon_sdk_ext_files + mozart_dart_sdk_ext_files
117+ zircon_path = rebase_path (zircon_sdk_ext_lib )
118+ fuchsia_path = rebase_path (fuchsia_sdk_ext_lib )
119+ mozart_internal_path = rebase_path (mozart_dart_sdk_ext_lib )
120+ args += [
121+ " --url_mapping=dart:zircon,$zircon_path " ,
122+ " --url_mapping=dart:fuchsia,$fuchsia_path " ,
123+ " --url_mapping=dart:mozart.internal,$mozart_internal_path " ,
124+ " --load_compilation_trace" ,
125+ rebase_path (" fuchsia_compilation_trace.txt" ),
144126 ]
145- input = " $target_gen_dir /isolate_snapshot_instructions.bin"
146- output = " $target_gen_dir /isolate_snapshot_instructions.S"
147- symbol = " kDartIsolateSnapshotInstructions"
148- executable = true
149127 }
128+ }
150129
151- source_set (" snapshot" ) {
152- deps = [
153- " :isolate_snapshot_data_assembly" ,
154- " :isolate_snapshot_instructions_assembly" ,
155- " :vm_snapshot_data_assembly" ,
156- " :vm_snapshot_instructions_assembly" ,
130+ # Generates an assembly file defining a given symbol with the bytes from a
131+ # binary file. Places the symbol in a text section if 'executable' is true,
132+ # otherwise places the symbol in a read-only data section.
133+ template (" bin_to_assembly" ) {
134+ assert (defined (invoker .deps ), " Must define deps" )
135+ assert (defined (invoker .input ), " Must define input binary file" )
136+ assert (defined (invoker .output ), " Must define output assembly file" )
137+ assert (defined (invoker .symbol ), " Must define symbol name" )
138+ assert (defined (invoker .executable ), " Must define boolean executable" )
139+
140+ action (target_name ) {
141+ deps = invoker .deps
142+ script = " //third_party/dart/runtime/tools/bin_to_assembly.py"
143+ args = [
144+ " --input" ,
145+ rebase_path (invoker .input ),
146+ " --output" ,
147+ rebase_path (invoker .output ),
148+ " --symbol_name" ,
149+ invoker .symbol ,
150+ " --target_os" ,
151+ current_os ,
157152 ]
158- sources = [
159- " $target_gen_dir /isolate_snapshot_data.S" ,
160- " $target_gen_dir /isolate_snapshot_instructions.S" ,
161- " $target_gen_dir /vm_snapshot_data.S" ,
162- " $target_gen_dir /vm_snapshot_instructions.S" ,
153+ if (invoker .executable ) {
154+ args += [ " --executable" ]
155+ }
156+ inputs = [
157+ script ,
158+ invoker .input ,
159+ ]
160+ outputs = [
161+ invoker .output ,
163162 ]
164163 }
165164}
166165
166+ bin_to_assembly (" vm_snapshot_data_assembly" ) {
167+ deps = [
168+ " :generate_snapshot_bin" ,
169+ ]
170+ input = " $target_gen_dir /vm_isolate_snapshot.bin"
171+ output = " $target_gen_dir /vm_snapshot_data.S"
172+ symbol = " kDartVmSnapshotData"
173+ executable = false
174+ }
175+
176+ bin_to_assembly (" vm_snapshot_instructions_assembly" ) {
177+ deps = [
178+ " :generate_snapshot_bin" ,
179+ ]
180+ input = " $target_gen_dir /vm_snapshot_instructions.bin"
181+ output = " $target_gen_dir /vm_snapshot_instructions.S"
182+ symbol = " kDartVmSnapshotInstructions"
183+ executable = true
184+ }
185+
186+ bin_to_assembly (" isolate_snapshot_data_assembly" ) {
187+ deps = [
188+ " :generate_snapshot_bin" ,
189+ ]
190+ input = " $target_gen_dir /isolate_snapshot.bin"
191+ output = " $target_gen_dir /isolate_snapshot_data.S"
192+ symbol = " kDartIsolateSnapshotData"
193+ executable = false
194+ }
195+
196+ bin_to_assembly (" isolate_snapshot_instructions_assembly" ) {
197+ deps = [
198+ " :generate_snapshot_bin" ,
199+ ]
200+ input = " $target_gen_dir /isolate_snapshot_instructions.bin"
201+ output = " $target_gen_dir /isolate_snapshot_instructions.S"
202+ symbol = " kDartIsolateSnapshotInstructions"
203+ executable = true
204+ }
205+
206+ source_set (" snapshot" ) {
207+ deps = [
208+ " :isolate_snapshot_data_assembly" ,
209+ " :isolate_snapshot_instructions_assembly" ,
210+ " :vm_snapshot_data_assembly" ,
211+ " :vm_snapshot_instructions_assembly" ,
212+ ]
213+ sources = [
214+ " $target_gen_dir /isolate_snapshot_data.S" ,
215+ " $target_gen_dir /isolate_snapshot_instructions.S" ,
216+ " $target_gen_dir /vm_snapshot_data.S" ,
217+ " $target_gen_dir /vm_snapshot_instructions.S" ,
218+ ]
219+ }
220+
167221compile_platform (" non_strong_platform" ) {
168222 libraries_specification_uri = " libraries.json"
169223
@@ -228,28 +282,22 @@ template("generate_entry_points_json_with_gen_snapshot") {
228282 output = invoker .output
229283
230284 tool = " //third_party/dart/runtime/bin:gen_snapshot"
231- inputs = [ input ] + extra_inputs
285+ inputs = [
286+ input ,
287+ ] + extra_inputs
232288 outputs = [
233289 output ,
234-
235- # Though they are not consumed, GN needs to know to create the output directory.
236- " $target_gen_dir /dummy.vm_data.snapshot" ,
237- " $target_gen_dir /dummy.vm_instr.snapshot" ,
238- " $target_gen_dir /dummy.isolate_data.snapshot" ,
239- " $target_gen_dir /dummy.isolate_instr.snapshot" ,
240290 ]
241291 args = [
242- " --print-precompiler-entry-points=" + rebase_path (output ),
243- " --snapshot-kind=app-aot-blobs" ,
244- " --vm_snapshot_data=" +
245- rebase_path (" $target_gen_dir /dummy.vm_data.snapshot" ),
246- " --vm_snapshot_instructions=" +
247- rebase_path (" $target_gen_dir /dummy.vm_instr.snapshot" ),
248- " --isolate_snapshot_data=" +
249- rebase_path (" $target_gen_dir /dummy.isolate_data.snapshot" ),
250- " --isolate_snapshot_instructions=" +
251- rebase_path (" $target_gen_dir /dummy.isolate_instr.snapshot" ),
252- ] + extra_args + [ rebase_path (input ) ]
292+ " --print-precompiler-entry-points=" + rebase_path (output ),
293+ " --snapshot-kind=app-aot-blobs" ,
294+ " --vm_snapshot_data=" + rebase_path (" $target_gen_dir /dummy.vm_data.snapshot" ),
295+ " --vm_snapshot_instructions=" + rebase_path (" $target_gen_dir /dummy.vm_instr.snapshot" ),
296+ " --isolate_snapshot_data=" + rebase_path (" $target_gen_dir /dummy.isolate_data.snapshot" ),
297+ " --isolate_snapshot_instructions=" + rebase_path (" $target_gen_dir /dummy.isolate_instr.snapshot" ),
298+ ] + extra_args + [
299+ rebase_path (input ),
300+ ]
253301 }
254302}
255303
0 commit comments