@@ -40,6 +40,15 @@ class FrontendServerClient {
4040 /// The [outputDillPath] determines where the primary output should be, and
4141 /// some targets may output additional files based on that file name (by
4242 /// 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.
4352 static Future <FrontendServerClient > start (
4453 String entrypoint,
4554 String outputDillPath,
@@ -60,9 +69,7 @@ class FrontendServerClient {
6069 List <String > additionalSources = const [],
6170 String ? nativeAssets,
6271 }) async {
63- var feServer = await Process .start (Platform .resolvedExecutable, [
64- if (debug) '--observe' ,
65- frontendServerPath ?? _feServerPath,
72+ final commonArguments = < String > [
6673 '--sdk-root' ,
6774 sdkRoot ?? sdkDir,
6875 '--platform=$platformKernel ' ,
@@ -90,7 +97,38 @@ class FrontendServerClient {
9097 '--native-assets' ,
9198 nativeAssets,
9299 ],
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+ }
94132 var feServerStdoutLines = StreamQueue (feServer.stdout
95133 .transform (utf8.decoder)
96134 .transform (const LineSplitter ()));
@@ -407,5 +445,10 @@ enum _RejectState {
407445 done,
408446}
409447
410- final _feServerPath =
448+ final _dartAotRuntimePath = p.join (sdkDir, 'bin' , 'dartaotruntime' );
449+
450+ final _feServerAppJitSnapshotPath =
411451 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