@@ -10,115 +10,21 @@ import("//flutter/common/config.gni")
1010import (" //third_party/dart/build/dart/dart_action.gni" )
1111import (" //third_party/dart/sdk_args.gni" )
1212
13- # Generates a Dart kernel snapshot using flutter_frontend_server.
14- #
15- # Arguments
16- # main_dart (required):
17- # The Dart entrypoint file.
18- #
19- # kernel_output (required):
20- # The path to the output kernel snapshot in the out directory.
21- #
22- # package_config (optional):
23- # The path to the package_config.json file.
24- #
25- # deps (optional):
26- # Additional dependencies. Dependencies on the frontend server and
27- # Flutter's platform.dill are included by default. This rule creates and
28- # uses a depfile, so listing all Dart sources is not necessary.
29- #
30- # extra_args (optional):
31- # Additional frontend server command line arguments.
32- template (" flutter_frontend_server" ) {
33- assert (defined (invoker .main_dart ), " The Dart test file must be specified." )
34- assert (defined (invoker .kernel_output ),
35- " The Dart Kernel file location must be specified." )
36-
37- kernel_output = invoker .kernel_output
38-
39- common_deps = [
40- " //flutter/flutter_frontend_server:frontend_server" ,
41- " //flutter/lib/snapshot:strong_platform" ,
42- ]
43- if (defined (invoker .deps )) {
44- common_deps += invoker .deps
45- }
46-
47- extra_args = []
48- if (defined (invoker .extra_args )) {
49- extra_args += invoker .extra_args
50- }
51-
52- packages_args = []
53- if (defined (invoker .package_config )) {
54- packages_args += [
55- " --packages" ,
56- rebase_path (invoker .package_config ),
57- ]
58- }
59-
60- snapshot_depfile = " $kernel_output .d"
61-
62- common_vm_args = [ " --disable-dart-dev" ]
63-
64- flutter_patched_sdk = rebase_path (" $root_out_dir /flutter_patched_sdk" )
65-
66- common_args = extra_args + packages_args + [
67- " --sdk-root" ,
68- flutter_patched_sdk ,
69- " --target=flutter" ,
70- " --depfile" ,
71- rebase_path (snapshot_depfile ),
72- " --output-dill" ,
73- rebase_path (invoker .kernel_output ),
74- rebase_path (invoker .main_dart ),
75- ]
76-
77- if (flutter_prebuilt_dart_sdk ) {
78- action (target_name ) {
79- forward_variables_from (invoker ,
80- [
81- " visibility" ,
82- " testonly" ,
83- ],
84- [ " pool" ])
85- deps = common_deps
86- pool = " //flutter/build/dart:dart_pool"
87- script = " //build/gn_run_binary.py"
88- inputs = [ invoker .main_dart ]
89- outputs = [ invoker .kernel_output ]
90- depfile = snapshot_depfile
91-
92- ext = " "
93- if (is_win ) {
94- ext = " .exe"
95- }
96- dart = rebase_path (" $host_prebuilt_dart_sdk /bin/dart$ext " , root_out_dir )
97- frontend_server =
98- rebase_path (" $root_gen_dir /frontend_server.dart.snapshot" )
99-
100- args = [ dart ] + common_vm_args + [ frontend_server ] + common_args
101- }
102- } else {
103- dart_action (target_name ) {
104- forward_variables_from (invoker ,
105- [
106- " visibility" ,
107- " testonly" ,
108- ],
109- [ " pool" ])
110- deps = common_deps
111- pool = " //flutter/build/dart:dart_pool"
112- script = " $root_gen_dir /frontend_server.dart.snapshot"
113- packages = rebase_path (invoker .package_config )
114- inputs = [ invoker .main_dart ]
115- outputs = [ invoker .kernel_output ]
116- depfile = snapshot_depfile
117- vm_args = common_vm_args
118- args = common_args
119- }
120- }
121- }
13+ frontend_server_files =
14+ exec_script (" //third_party/dart/tools/list_dart_files.py" ,
15+ [
16+ " absolute" ,
17+ rebase_path (" //flutter/flutter_frontend_server" ),
18+ ],
19+ " list lines" )
20+
21+ frontend_server_files +=
22+ exec_script (" //third_party/dart/tools/list_dart_files.py" ,
23+ [
24+ " absolute" ,
25+ rebase_path (" //third_party/dart/pkg" ),
26+ ],
27+ " list lines" )
12228
12329# Creates a dart kernel (dill) file suitable for use with gen_snapshot, as well
12430# as the app-jit, aot-elf, or aot-assembly snapshot for targeting Flutter on
@@ -142,38 +48,61 @@ template("flutter_snapshot") {
14248
14349 kernel_output = " $target_gen_dir /kernel_blob.bin"
14450
145- extra_frontend_server_args = []
146- if (is_aot ) {
147- extra_frontend_server_args += [
148- " --aot" ,
149- " --tfa" ,
51+ prebuilt_dart_action (kernel_target ) {
52+ script = " //flutter/flutter_frontend_server/bin/starter.dart"
53+
54+ main_dart = rebase_path (invoker .main_dart )
55+ package_config = rebase_path (invoker .package_config )
56+ flutter_patched_sdk = rebase_path (" $root_out_dir /flutter_patched_sdk" )
57+
58+ deps = [ " //flutter/lib/snapshot:strong_platform" ]
59+
60+ inputs = [
61+ main_dart ,
62+ package_config ,
63+ ] + frontend_server_files
64+
65+ outputs = [ kernel_output ]
66+
67+ depfile = " $kernel_output .d"
68+ abs_depfile = rebase_path (depfile )
69+ vm_args = [ " --disable-dart-dev" ]
70+
71+ args = [
72+ " --depfile=$abs_depfile " ,
73+ " --packages=" + rebase_path (package_config ),
74+ " --target=flutter" ,
75+ " --sdk-root=" + flutter_patched_sdk ,
76+ " --output-dill=" + rebase_path (kernel_output , root_build_dir ),
15077 ]
151- } else {
152- # --no-link-platform is only valid when --aot isn't specified
153- extra_frontend_server_args += [ " --no-link-platform" ]
154- }
15578
156- if (defined (invoker .product ) && invoker .product ) {
157- # Setting this flag in a non-product release build for AOT (a "profile"
158- # build) causes the vm service isolate code to be tree-shaken from an app.
159- # See the pragma on the entrypoint here:
160- #
161- # https://github.com/dart-lang/sdk/blob/main/sdk/lib/_internal/vm/bin/vmservice_io.dart#L240
162- #
163- # Also, this define excludes debugging and profiling code from Flutter.
164- extra_frontend_server_args += [ " -Ddart.vm.product=true" ]
165- } else {
166- if (flutter_runtime_mode == " profile" ) {
167- # The following define excludes debugging code from Flutter.
168- extra_frontend_server_args += [ " -Ddart.vm.profile=true" ]
79+ if (is_aot ) {
80+ args += [
81+ " --aot" ,
82+ " --tfa" ,
83+ ]
84+ } else {
85+ # --no-link-platform is only valid when --aot isn't specified
86+ args += [ " --no-link-platform" ]
87+ }
88+
89+ if (defined (invoker .product ) && invoker .product ) {
90+ # Setting this flag in a non-product release build for AOT (a "profile"
91+ # build) causes the vm service isolate code to be tree-shaken from an app.
92+ # See the pragma on the entrypoint here:
93+ #
94+ # https://github.com/dart-lang/sdk/blob/main/sdk/lib/_internal/vm/bin/vmservice_io.dart#L240
95+ #
96+ # Also, this define excludes debugging and profiling code from Flutter.
97+ args += [ " -Ddart.vm.product=true" ]
98+ } else {
99+ if (flutter_runtime_mode == " profile" ) {
100+ # The following define excludes debugging code from Flutter.
101+ args += [ " -Ddart.vm.profile=true" ]
102+ }
169103 }
170- }
171104
172- flutter_frontend_server (kernel_target ) {
173- main_dart = invoker .main_dart
174- package_config = invoker .package_config
175- kernel_output = kernel_output
176- extra_args = extra_frontend_server_args
105+ args += [ rebase_path (main_dart ) ]
177106 }
178107
179108 compiled_action (snapshot_target ) {
@@ -342,7 +271,7 @@ template("application_snapshot") {
342271 # Ensure the compiled appliation (e.g. frontend-server, ...) will use this
343272 # Dart SDK hash when consuming/producing kernel.
344273 #
345- # (Instead of ensuring every user of the "application_snapshot" passes its
274+ # (Instead of ensuring every user of the "application_snapshot" passes it's
346275 # own)
347276 snapshot_vm_args += [ " -Dsdk_hash=$sdk_hash " ]
348277
0 commit comments