Unverified Commit 1a44710d authored by Derek Xu's avatar Derek Xu Committed by GitHub

Reland "Switch flutter_tools to run frontend server from AOT snapshot" (#136282)

This reverts commit a1639be4.
parent 58701ac2
...@@ -190,7 +190,7 @@ String? _artifactToFileName(Artifact artifact, Platform hostPlatform, [ BuildMod ...@@ -190,7 +190,7 @@ String? _artifactToFileName(Artifact artifact, Platform hostPlatform, [ BuildMod
case Artifact.wasmOptBinary: case Artifact.wasmOptBinary:
return 'wasm-opt$exe'; return 'wasm-opt$exe';
case Artifact.frontendServerSnapshotForEngineDartSdk: case Artifact.frontendServerSnapshotForEngineDartSdk:
return 'frontend_server.dart.snapshot'; return 'frontend_server_aot.dart.snapshot';
case Artifact.linuxDesktopPath: case Artifact.linuxDesktopPath:
return ''; return '';
case Artifact.linuxHeaders: case Artifact.linuxHeaders:
......
...@@ -132,6 +132,7 @@ class KernelSnapshot extends Target { ...@@ -132,6 +132,7 @@ class KernelSnapshot extends Target {
Source.pattern('{FLUTTER_ROOT}/packages/flutter_tools/lib/src/build_system/targets/common.dart'), Source.pattern('{FLUTTER_ROOT}/packages/flutter_tools/lib/src/build_system/targets/common.dart'),
Source.artifact(Artifact.platformKernelDill), Source.artifact(Artifact.platformKernelDill),
Source.artifact(Artifact.engineDartBinary), Source.artifact(Artifact.engineDartBinary),
Source.artifact(Artifact.engineDartAotRuntime),
Source.artifact(Artifact.frontendServerSnapshotForEngineDartSdk), Source.artifact(Artifact.frontendServerSnapshotForEngineDartSdk),
]; ];
......
...@@ -244,20 +244,10 @@ class KernelCompiler { ...@@ -244,20 +244,10 @@ class KernelCompiler {
String? nativeAssets, String? nativeAssets,
}) async { }) async {
final TargetPlatform? platform = targetModel == TargetModel.dartdevc ? TargetPlatform.web_javascript : null; 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. // This is a URI, not a file path, so the forward slash is correct even on Windows.
if (!sdkRoot.endsWith('/')) { if (!sdkRoot.endsWith('/')) {
sdkRoot = '$sdkRoot/'; 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; String? mainUri;
final File mainFile = _fileSystem.file(mainPath); final File mainFile = _fileSystem.file(mainPath);
final Uri mainFileUri = mainFile.uri; final Uri mainFileUri = mainFile.uri;
...@@ -282,10 +272,33 @@ class KernelCompiler { ...@@ -282,10 +272,33 @@ class KernelCompiler {
toMultiRootPath(dartPluginRegistrantFileUri, _fileSystemScheme, _fileSystemRoots, _fileSystem.path.separator == r'\'); toMultiRootPath(dartPluginRegistrantFileUri, _fileSystemScheme, _fileSystemRoots, _fileSystem.path.separator == r'\');
} }
final List<String> command = <String>[ final List<String> commandToStartFrontendServer;
engineDartPath, if (frontendServerStarterPath != null && frontendServerStarterPath.isNotEmpty) {
'--disable-dart-dev', final String engineDartPath = _artifacts.getArtifactPath(Artifact.engineDartBinary, platform: platform);
frontendServer, if (!_processManager.canRun(engineDartPath)) {
throwToolExit('Unable to find Dart binary at $engineDartPath');
}
commandToStartFrontendServer = <String>[
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 = <String>[
engineDartAotRuntimePath,
'--disable-dart-dev',
_artifacts.getArtifactPath(
Artifact.frontendServerSnapshotForEngineDartSdk,
platform: platform,
),
];
}
final List<String> command = commandToStartFrontendServer + <String>[
'--sdk-root', '--sdk-root',
sdkRoot, sdkRoot,
'--target=$targetModel', '--target=$targetModel',
...@@ -777,16 +790,25 @@ class DefaultResidentCompiler implements ResidentCompiler { ...@@ -777,16 +790,25 @@ class DefaultResidentCompiler implements ResidentCompiler {
String? nativeAssetsUri, String? nativeAssetsUri,
}) async { }) async {
final TargetPlatform? platform = (targetModel == TargetModel.dartdevc) ? TargetPlatform.web_javascript : null; final TargetPlatform? platform = (targetModel == TargetModel.dartdevc) ? TargetPlatform.web_javascript : null;
final String frontendServer = (frontendServerStarterPath == null || frontendServerStarterPath!.isEmpty) late final List<String> commandToStartFrontendServer;
? artifacts.getArtifactPath( if (frontendServerStarterPath != null && frontendServerStarterPath!.isNotEmpty) {
Artifact.frontendServerSnapshotForEngineDartSdk, commandToStartFrontendServer = <String>[
platform: platform, artifacts.getArtifactPath(Artifact.engineDartBinary, platform: platform),
) '--disable-dart-dev',
: frontendServerStarterPath!; frontendServerStarterPath!,
final List<String> command = <String>[ ];
artifacts.getArtifactPath(Artifact.engineDartBinary, platform: platform), } else {
'--disable-dart-dev', commandToStartFrontendServer = <String>[
frontendServer, artifacts.getArtifactPath(Artifact.engineDartAotRuntime, platform: platform),
'--disable-dart-dev',
artifacts.getArtifactPath(
Artifact.frontendServerSnapshotForEngineDartSdk,
platform: platform,
),
];
}
final List<String> command = commandToStartFrontendServer + <String>[
'--sdk-root', '--sdk-root',
sdkRoot, sdkRoot,
'--incremental', '--incremental',
......
...@@ -143,7 +143,8 @@ void main() { ...@@ -143,7 +143,8 @@ void main() {
); );
expect( expect(
artifacts.getArtifactPath(Artifact.frontendServerSnapshotForEngineDartSdk), 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() { ...@@ -325,7 +326,7 @@ void main() {
expect( expect(
artifacts.getArtifactPath(Artifact.frontendServerSnapshotForEngineDartSdk), artifacts.getArtifactPath(Artifact.frontendServerSnapshotForEngineDartSdk),
fileSystem.path.join('/out', 'host_debug_unopt', 'dart-sdk', 'bin', 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() { ...@@ -397,7 +398,7 @@ void main() {
Artifact.frontendServerSnapshotForEngineDartSdk, Artifact.frontendServerSnapshotForEngineDartSdk,
platform: TargetPlatform.web_javascript), platform: TargetPlatform.web_javascript),
fileSystem.path.join('/flutter', 'prebuilts', 'linux-x64', 'dart-sdk', 'bin', fileSystem.path.join('/flutter', 'prebuilts', 'linux-x64', 'dart-sdk', 'bin',
'snapshots', 'frontend_server.dart.snapshot'), 'snapshots', 'frontend_server_aot.dart.snapshot'),
); );
expect( expect(
artifacts.getArtifactPath( artifacts.getArtifactPath(
......
...@@ -94,7 +94,7 @@ native-assets: {} ...@@ -94,7 +94,7 @@ native-assets: {}
); );
processManager.addCommands(<FakeCommand>[ processManager.addCommands(<FakeCommand>[
FakeCommand(command: <String>[ FakeCommand(command: <String>[
artifacts.getArtifactPath(Artifact.engineDartBinary), artifacts.getArtifactPath(Artifact.engineDartAotRuntime),
'--disable-dart-dev', '--disable-dart-dev',
artifacts.getArtifactPath(Artifact.frontendServerSnapshotForEngineDartSdk), artifacts.getArtifactPath(Artifact.frontendServerSnapshotForEngineDartSdk),
'--sdk-root', '--sdk-root',
...@@ -139,7 +139,7 @@ native-assets: {} ...@@ -139,7 +139,7 @@ native-assets: {}
); );
processManager.addCommands(<FakeCommand>[ processManager.addCommands(<FakeCommand>[
FakeCommand(command: <String>[ FakeCommand(command: <String>[
artifacts.getArtifactPath(Artifact.engineDartBinary), artifacts.getArtifactPath(Artifact.engineDartAotRuntime),
'--disable-dart-dev', '--disable-dart-dev',
artifacts.getArtifactPath(Artifact.frontendServerSnapshotForEngineDartSdk), artifacts.getArtifactPath(Artifact.frontendServerSnapshotForEngineDartSdk),
'--sdk-root', '--sdk-root',
...@@ -185,7 +185,7 @@ native-assets: {} ...@@ -185,7 +185,7 @@ native-assets: {}
); );
processManager.addCommands(<FakeCommand>[ processManager.addCommands(<FakeCommand>[
FakeCommand(command: <String>[ FakeCommand(command: <String>[
artifacts.getArtifactPath(Artifact.engineDartBinary), artifacts.getArtifactPath(Artifact.engineDartAotRuntime),
'--disable-dart-dev', '--disable-dart-dev',
artifacts.getArtifactPath(Artifact.frontendServerSnapshotForEngineDartSdk), artifacts.getArtifactPath(Artifact.frontendServerSnapshotForEngineDartSdk),
'--sdk-root', '--sdk-root',
...@@ -279,7 +279,7 @@ native-assets: {} ...@@ -279,7 +279,7 @@ native-assets: {}
); );
processManager.addCommands(<FakeCommand>[ processManager.addCommands(<FakeCommand>[
FakeCommand(command: <String>[ FakeCommand(command: <String>[
artifacts.getArtifactPath(Artifact.engineDartBinary), artifacts.getArtifactPath(Artifact.engineDartAotRuntime),
'--disable-dart-dev', '--disable-dart-dev',
artifacts.getArtifactPath(Artifact.frontendServerSnapshotForEngineDartSdk), artifacts.getArtifactPath(Artifact.frontendServerSnapshotForEngineDartSdk),
'--sdk-root', '--sdk-root',
...@@ -328,7 +328,7 @@ native-assets: {} ...@@ -328,7 +328,7 @@ native-assets: {}
); );
processManager.addCommands(<FakeCommand>[ processManager.addCommands(<FakeCommand>[
FakeCommand(command: <String>[ FakeCommand(command: <String>[
artifacts.getArtifactPath(Artifact.engineDartBinary), artifacts.getArtifactPath(Artifact.engineDartAotRuntime),
'--disable-dart-dev', '--disable-dart-dev',
artifacts.getArtifactPath(Artifact.frontendServerSnapshotForEngineDartSdk), artifacts.getArtifactPath(Artifact.frontendServerSnapshotForEngineDartSdk),
'--sdk-root', '--sdk-root',
...@@ -375,7 +375,7 @@ native-assets: {} ...@@ -375,7 +375,7 @@ native-assets: {}
); );
processManager.addCommands(<FakeCommand>[ processManager.addCommands(<FakeCommand>[
FakeCommand(command: <String>[ FakeCommand(command: <String>[
artifacts.getArtifactPath(Artifact.engineDartBinary), artifacts.getArtifactPath(Artifact.engineDartAotRuntime),
'--disable-dart-dev', '--disable-dart-dev',
artifacts.getArtifactPath(Artifact.frontendServerSnapshotForEngineDartSdk), artifacts.getArtifactPath(Artifact.frontendServerSnapshotForEngineDartSdk),
'--sdk-root', '--sdk-root',
...@@ -434,7 +434,7 @@ native-assets: {} ...@@ -434,7 +434,7 @@ native-assets: {}
); );
processManager.addCommands(<FakeCommand>[ processManager.addCommands(<FakeCommand>[
FakeCommand(command: <String>[ FakeCommand(command: <String>[
artifacts.getArtifactPath(Artifact.engineDartBinary), artifacts.getArtifactPath(Artifact.engineDartAotRuntime),
'--disable-dart-dev', '--disable-dart-dev',
artifacts.getArtifactPath(Artifact.frontendServerSnapshotForEngineDartSdk), artifacts.getArtifactPath(Artifact.frontendServerSnapshotForEngineDartSdk),
'--sdk-root', '--sdk-root',
......
...@@ -53,7 +53,7 @@ void main() { ...@@ -53,7 +53,7 @@ void main() {
logger: logger, logger: logger,
processManager: FakeProcessManager.list(<FakeCommand>[ processManager: FakeProcessManager.list(<FakeCommand>[
FakeCommand(command: const <String>[ FakeCommand(command: const <String>[
'Artifact.engineDartBinary', 'Artifact.engineDartAotRuntime',
'--disable-dart-dev', '--disable-dart-dev',
'Artifact.frontendServerSnapshotForEngineDartSdk', 'Artifact.frontendServerSnapshotForEngineDartSdk',
'--sdk-root', '--sdk-root',
...@@ -99,7 +99,7 @@ void main() { ...@@ -99,7 +99,7 @@ void main() {
logger: logger, logger: logger,
processManager: FakeProcessManager.list(<FakeCommand>[ processManager: FakeProcessManager.list(<FakeCommand>[
FakeCommand(command: const <String>[ FakeCommand(command: const <String>[
'Artifact.engineDartBinary', 'Artifact.engineDartAotRuntime',
'--disable-dart-dev', '--disable-dart-dev',
'Artifact.frontendServerSnapshotForEngineDartSdk', 'Artifact.frontendServerSnapshotForEngineDartSdk',
'--sdk-root', '--sdk-root',
...@@ -145,7 +145,7 @@ void main() { ...@@ -145,7 +145,7 @@ void main() {
logger: logger, logger: logger,
processManager: FakeProcessManager.list(<FakeCommand>[ processManager: FakeProcessManager.list(<FakeCommand>[
FakeCommand(command: const <String>[ FakeCommand(command: const <String>[
'Artifact.engineDartBinary', 'Artifact.engineDartAotRuntime',
'--disable-dart-dev', '--disable-dart-dev',
'Artifact.frontendServerSnapshotForEngineDartSdk', 'Artifact.frontendServerSnapshotForEngineDartSdk',
'--sdk-root', '--sdk-root',
...@@ -191,7 +191,7 @@ void main() { ...@@ -191,7 +191,7 @@ void main() {
logger: logger, logger: logger,
processManager: FakeProcessManager.list(<FakeCommand>[ processManager: FakeProcessManager.list(<FakeCommand>[
FakeCommand(command: const <String>[ FakeCommand(command: const <String>[
'Artifact.engineDartBinary', 'Artifact.engineDartAotRuntime',
'--disable-dart-dev', '--disable-dart-dev',
'Artifact.frontendServerSnapshotForEngineDartSdk', 'Artifact.frontendServerSnapshotForEngineDartSdk',
'--sdk-root', '--sdk-root',
...@@ -239,7 +239,7 @@ void main() { ...@@ -239,7 +239,7 @@ void main() {
logger: logger, logger: logger,
processManager: FakeProcessManager.list(<FakeCommand>[ processManager: FakeProcessManager.list(<FakeCommand>[
FakeCommand(command: const <String>[ FakeCommand(command: const <String>[
'Artifact.engineDartBinary', 'Artifact.engineDartAotRuntime',
'--disable-dart-dev', '--disable-dart-dev',
'Artifact.frontendServerSnapshotForEngineDartSdk', 'Artifact.frontendServerSnapshotForEngineDartSdk',
'--sdk-root', '--sdk-root',
...@@ -287,7 +287,7 @@ void main() { ...@@ -287,7 +287,7 @@ void main() {
logger: logger, logger: logger,
processManager: FakeProcessManager.list(<FakeCommand>[ processManager: FakeProcessManager.list(<FakeCommand>[
FakeCommand(command: const <String>[ FakeCommand(command: const <String>[
'Artifact.engineDartBinary', 'Artifact.engineDartAotRuntime',
'--disable-dart-dev', '--disable-dart-dev',
'Artifact.frontendServerSnapshotForEngineDartSdk', 'Artifact.frontendServerSnapshotForEngineDartSdk',
'--sdk-root', '--sdk-root',
...@@ -339,7 +339,7 @@ void main() { ...@@ -339,7 +339,7 @@ void main() {
logger: logger, logger: logger,
processManager: FakeProcessManager.list(<FakeCommand>[ processManager: FakeProcessManager.list(<FakeCommand>[
FakeCommand(command: const <String>[ FakeCommand(command: const <String>[
'Artifact.engineDartBinary', 'Artifact.engineDartAotRuntime',
'--disable-dart-dev', '--disable-dart-dev',
'Artifact.frontendServerSnapshotForEngineDartSdk', 'Artifact.frontendServerSnapshotForEngineDartSdk',
'--sdk-root', '--sdk-root',
...@@ -389,7 +389,7 @@ void main() { ...@@ -389,7 +389,7 @@ void main() {
logger: logger, logger: logger,
processManager: FakeProcessManager.list(<FakeCommand>[ processManager: FakeProcessManager.list(<FakeCommand>[
FakeCommand(command: const <String>[ FakeCommand(command: const <String>[
'Artifact.engineDartBinary', 'Artifact.engineDartAotRuntime',
'--disable-dart-dev', '--disable-dart-dev',
'Artifact.frontendServerSnapshotForEngineDartSdk', 'Artifact.frontendServerSnapshotForEngineDartSdk',
'--sdk-root', '--sdk-root',
...@@ -449,7 +449,7 @@ void main() { ...@@ -449,7 +449,7 @@ void main() {
logger: logger, logger: logger,
processManager: FakeProcessManager.list(<FakeCommand>[ processManager: FakeProcessManager.list(<FakeCommand>[
FakeCommand(command: const <String>[ FakeCommand(command: const <String>[
'Artifact.engineDartBinary', 'Artifact.engineDartAotRuntime',
'--disable-dart-dev', '--disable-dart-dev',
'Artifact.frontendServerSnapshotForEngineDartSdk', 'Artifact.frontendServerSnapshotForEngineDartSdk',
'--sdk-root', '--sdk-root',
......
...@@ -30,7 +30,7 @@ void main() { ...@@ -30,7 +30,7 @@ void main() {
late FakeProcessManager fakeProcessManager; late FakeProcessManager fakeProcessManager;
const List<String> frontendServerCommand = <String>[ const List<String> frontendServerCommand = <String>[
'Artifact.engineDartBinary', 'Artifact.engineDartAotRuntime',
'--disable-dart-dev', '--disable-dart-dev',
'Artifact.frontendServerSnapshotForEngineDartSdk', 'Artifact.frontendServerSnapshotForEngineDartSdk',
'--sdk-root', '--sdk-root',
......
...@@ -36,7 +36,7 @@ void main() { ...@@ -36,7 +36,7 @@ void main() {
); );
final FakeProcessManager processManager = FakeProcessManager.list(<FakeCommand>[ final FakeProcessManager processManager = FakeProcessManager.list(<FakeCommand>[
FakeCommand(command: <Pattern>[ FakeCommand(command: <Pattern>[
'Artifact.engineDartBinary.TargetPlatform.web_javascript', 'Artifact.engineDartAotRuntime.TargetPlatform.web_javascript',
'--disable-dart-dev', '--disable-dart-dev',
'Artifact.frontendServerSnapshotForEngineDartSdk.TargetPlatform.web_javascript', 'Artifact.frontendServerSnapshotForEngineDartSdk.TargetPlatform.web_javascript',
'--sdk-root', '--sdk-root',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment