@@ -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, the value of the [debug]
51
+ /// argument is ignored.
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,34 @@ 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
+ ] +
109
+ commonArguments,
110
+ );
111
+ } else if (File (_feServerAotSnapshotPath).existsSync ()) {
112
+ feServer = await Process .start (
113
+ _dartAotRuntimePath,
114
+ < String > [_feServerAotSnapshotPath] + commonArguments,
115
+ );
116
+ } else {
117
+ // AOT snapshots cannot be generated on IA32, so we need this fallback
118
+ // branch until support for IA32 is dropped (https://dartbug.com/49969).
119
+ feServer = await Process .start (
120
+ Platform .resolvedExecutable,
121
+ < String > [
122
+ if (debug) '--observe' ,
123
+ _feServerAppJitSnapshotPath,
124
+ ] +
125
+ commonArguments,
126
+ );
127
+ }
94
128
var feServerStdoutLines = StreamQueue (feServer.stdout
95
129
.transform (utf8.decoder)
96
130
.transform (const LineSplitter ()));
@@ -407,5 +441,10 @@ enum _RejectState {
407
441
done,
408
442
}
409
443
410
- final _feServerPath =
444
+ final _dartAotRuntimePath = p.join (sdkDir, 'bin' , 'dartaotruntime' );
445
+
446
+ final _feServerAppJitSnapshotPath =
411
447
p.join (sdkDir, 'bin' , 'snapshots' , 'frontend_server.dart.snapshot' );
448
+
449
+ final _feServerAotSnapshotPath =
450
+ p.join (sdkDir, 'bin' , 'snapshots' , 'frontend_server_aot.dart.snapshot' );
0 commit comments