diff --git a/frontend_server_client/CHANGELOG.md b/frontend_server_client/CHANGELOG.md index baedcf926..047c86e8a 100644 --- a/frontend_server_client/CHANGELOG.md +++ b/frontend_server_client/CHANGELOG.md @@ -1,7 +1,12 @@ -## 3.3.0-wip +## 4.0.0-wip -- Update Dart SDK constraint to `>=3.0.0 <4.0.0`. +- Update Dart SDK constraint to `^3.0.0`. - Support changes in the SDK layout for Dart 3.0. +- By default, start the frontend server from the AOT snapshot shipped in the + Dart SDK. +- Throw an `ArgumentError` when `FrontendServerClient.start` is called with the + `frontendServerPath` argument omitted and the `debug` argument set to true. +- Update `package:vm_service` constraint to `^14.0.0`. ## 3.2.0 diff --git a/frontend_server_client/lib/src/frontend_server_client.dart b/frontend_server_client/lib/src/frontend_server_client.dart index cd91511d5..3a62274a4 100644 --- a/frontend_server_client/lib/src/frontend_server_client.dart +++ b/frontend_server_client/lib/src/frontend_server_client.dart @@ -40,6 +40,15 @@ class FrontendServerClient { /// The [outputDillPath] determines where the primary output should be, and /// some targets may output additional files based on that file name (by /// adding file extensions for instance). + /// + /// When the [frontendServerPath] argument is provided, the frontend server + /// will be started from the specified file. The specified file can either be + /// a Dart source file or an AppJIT snapshot. + /// + /// When the [frontendServerPath] argument is provided, setting [debug] to + /// true permits debuggers to attach to the frontend server. When the + /// [frontendServerPath] argument is omitted, setting [debug] to true will + /// cause an [ArgumentError] to be thrown. static Future start( String entrypoint, String outputDillPath, @@ -60,9 +69,7 @@ class FrontendServerClient { List additionalSources = const [], String? nativeAssets, }) async { - var feServer = await Process.start(Platform.resolvedExecutable, [ - if (debug) '--observe', - frontendServerPath ?? _feServerPath, + final commonArguments = [ '--sdk-root', sdkRoot ?? sdkDir, '--platform=$platformKernel', @@ -90,7 +97,38 @@ class FrontendServerClient { '--native-assets', nativeAssets, ], - ]); + ]; + late final Process feServer; + if (frontendServerPath != null) { + feServer = await Process.start( + Platform.resolvedExecutable, + [ + if (debug) '--observe', + frontendServerPath, + ...commonArguments, + ], + ); + } else if (File(_feServerAotSnapshotPath).existsSync()) { + if (debug) { + throw ArgumentError('The debug argument cannot be set to true when the ' + 'frontendServerPath argument is omitted.'); + } + feServer = await Process.start( + _dartAotRuntimePath, + [_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, + [ + if (debug) '--observe', + _feServerAppJitSnapshotPath, + ...commonArguments, + ], + ); + } var feServerStdoutLines = StreamQueue(feServer.stdout .transform(utf8.decoder) .transform(const LineSplitter())); @@ -407,5 +445,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'); diff --git a/frontend_server_client/pubspec.yaml b/frontend_server_client/pubspec.yaml index 5ef52a2f2..7f0657b70 100644 --- a/frontend_server_client/pubspec.yaml +++ b/frontend_server_client/pubspec.yaml @@ -1,5 +1,5 @@ name: frontend_server_client -version: 3.3.0-wip +version: 4.0.0-wip description: >- Client code to start and interact with the frontend_server compiler from the Dart SDK. @@ -20,4 +20,4 @@ dev_dependencies: test: ^1.16.0 test_descriptor: ^2.0.0 test_process: ^2.0.0 - vm_service: ^8.0.0 + vm_service: ^14.0.0 diff --git a/frontend_server_common/CHANGELOG.md b/frontend_server_common/CHANGELOG.md index aa64921d0..6704b3872 100644 --- a/frontend_server_common/CHANGELOG.md +++ b/frontend_server_common/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.2.2 + +- Start the frontend server from the AOT snapshot shipped in the Dart SDK. + ## 0.2.1 - Doe not pass `-debugger-module-names` flag to the frontend server. diff --git a/frontend_server_common/lib/src/frontend_server_client.dart b/frontend_server_common/lib/src/frontend_server_client.dart index aba399997..18b15b53e 100644 --- a/frontend_server_common/lib/src/frontend_server_client.dart +++ b/frontend_server_common/lib/src/frontend_server_client.dart @@ -398,7 +398,7 @@ class ResidentCompiler { _logger.info(args.join(' ')); final workingDirectory = projectDirectory.toFilePath(); - _server = await Process.start(sdkLayout.dartPath, args, + _server = await Process.start(sdkLayout.dartAotRuntimePath, args, workingDirectory: workingDirectory); var server = _server!; diff --git a/test_common/lib/test_sdk_layout.dart b/test_common/lib/test_sdk_layout.dart index 072bd3f1f..9064ce8e9 100644 --- a/test_common/lib/test_sdk_layout.dart +++ b/test_common/lib/test_sdk_layout.dart @@ -90,11 +90,16 @@ class TestSdkLayout { 'bin', Platform.isWindows ? 'dart.exe' : 'dart', ), + dartAotRuntimePath: p.join( + sdkLayout.sdkDirectory, + 'bin', + Platform.isWindows ? 'dartaotruntime.exe' : 'dartaotruntime', + ), frontendServerSnapshotPath: p.join( sdkLayout.sdkDirectory, 'bin', 'snapshots', - 'frontend_server.dart.snapshot', + 'frontend_server_aot.dart.snapshot', ), dartdevcSnapshotPath: sdkLayout.dartdevcSnapshotPath, kernelWorkerSnapshotPath: p.join( @@ -137,6 +142,7 @@ class TestSdkLayout { final String stackTraceMapperPath; final String dartPath; + final String dartAotRuntimePath; final String frontendServerSnapshotPath; final String dartdevcSnapshotPath; final String kernelWorkerSnapshotPath; @@ -155,6 +161,7 @@ class TestSdkLayout { required this.requireJsPath, required this.stackTraceMapperPath, required this.dartPath, + required this.dartAotRuntimePath, required this.frontendServerSnapshotPath, required this.dartdevcSnapshotPath, required this.kernelWorkerSnapshotPath, diff --git a/test_common/test/test_sdk_configuration_test.dart b/test_common/test/test_sdk_configuration_test.dart index 8a701fc45..1ff60ddee 100644 --- a/test_common/test/test_sdk_configuration_test.dart +++ b/test_common/test/test_sdk_configuration_test.dart @@ -70,6 +70,7 @@ void main() { expect(sdkLayout.stackTraceMapperPath, _fileExists); expect(sdkLayout.dartPath, _fileExists); + expect(sdkLayout.dartAotRuntimePath, _fileExists); expect(sdkLayout.frontendServerSnapshotPath, _fileExists); expect(sdkLayout.dartdevcSnapshotPath, _fileExists); expect(sdkLayout.kernelWorkerSnapshotPath, _fileExists);