@@ -40,6 +40,15 @@ class FrontendServerClient {
40
40
/// The [outputDillPath] determines where the primary output should be, and
41
41
/// some targets may output additional files based on that file name (by
42
42
/// adding file extensions for instance).
43
+ ///
44
+ /// When the [frontendServerPath] argument is provided, the frontend server
45
+ /// will be started from the specified file. The specified file can either be
46
+ /// a Dart source file or an AppJIT snapshot.
47
+ ///
48
+ /// When the [frontendServerPath] argument is provided, setting [debug] to
49
+ /// true permits debuggers to attach to the frontend server. When the
50
+ /// [frontendServerPath] argument is omitted, setting [debug] to true will
51
+ /// cause an [ArgumentError] to be thrown.
43
52
static Future <FrontendServerClient > start (
44
53
String entrypoint,
45
54
String outputDillPath,
@@ -60,9 +69,7 @@ class FrontendServerClient {
60
69
List <String > additionalSources = const [],
61
70
String ? nativeAssets,
62
71
}) async {
63
- var feServer = await Process .start (Platform .resolvedExecutable, [
64
- if (debug) '--observe' ,
65
- frontendServerPath ?? _feServerPath,
72
+ final commonArguments = < String > [
66
73
'--sdk-root' ,
67
74
sdkRoot ?? sdkDir,
68
75
'--platform=$platformKernel ' ,
@@ -90,7 +97,38 @@ class FrontendServerClient {
90
97
'--native-assets' ,
91
98
nativeAssets,
92
99
],
93
- ]);
100
+ ];
101
+ late final Process feServer;
102
+ if (frontendServerPath != null ) {
103
+ feServer = await Process .start (
104
+ Platform .resolvedExecutable,
105
+ < String > [
106
+ if (debug) '--observe' ,
107
+ frontendServerPath,
108
+ ...commonArguments,
109
+ ],
110
+ );
111
+ } else if (File (_feServerAotSnapshotPath).existsSync ()) {
112
+ if (debug) {
113
+ throw ArgumentError ('The debug argument cannot be set to true when the '
114
+ 'frontendServerPath argument is omitted.' );
115
+ }
116
+ feServer = await Process .start (
117
+ _dartAotRuntimePath,
118
+ < String > [_feServerAotSnapshotPath, ...commonArguments],
119
+ );
120
+ } else {
121
+ // AOT snapshots cannot be generated on IA32, so we need this fallback
122
+ // branch until support for IA32 is dropped (https://dartbug.com/49969).
123
+ feServer = await Process .start (
124
+ Platform .resolvedExecutable,
125
+ < String > [
126
+ if (debug) '--observe' ,
127
+ _feServerAppJitSnapshotPath,
128
+ ...commonArguments,
129
+ ],
130
+ );
131
+ }
94
132
var feServerStdoutLines = StreamQueue (feServer.stdout
95
133
.transform (utf8.decoder)
96
134
.transform (const LineSplitter ()));
@@ -407,5 +445,10 @@ enum _RejectState {
407
445
done,
408
446
}
409
447
410
- final _feServerPath =
448
+ final _dartAotRuntimePath = p.join (sdkDir, 'bin' , 'dartaotruntime' );
449
+
450
+ final _feServerAppJitSnapshotPath =
411
451
p.join (sdkDir, 'bin' , 'snapshots' , 'frontend_server.dart.snapshot' );
452
+
453
+ final _feServerAotSnapshotPath =
454
+ p.join (sdkDir, 'bin' , 'snapshots' , 'frontend_server_aot.dart.snapshot' );
0 commit comments