diff --git a/packages/flutter_tools/lib/src/artifacts.dart b/packages/flutter_tools/lib/src/artifacts.dart index 8775db6fec1f..161e8b6ae7da 100644 --- a/packages/flutter_tools/lib/src/artifacts.dart +++ b/packages/flutter_tools/lib/src/artifacts.dart @@ -190,7 +190,7 @@ String? _artifactToFileName(Artifact artifact, Platform hostPlatform, [ BuildMod case Artifact.wasmOptBinary: return 'wasm-opt$exe'; case Artifact.frontendServerSnapshotForEngineDartSdk: - return 'frontend_server.dart.snapshot'; + return 'frontend_server_aot.dart.snapshot'; case Artifact.linuxDesktopPath: return ''; case Artifact.linuxHeaders: diff --git a/packages/flutter_tools/lib/src/build_system/targets/common.dart b/packages/flutter_tools/lib/src/build_system/targets/common.dart index d5febecf4251..c3507abb349a 100644 --- a/packages/flutter_tools/lib/src/build_system/targets/common.dart +++ b/packages/flutter_tools/lib/src/build_system/targets/common.dart @@ -132,6 +132,7 @@ class KernelSnapshot extends Target { Source.pattern('{FLUTTER_ROOT}/packages/flutter_tools/lib/src/build_system/targets/common.dart'), Source.artifact(Artifact.platformKernelDill), Source.artifact(Artifact.engineDartBinary), + Source.artifact(Artifact.engineDartAotRuntime), Source.artifact(Artifact.frontendServerSnapshotForEngineDartSdk), ]; diff --git a/packages/flutter_tools/lib/src/compile.dart b/packages/flutter_tools/lib/src/compile.dart index e7571a69eac3..15d209367f15 100644 --- a/packages/flutter_tools/lib/src/compile.dart +++ b/packages/flutter_tools/lib/src/compile.dart @@ -244,20 +244,10 @@ class KernelCompiler { String? nativeAssets, }) async { final TargetPlatform? platform = targetModel == TargetModel.dartdevc ? TargetPlatform.web_javascript : null; - final String frontendServer = (frontendServerStarterPath == null || frontendServerStarterPath.isEmpty) - ? _artifacts.getArtifactPath( - Artifact.frontendServerSnapshotForEngineDartSdk, - platform: platform, - ) - : frontendServerStarterPath; // This is a URI, not a file path, so the forward slash is correct even on Windows. if (!sdkRoot.endsWith('/')) { sdkRoot = '$sdkRoot/'; } - final String engineDartPath = _artifacts.getArtifactPath(Artifact.engineDartBinary, platform: platform); - if (!_processManager.canRun(engineDartPath)) { - throwToolExit('Unable to find Dart binary at $engineDartPath'); - } String? mainUri; final File mainFile = _fileSystem.file(mainPath); final Uri mainFileUri = mainFile.uri; @@ -282,10 +272,33 @@ class KernelCompiler { toMultiRootPath(dartPluginRegistrantFileUri, _fileSystemScheme, _fileSystemRoots, _fileSystem.path.separator == r'\'); } - final List command = [ - engineDartPath, - '--disable-dart-dev', - frontendServer, + final List commandToStartFrontendServer; + if (frontendServerStarterPath != null && frontendServerStarterPath.isNotEmpty) { + final String engineDartPath = _artifacts.getArtifactPath(Artifact.engineDartBinary, platform: platform); + if (!_processManager.canRun(engineDartPath)) { + throwToolExit('Unable to find Dart binary at $engineDartPath'); + } + commandToStartFrontendServer = [ + engineDartPath, + '--disable-dart-dev', + frontendServerStarterPath, + ]; + } else { + final String engineDartAotRuntimePath = _artifacts.getArtifactPath(Artifact.engineDartAotRuntime, platform: platform); + if (!_processManager.canRun(engineDartAotRuntimePath)) { + throwToolExit('Unable to find dartaotruntime binary at $engineDartAotRuntimePath'); + } + commandToStartFrontendServer = [ + engineDartAotRuntimePath, + '--disable-dart-dev', + _artifacts.getArtifactPath( + Artifact.frontendServerSnapshotForEngineDartSdk, + platform: platform, + ), + ]; + } + + final List command = commandToStartFrontendServer + [ '--sdk-root', sdkRoot, '--target=$targetModel', @@ -777,16 +790,25 @@ class DefaultResidentCompiler implements ResidentCompiler { String? nativeAssetsUri, }) async { final TargetPlatform? platform = (targetModel == TargetModel.dartdevc) ? TargetPlatform.web_javascript : null; - final String frontendServer = (frontendServerStarterPath == null || frontendServerStarterPath!.isEmpty) - ? artifacts.getArtifactPath( - Artifact.frontendServerSnapshotForEngineDartSdk, - platform: platform, - ) - : frontendServerStarterPath!; - final List command = [ - artifacts.getArtifactPath(Artifact.engineDartBinary, platform: platform), - '--disable-dart-dev', - frontendServer, + late final List commandToStartFrontendServer; + if (frontendServerStarterPath != null && frontendServerStarterPath!.isNotEmpty) { + commandToStartFrontendServer = [ + artifacts.getArtifactPath(Artifact.engineDartBinary, platform: platform), + '--disable-dart-dev', + frontendServerStarterPath!, + ]; + } else { + commandToStartFrontendServer = [ + artifacts.getArtifactPath(Artifact.engineDartAotRuntime, platform: platform), + '--disable-dart-dev', + artifacts.getArtifactPath( + Artifact.frontendServerSnapshotForEngineDartSdk, + platform: platform, + ), + ]; + } + + final List command = commandToStartFrontendServer + [ '--sdk-root', sdkRoot, '--incremental', diff --git a/packages/flutter_tools/test/general.shard/artifacts_test.dart b/packages/flutter_tools/test/general.shard/artifacts_test.dart index 920980a23ba2..dc39ffe002c8 100644 --- a/packages/flutter_tools/test/general.shard/artifacts_test.dart +++ b/packages/flutter_tools/test/general.shard/artifacts_test.dart @@ -143,7 +143,8 @@ void main() { ); expect( artifacts.getArtifactPath(Artifact.frontendServerSnapshotForEngineDartSdk), - fileSystem.path.join('root', 'bin', 'cache', 'dart-sdk', 'bin', 'snapshots', 'frontend_server.dart.snapshot') + fileSystem.path.join('root', 'bin', 'cache', 'dart-sdk', 'bin', + 'snapshots', 'frontend_server_aot.dart.snapshot') ); }); @@ -325,7 +326,7 @@ void main() { expect( artifacts.getArtifactPath(Artifact.frontendServerSnapshotForEngineDartSdk), fileSystem.path.join('/out', 'host_debug_unopt', 'dart-sdk', 'bin', - 'snapshots', 'frontend_server.dart.snapshot') + 'snapshots', 'frontend_server_aot.dart.snapshot') ); @@ -397,7 +398,7 @@ void main() { Artifact.frontendServerSnapshotForEngineDartSdk, platform: TargetPlatform.web_javascript), fileSystem.path.join('/flutter', 'prebuilts', 'linux-x64', 'dart-sdk', 'bin', - 'snapshots', 'frontend_server.dart.snapshot'), + 'snapshots', 'frontend_server_aot.dart.snapshot'), ); expect( artifacts.getArtifactPath( diff --git a/packages/flutter_tools/test/general.shard/build_system/targets/common_test.dart b/packages/flutter_tools/test/general.shard/build_system/targets/common_test.dart index a287f1b0d092..0b05203de252 100644 --- a/packages/flutter_tools/test/general.shard/build_system/targets/common_test.dart +++ b/packages/flutter_tools/test/general.shard/build_system/targets/common_test.dart @@ -94,7 +94,7 @@ native-assets: {} ); processManager.addCommands([ FakeCommand(command: [ - artifacts.getArtifactPath(Artifact.engineDartBinary), + artifacts.getArtifactPath(Artifact.engineDartAotRuntime), '--disable-dart-dev', artifacts.getArtifactPath(Artifact.frontendServerSnapshotForEngineDartSdk), '--sdk-root', @@ -139,7 +139,7 @@ native-assets: {} ); processManager.addCommands([ FakeCommand(command: [ - artifacts.getArtifactPath(Artifact.engineDartBinary), + artifacts.getArtifactPath(Artifact.engineDartAotRuntime), '--disable-dart-dev', artifacts.getArtifactPath(Artifact.frontendServerSnapshotForEngineDartSdk), '--sdk-root', @@ -185,7 +185,7 @@ native-assets: {} ); processManager.addCommands([ FakeCommand(command: [ - artifacts.getArtifactPath(Artifact.engineDartBinary), + artifacts.getArtifactPath(Artifact.engineDartAotRuntime), '--disable-dart-dev', artifacts.getArtifactPath(Artifact.frontendServerSnapshotForEngineDartSdk), '--sdk-root', @@ -279,7 +279,7 @@ native-assets: {} ); processManager.addCommands([ FakeCommand(command: [ - artifacts.getArtifactPath(Artifact.engineDartBinary), + artifacts.getArtifactPath(Artifact.engineDartAotRuntime), '--disable-dart-dev', artifacts.getArtifactPath(Artifact.frontendServerSnapshotForEngineDartSdk), '--sdk-root', @@ -328,7 +328,7 @@ native-assets: {} ); processManager.addCommands([ FakeCommand(command: [ - artifacts.getArtifactPath(Artifact.engineDartBinary), + artifacts.getArtifactPath(Artifact.engineDartAotRuntime), '--disable-dart-dev', artifacts.getArtifactPath(Artifact.frontendServerSnapshotForEngineDartSdk), '--sdk-root', @@ -375,7 +375,7 @@ native-assets: {} ); processManager.addCommands([ FakeCommand(command: [ - artifacts.getArtifactPath(Artifact.engineDartBinary), + artifacts.getArtifactPath(Artifact.engineDartAotRuntime), '--disable-dart-dev', artifacts.getArtifactPath(Artifact.frontendServerSnapshotForEngineDartSdk), '--sdk-root', @@ -434,7 +434,7 @@ native-assets: {} ); processManager.addCommands([ FakeCommand(command: [ - artifacts.getArtifactPath(Artifact.engineDartBinary), + artifacts.getArtifactPath(Artifact.engineDartAotRuntime), '--disable-dart-dev', artifacts.getArtifactPath(Artifact.frontendServerSnapshotForEngineDartSdk), '--sdk-root', diff --git a/packages/flutter_tools/test/general.shard/compile_batch_test.dart b/packages/flutter_tools/test/general.shard/compile_batch_test.dart index e82fb93fe600..9d2ad2a8868f 100644 --- a/packages/flutter_tools/test/general.shard/compile_batch_test.dart +++ b/packages/flutter_tools/test/general.shard/compile_batch_test.dart @@ -53,7 +53,7 @@ void main() { logger: logger, processManager: FakeProcessManager.list([ FakeCommand(command: const [ - 'Artifact.engineDartBinary', + 'Artifact.engineDartAotRuntime', '--disable-dart-dev', 'Artifact.frontendServerSnapshotForEngineDartSdk', '--sdk-root', @@ -99,7 +99,7 @@ void main() { logger: logger, processManager: FakeProcessManager.list([ FakeCommand(command: const [ - 'Artifact.engineDartBinary', + 'Artifact.engineDartAotRuntime', '--disable-dart-dev', 'Artifact.frontendServerSnapshotForEngineDartSdk', '--sdk-root', @@ -145,7 +145,7 @@ void main() { logger: logger, processManager: FakeProcessManager.list([ FakeCommand(command: const [ - 'Artifact.engineDartBinary', + 'Artifact.engineDartAotRuntime', '--disable-dart-dev', 'Artifact.frontendServerSnapshotForEngineDartSdk', '--sdk-root', @@ -191,7 +191,7 @@ void main() { logger: logger, processManager: FakeProcessManager.list([ FakeCommand(command: const [ - 'Artifact.engineDartBinary', + 'Artifact.engineDartAotRuntime', '--disable-dart-dev', 'Artifact.frontendServerSnapshotForEngineDartSdk', '--sdk-root', @@ -239,7 +239,7 @@ void main() { logger: logger, processManager: FakeProcessManager.list([ FakeCommand(command: const [ - 'Artifact.engineDartBinary', + 'Artifact.engineDartAotRuntime', '--disable-dart-dev', 'Artifact.frontendServerSnapshotForEngineDartSdk', '--sdk-root', @@ -287,7 +287,7 @@ void main() { logger: logger, processManager: FakeProcessManager.list([ FakeCommand(command: const [ - 'Artifact.engineDartBinary', + 'Artifact.engineDartAotRuntime', '--disable-dart-dev', 'Artifact.frontendServerSnapshotForEngineDartSdk', '--sdk-root', @@ -339,7 +339,7 @@ void main() { logger: logger, processManager: FakeProcessManager.list([ FakeCommand(command: const [ - 'Artifact.engineDartBinary', + 'Artifact.engineDartAotRuntime', '--disable-dart-dev', 'Artifact.frontendServerSnapshotForEngineDartSdk', '--sdk-root', @@ -389,7 +389,7 @@ void main() { logger: logger, processManager: FakeProcessManager.list([ FakeCommand(command: const [ - 'Artifact.engineDartBinary', + 'Artifact.engineDartAotRuntime', '--disable-dart-dev', 'Artifact.frontendServerSnapshotForEngineDartSdk', '--sdk-root', @@ -449,7 +449,7 @@ void main() { logger: logger, processManager: FakeProcessManager.list([ FakeCommand(command: const [ - 'Artifact.engineDartBinary', + 'Artifact.engineDartAotRuntime', '--disable-dart-dev', 'Artifact.frontendServerSnapshotForEngineDartSdk', '--sdk-root', diff --git a/packages/flutter_tools/test/general.shard/compile_incremental_test.dart b/packages/flutter_tools/test/general.shard/compile_incremental_test.dart index adaa4c2a6b97..14749ae1d458 100644 --- a/packages/flutter_tools/test/general.shard/compile_incremental_test.dart +++ b/packages/flutter_tools/test/general.shard/compile_incremental_test.dart @@ -30,7 +30,7 @@ void main() { late FakeProcessManager fakeProcessManager; const List frontendServerCommand = [ - 'Artifact.engineDartBinary', + 'Artifact.engineDartAotRuntime', '--disable-dart-dev', 'Artifact.frontendServerSnapshotForEngineDartSdk', '--sdk-root', diff --git a/packages/flutter_tools/test/general.shard/test/web_test_compiler_test.dart b/packages/flutter_tools/test/general.shard/test/web_test_compiler_test.dart index 54f8be20c931..26ed691651c5 100644 --- a/packages/flutter_tools/test/general.shard/test/web_test_compiler_test.dart +++ b/packages/flutter_tools/test/general.shard/test/web_test_compiler_test.dart @@ -36,7 +36,7 @@ void main() { ); final FakeProcessManager processManager = FakeProcessManager.list([ FakeCommand(command: [ - 'Artifact.engineDartBinary.TargetPlatform.web_javascript', + 'Artifact.engineDartAotRuntime.TargetPlatform.web_javascript', '--disable-dart-dev', 'Artifact.frontendServerSnapshotForEngineDartSdk.TargetPlatform.web_javascript', '--sdk-root',