Skip to content

Commit

Permalink
Make FrontendServerClient start the frontend server from AOT snapshot…
Browse files Browse the repository at this point in the history
… by default
  • Loading branch information
derekxu16 committed Oct 24, 2023
1 parent 2d8e9c2 commit 19c0821
Showing 1 changed file with 35 additions and 5 deletions.
40 changes: 35 additions & 5 deletions frontend_server_client/lib/src/frontend_server_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,7 @@ class FrontendServerClient {
List<String> additionalSources = const [],
String? nativeAssets,
}) async {
var feServer = await Process.start(Platform.resolvedExecutable, [
if (debug) '--observe',
frontendServerPath ?? _feServerPath,
final commonArguments = <String>[
'--sdk-root',
sdkRoot ?? sdkDir,
'--platform=$platformKernel',
Expand Down Expand Up @@ -90,7 +88,34 @@ class FrontendServerClient {
'--native-assets',
nativeAssets,
],
]);
];
late final Process feServer;
if (frontendServerPath != null) {
feServer = await Process.start(
Platform.resolvedExecutable,
<String>[
if (debug) '--observe',
frontendServerPath,
] +
commonArguments,
);
} else if (File(_feServerAotSnapshotPath).existsSync()) {
feServer = await Process.start(
_dartAotRuntimePath,
<String>[_feServerAotSnapshotPath] + commonArguments,
);
} else {
// AOT snapshots cannot be generated on IA32, so we need this fallback
// branch until support for IA32 is dropped (https://dartbug.com/49969).
feServer = await Process.start(
Platform.resolvedExecutable,
<String>[
if (debug) '--observe',
_feServerAppJitSnapshotPath,
] +
commonArguments,
);
}
var feServerStdoutLines = StreamQueue(feServer.stdout
.transform(utf8.decoder)
.transform(const LineSplitter()));
Expand Down Expand Up @@ -407,5 +432,10 @@ enum _RejectState {
done,
}

final _feServerPath =
final _dartAotRuntimePath = p.join(sdkDir, 'bin', 'dartaotruntime');

final _feServerAppJitSnapshotPath =
p.join(sdkDir, 'bin', 'snapshots', 'frontend_server.dart.snapshot');

final _feServerAotSnapshotPath =
p.join(sdkDir, 'bin', 'snapshots', 'frontend_server_aot.dart.snapshot');

0 comments on commit 19c0821

Please sign in to comment.