@@ -25,203 +25,146 @@ copy("generate_dart_ui") {
2525 ]
2626}
2727
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"
39- }
40- } else {
41- snapshot_dart = " snapshot.dart"
42- snapshot_kind = " core"
43- }
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"
4432
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" ]
57- }
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+ ]
5840
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- ]
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+ ]
7052
71- rebased_dart_ui_path = rebase_path (dart_ui_path )
53+ args = [
54+ " --strong" ,
55+ " --sync-async" ,
56+ " --reify-generic-functions" ,
57+ " --snapshot_kind=core" ,
58+ " --await_is_keyword" ,
59+ " --enable_mirrors=false" ,
60+ " --vm_snapshot_data=" + rebase_path (vm_snapshot_data ),
61+ " --vm_snapshot_instructions=" + rebase_path (vm_snapshot_instructions ),
62+ " --isolate_snapshot_data=" + rebase_path (isolate_snapshot_data ),
63+ " --isolate_snapshot_instructions=" +
64+ rebase_path (isolate_snapshot_instructions ),
65+ rebase_path (platform_kernel ),
66+ ]
7267
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"
68+ if (is_debug ) {
69+ args += [
70+ " --enable_asserts" ,
71+ " --enable_type_checks" ,
72+ " --error_on_bad_type" ,
73+ " --error_on_bad_override" ,
74+ ]
75+ }
76+ }
7777
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_flag" ,
90- " --no-strong" ,
91- " --vm_flag" ,
92- " --no-sync-async" ,
93- " --vm_flag" ,
94- " --no-reify-generic-functions" ,
95- " --vm_output_bin" ,
96- rebase_path (vm_snapshot_data , root_build_dir ),
97- " --vm_instructions_output_bin" ,
98- rebase_path (vm_snapshot_instructions , root_build_dir ),
99- " --isolate_output_bin" ,
100- rebase_path (isolate_snapshot_data , root_build_dir ),
101- " --isolate_instructions_output_bin" ,
102- rebase_path (isolate_snapshot_instructions , root_build_dir ),
103- " --url_mapping=dart:ui,$rebased_dart_ui_path " ,
104- " --vm_flag" ,
105- " --dependencies=" + rebase_path (depfile ),
106- ]
78+ # Generates an assembly file defining a given symbol with the bytes from a
79+ # binary file. Places the symbol in a text section if 'executable' is true,
80+ # otherwise places the symbol in a read-only data section.
81+ template (" bin_to_assembly" ) {
82+ assert (defined (invoker .deps ), " Must define deps" )
83+ assert (defined (invoker .input ), " Must define input binary file" )
84+ assert (defined (invoker .output ), " Must define output assembly file" )
85+ assert (defined (invoker .symbol ), " Must define symbol name" )
86+ assert (defined (invoker .executable ), " Must define boolean executable" )
87+
88+ action (target_name ) {
89+ deps = invoker .deps
90+ script = " //third_party/dart/runtime/tools/bin_to_assembly.py"
91+ args = [
92+ " --input" ,
93+ rebase_path (invoker .input ),
94+ " --output" ,
95+ rebase_path (invoker .output ),
96+ " --symbol_name" ,
97+ invoker .symbol ,
98+ " --target_os" ,
99+ current_os ,
100+ ]
101+ if (invoker .executable ) {
102+ args += [ " --executable" ]
103+ }
104+ inputs = [
105+ script ,
106+ invoker .input ,
107+ ]
108+ outputs = [
109+ invoker .output ,
110+ ]
111+ }
112+ }
107113
108- if (is_debug ) {
109- args += [
110- " --vm_flag" ,
111- " --enable_asserts" ,
112- " --vm_flag" ,
113- " --enable_type_checks" ,
114- " --vm_flag" ,
115- " --error_on_bad_type" ,
116- " --vm_flag" ,
117- " --error_on_bad_override" ,
114+ bin_to_assembly (" vm_snapshot_data_assembly" ) {
115+ deps = [
116+ " :generate_snapshot_bin" ,
118117 ]
118+ input = " $target_gen_dir /vm_isolate_snapshot.bin"
119+ output = " $target_gen_dir /vm_snapshot_data.S"
120+ symbol = " kDartVmSnapshotData"
121+ executable = false
119122 }
120123
121- if (is_fuchsia ) {
122- inputs += zircon_sdk_ext_files + mozart_dart_sdk_ext_files
123- zircon_path = rebase_path (zircon_sdk_ext_lib )
124- fuchsia_path = rebase_path (fuchsia_sdk_ext_lib )
125- mozart_internal_path = rebase_path (mozart_dart_sdk_ext_lib )
126- args += [
127- " --url_mapping=dart:zircon,$zircon_path " ,
128- " --url_mapping=dart:fuchsia,$fuchsia_path " ,
129- " --url_mapping=dart:mozart.internal,$mozart_internal_path " ,
130- " --load_compilation_trace" ,
131- rebase_path (" fuchsia_compilation_trace.txt" ),
124+ bin_to_assembly (" vm_snapshot_instructions_assembly" ) {
125+ deps = [
126+ " :generate_snapshot_bin" ,
132127 ]
128+ input = " $target_gen_dir /vm_snapshot_instructions.bin"
129+ output = " $target_gen_dir /vm_snapshot_instructions.S"
130+ symbol = " kDartVmSnapshotInstructions"
131+ executable = true
133132 }
134- }
135133
136- # Generates an assembly file defining a given symbol with the bytes from a
137- # binary file. Places the symbol in a text section if 'executable' is true,
138- # otherwise places the symbol in a read-only data section.
139- template (" bin_to_assembly" ) {
140- assert (defined (invoker .deps ), " Must define deps" )
141- assert (defined (invoker .input ), " Must define input binary file" )
142- assert (defined (invoker .output ), " Must define output assembly file" )
143- assert (defined (invoker .symbol ), " Must define symbol name" )
144- assert (defined (invoker .executable ), " Must define boolean executable" )
145-
146- action (target_name ) {
147- deps = invoker .deps
148- script = " //third_party/dart/runtime/tools/bin_to_assembly.py"
149- args = [
150- " --input" ,
151- rebase_path (invoker .input ),
152- " --output" ,
153- rebase_path (invoker .output ),
154- " --symbol_name" ,
155- invoker .symbol ,
156- " --target_os" ,
157- current_os ,
158- ]
159- if (invoker .executable ) {
160- args += [ " --executable" ]
161- }
162- inputs = [
163- script ,
164- invoker .input ,
165- ]
166- outputs = [
167- invoker .output ,
134+ bin_to_assembly (" isolate_snapshot_data_assembly" ) {
135+ deps = [
136+ " :generate_snapshot_bin" ,
168137 ]
138+ input = " $target_gen_dir /isolate_snapshot.bin"
139+ output = " $target_gen_dir /isolate_snapshot_data.S"
140+ symbol = " kDartIsolateSnapshotData"
141+ executable = false
169142 }
170- }
171-
172- bin_to_assembly (" vm_snapshot_data_assembly" ) {
173- deps = [
174- " :generate_snapshot_bin" ,
175- ]
176- input = " $target_gen_dir /vm_isolate_snapshot.bin"
177- output = " $target_gen_dir /vm_snapshot_data.S"
178- symbol = " kDartVmSnapshotData"
179- executable = false
180- }
181-
182- bin_to_assembly (" vm_snapshot_instructions_assembly" ) {
183- deps = [
184- " :generate_snapshot_bin" ,
185- ]
186- input = " $target_gen_dir /vm_snapshot_instructions.bin"
187- output = " $target_gen_dir /vm_snapshot_instructions.S"
188- symbol = " kDartVmSnapshotInstructions"
189- executable = true
190- }
191-
192- bin_to_assembly (" isolate_snapshot_data_assembly" ) {
193- deps = [
194- " :generate_snapshot_bin" ,
195- ]
196- input = " $target_gen_dir /isolate_snapshot.bin"
197- output = " $target_gen_dir /isolate_snapshot_data.S"
198- symbol = " kDartIsolateSnapshotData"
199- executable = false
200- }
201143
202- bin_to_assembly (" isolate_snapshot_instructions_assembly" ) {
203- deps = [
204- " :generate_snapshot_bin" ,
205- ]
206- input = " $target_gen_dir /isolate_snapshot_instructions.bin"
207- output = " $target_gen_dir /isolate_snapshot_instructions.S"
208- symbol = " kDartIsolateSnapshotInstructions"
209- executable = true
210- }
144+ bin_to_assembly (" isolate_snapshot_instructions_assembly" ) {
145+ deps = [
146+ " :generate_snapshot_bin" ,
147+ ]
148+ input = " $target_gen_dir /isolate_snapshot_instructions.bin"
149+ output = " $target_gen_dir /isolate_snapshot_instructions.S"
150+ symbol = " kDartIsolateSnapshotInstructions"
151+ executable = true
152+ }
211153
212- source_set (" snapshot" ) {
213- deps = [
214- " :isolate_snapshot_data_assembly" ,
215- " :isolate_snapshot_instructions_assembly" ,
216- " :vm_snapshot_data_assembly" ,
217- " :vm_snapshot_instructions_assembly" ,
218- ]
219- sources = [
220- " $target_gen_dir /isolate_snapshot_data.S" ,
221- " $target_gen_dir /isolate_snapshot_instructions.S" ,
222- " $target_gen_dir /vm_snapshot_data.S" ,
223- " $target_gen_dir /vm_snapshot_instructions.S" ,
224- ]
154+ source_set (" snapshot" ) {
155+ deps = [
156+ " :isolate_snapshot_data_assembly" ,
157+ " :isolate_snapshot_instructions_assembly" ,
158+ " :vm_snapshot_data_assembly" ,
159+ " :vm_snapshot_instructions_assembly" ,
160+ ]
161+ sources = [
162+ " $target_gen_dir /isolate_snapshot_data.S" ,
163+ " $target_gen_dir /isolate_snapshot_instructions.S" ,
164+ " $target_gen_dir /vm_snapshot_data.S" ,
165+ " $target_gen_dir /vm_snapshot_instructions.S" ,
166+ ]
167+ }
225168}
226169
227170compile_platform (" non_strong_platform" ) {
@@ -288,25 +231,31 @@ template("generate_entry_points_json_with_gen_snapshot") {
288231 output = invoker .output
289232
290233 tool = " //third_party/dart/runtime/bin:gen_snapshot"
291- inputs = [
292- input ,
293- ] + extra_inputs
234+ inputs = [ input ] + extra_inputs
294235 outputs = [
295236 output ,
237+
238+ # Though they are not consumed, GN needs to know to create the output directory.
239+ " $target_gen_dir /dummy.vm_data.snapshot" ,
240+ " $target_gen_dir /dummy.vm_instr.snapshot" ,
241+ " $target_gen_dir /dummy.isolate_data.snapshot" ,
242+ " $target_gen_dir /dummy.isolate_instr.snapshot" ,
296243 ]
297244 args = [
298- " --no-strong" ,
299- " --no-sync-async" ,
300- " --no-reify-generic-functions" ,
301- " --print-precompiler-entry-points=" + rebase_path (output ),
302- " --snapshot-kind=app-aot-blobs" ,
303- " --vm_snapshot_data=" + rebase_path (" $target_gen_dir /dummy.vm_data.snapshot" ),
304- " --vm_snapshot_instructions=" + rebase_path (" $target_gen_dir /dummy.vm_instr.snapshot" ),
305- " --isolate_snapshot_data=" + rebase_path (" $target_gen_dir /dummy.isolate_data.snapshot" ),
306- " --isolate_snapshot_instructions=" + rebase_path (" $target_gen_dir /dummy.isolate_instr.snapshot" ),
307- ] + extra_args + [
308- rebase_path (input ),
309- ]
245+ " --no-strong" ,
246+ " --no-sync-async" ,
247+ " --no-reify-generic-functions" ,
248+ " --print-precompiler-entry-points=" + rebase_path (output ),
249+ " --snapshot-kind=app-aot-blobs" ,
250+ " --vm_snapshot_data=" +
251+ rebase_path (" $target_gen_dir /dummy.vm_data.snapshot" ),
252+ " --vm_snapshot_instructions=" +
253+ rebase_path (" $target_gen_dir /dummy.vm_instr.snapshot" ),
254+ " --isolate_snapshot_data=" +
255+ rebase_path (" $target_gen_dir /dummy.isolate_data.snapshot" ),
256+ " --isolate_snapshot_instructions=" +
257+ rebase_path (" $target_gen_dir /dummy.isolate_instr.snapshot" ),
258+ ] + extra_args + [ rebase_path (input ) ]
310259 }
311260}
312261
0 commit comments