Fix JS compilation to use the command 'compile js' instead of using snapshot names to invoke dart2js (#156735)
Fix JS compilation to use the command 'compile js' instead of using snapshot names to invoke dart2js The Dart SDK is switching all tools to use AOT snapshots instead of JIT snapshots and using snapshot names directly causes things to break.
This commit is contained in:
@@ -43,10 +43,6 @@ enum Artifact {
|
||||
engineDartAotRuntime,
|
||||
/// The snapshot of frontend_server compiler.
|
||||
frontendServerSnapshotForEngineDartSdk,
|
||||
/// The dart snapshot of the dart2js compiler.
|
||||
dart2jsSnapshot,
|
||||
/// The dart snapshot of the dart2wasm compiler.
|
||||
dart2wasmSnapshot,
|
||||
|
||||
/// The root of the Linux desktop sources.
|
||||
linuxDesktopPath,
|
||||
@@ -212,10 +208,6 @@ String? _artifactToFileName(Artifact artifact, Platform hostPlatform, [ BuildMod
|
||||
return 'dart$exe';
|
||||
case Artifact.engineDartAotRuntime:
|
||||
return 'dartaotruntime$exe';
|
||||
case Artifact.dart2jsSnapshot:
|
||||
return 'dart2js.dart.snapshot';
|
||||
case Artifact.dart2wasmSnapshot:
|
||||
return 'dart2wasm_product.snapshot';
|
||||
case Artifact.frontendServerSnapshotForEngineDartSdk:
|
||||
return 'frontend_server_aot.dart.snapshot';
|
||||
case Artifact.linuxDesktopPath:
|
||||
@@ -610,8 +602,6 @@ class CachedArtifacts implements Artifacts {
|
||||
case Artifact.engineDartSdkPath:
|
||||
case Artifact.engineDartBinary:
|
||||
case Artifact.engineDartAotRuntime:
|
||||
case Artifact.dart2jsSnapshot:
|
||||
case Artifact.dart2wasmSnapshot:
|
||||
case Artifact.frontendServerSnapshotForEngineDartSdk:
|
||||
case Artifact.constFinder:
|
||||
case Artifact.flutterFramework:
|
||||
@@ -662,8 +652,6 @@ class CachedArtifacts implements Artifacts {
|
||||
case Artifact.engineDartSdkPath:
|
||||
case Artifact.engineDartBinary:
|
||||
case Artifact.engineDartAotRuntime:
|
||||
case Artifact.dart2jsSnapshot:
|
||||
case Artifact.dart2wasmSnapshot:
|
||||
case Artifact.frontendServerSnapshotForEngineDartSdk:
|
||||
case Artifact.constFinder:
|
||||
case Artifact.flutterFramework:
|
||||
@@ -709,8 +697,6 @@ class CachedArtifacts implements Artifacts {
|
||||
case Artifact.engineDartSdkPath:
|
||||
case Artifact.engineDartBinary:
|
||||
case Artifact.engineDartAotRuntime:
|
||||
case Artifact.dart2jsSnapshot:
|
||||
case Artifact.dart2wasmSnapshot:
|
||||
case Artifact.frontendServerSnapshotForEngineDartSdk:
|
||||
case Artifact.constFinder:
|
||||
case Artifact.flutterMacOSFramework:
|
||||
@@ -773,8 +759,6 @@ class CachedArtifacts implements Artifacts {
|
||||
case Artifact.engineDartSdkPath:
|
||||
case Artifact.engineDartBinary:
|
||||
case Artifact.engineDartAotRuntime:
|
||||
case Artifact.dart2jsSnapshot:
|
||||
case Artifact.dart2wasmSnapshot:
|
||||
case Artifact.frontendServerSnapshotForEngineDartSdk:
|
||||
case Artifact.icuData:
|
||||
case Artifact.isolateSnapshotData:
|
||||
@@ -807,8 +791,6 @@ class CachedArtifacts implements Artifacts {
|
||||
// For script snapshots any gen_snapshot binary will do. Returning gen_snapshot for
|
||||
// android_arm in profile mode because it is available on all supported host platforms.
|
||||
return _getAndroidArtifactPath(artifact, TargetPlatform.android_arm, BuildMode.profile);
|
||||
case Artifact.dart2jsSnapshot:
|
||||
case Artifact.dart2wasmSnapshot:
|
||||
case Artifact.frontendServerSnapshotForEngineDartSdk:
|
||||
return _fileSystem.path.join(
|
||||
_dartSdkPath(_cache), 'bin', 'snapshots',
|
||||
@@ -1276,8 +1258,6 @@ class CachedLocalEngineArtifacts implements Artifacts {
|
||||
case Artifact.engineDartBinary:
|
||||
case Artifact.engineDartAotRuntime:
|
||||
return _fileSystem.path.join(_getDartSdkPath(), 'bin', artifactFileName);
|
||||
case Artifact.dart2jsSnapshot:
|
||||
case Artifact.dart2wasmSnapshot:
|
||||
case Artifact.frontendServerSnapshotForEngineDartSdk:
|
||||
return _fileSystem.path.join(_getDartSdkPath(), 'bin', 'snapshots', artifactFileName);
|
||||
case Artifact.flutterToolsFileGenerators:
|
||||
@@ -1410,8 +1390,6 @@ class CachedLocalWebSdkArtifacts implements Artifacts {
|
||||
return _fileSystem.path.join(
|
||||
_getDartSdkPath(), 'bin',
|
||||
_artifactToFileName(artifact, _platform, mode));
|
||||
case Artifact.dart2jsSnapshot:
|
||||
case Artifact.dart2wasmSnapshot:
|
||||
case Artifact.frontendServerSnapshotForEngineDartSdk:
|
||||
return _fileSystem.path.join(
|
||||
_getDartSdkPath(), 'bin', 'snapshots',
|
||||
|
||||
@@ -96,8 +96,6 @@ class WebEntrypointTarget extends Target {
|
||||
abstract class Dart2WebTarget extends Target {
|
||||
const Dart2WebTarget();
|
||||
|
||||
Source get compilerSnapshot;
|
||||
|
||||
WebCompilerConfig get compilerConfig;
|
||||
|
||||
Map<String, Object?> get buildConfig;
|
||||
@@ -126,7 +124,6 @@ abstract class Dart2WebTarget extends Target {
|
||||
@override
|
||||
List<Source> get inputs => <Source>[
|
||||
const Source.hostArtifact(HostArtifact.flutterWebSdk),
|
||||
compilerSnapshot,
|
||||
const Source.artifact(Artifact.engineDartBinary),
|
||||
const Source.pattern('{BUILD_DIR}/main.dart'),
|
||||
const Source.pattern('{WORKSPACE_DIR}/.dart_tool/package_config_subset'),
|
||||
@@ -151,9 +148,6 @@ class Dart2JSTarget extends Dart2WebTarget {
|
||||
@override
|
||||
String get name => 'dart2js';
|
||||
|
||||
@override
|
||||
Source get compilerSnapshot => const Source.artifact(Artifact.dart2jsSnapshot);
|
||||
|
||||
@override
|
||||
List<String> get depfiles => const <String>[
|
||||
'dart2js.d',
|
||||
@@ -170,7 +164,8 @@ class Dart2JSTarget extends Dart2WebTarget {
|
||||
final String platformBinariesPath = artifacts.getHostArtifact(HostArtifact.webPlatformKernelFolder).path;
|
||||
final List<String> sharedCommandOptions = <String>[
|
||||
artifacts.getArtifactPath(Artifact.engineDartBinary, platform: TargetPlatform.web_javascript),
|
||||
artifacts.getArtifactPath(Artifact.dart2jsSnapshot, platform: TargetPlatform.web_javascript),
|
||||
'compile',
|
||||
'js',
|
||||
'--platform-binaries=$platformBinariesPath',
|
||||
'--invoker=flutter_tool',
|
||||
...decodeCommaSeparated(environment.defines, kExtraFrontEndOptions),
|
||||
@@ -361,9 +356,6 @@ class Dart2WasmTarget extends Dart2WebTarget {
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Source get compilerSnapshot => const Source.artifact(Artifact.dart2wasmSnapshot);
|
||||
|
||||
@override
|
||||
String get name => 'dart2wasm';
|
||||
|
||||
|
||||
@@ -453,8 +453,8 @@ void setupFileSystemForEndToEndTest(FileSystem fileSystem) {
|
||||
final List<String> dependencies = <String>[
|
||||
fileSystem.path.join('packages', 'flutter_tools', 'lib', 'src', 'build_system', 'targets', 'web.dart'),
|
||||
fileSystem.path.join('bin', 'cache', 'flutter_web_sdk'),
|
||||
fileSystem.path.join('bin', 'cache', 'dart-sdk', 'bin', 'snapshots', 'dart2js.dart.snapshot'),
|
||||
fileSystem.path.join('bin', 'cache', 'dart-sdk', 'bin', 'dart'),
|
||||
fileSystem.path.join('bin', 'cache', 'dart-sdk', 'bin', 'dartaotruntime'),
|
||||
fileSystem.path.join('bin', 'cache', 'dart-sdk '),
|
||||
];
|
||||
for (final String dependency in dependencies) {
|
||||
|
||||
@@ -575,12 +575,6 @@ void main() {
|
||||
platform: TargetPlatform.web_javascript),
|
||||
throwsToolExit(message: failureMessage),
|
||||
);
|
||||
expect(
|
||||
() => artifacts.getArtifactPath(
|
||||
Artifact.dart2jsSnapshot,
|
||||
platform: TargetPlatform.web_javascript),
|
||||
throwsToolExit(message: failureMessage),
|
||||
);
|
||||
|
||||
fileSystem
|
||||
.directory('flutter')
|
||||
@@ -611,10 +605,9 @@ void main() {
|
||||
);
|
||||
expect(
|
||||
artifacts.getArtifactPath(
|
||||
Artifact.dart2jsSnapshot,
|
||||
Artifact.engineDartAotRuntime,
|
||||
platform: TargetPlatform.web_javascript),
|
||||
fileSystem.path.join('/flutter', 'prebuilts', 'linux-x64', 'dart-sdk',
|
||||
'bin', 'snapshots', 'dart2js.dart.snapshot'),
|
||||
fileSystem.path.join('/flutter', 'prebuilts', 'linux-x64', 'dart-sdk', 'bin', 'dartaotruntime'),
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
@@ -23,7 +23,8 @@ import '../../../src/testbed.dart';
|
||||
|
||||
const List<String> _kDart2jsLinuxArgs = <String>[
|
||||
'Artifact.engineDartBinary.TargetPlatform.web_javascript',
|
||||
'Artifact.dart2jsSnapshot.TargetPlatform.web_javascript',
|
||||
'compile',
|
||||
'js',
|
||||
'--platform-binaries=HostArtifact.webPlatformKernelFolder',
|
||||
'--invoker=flutter_tool',
|
||||
];
|
||||
|
||||
@@ -205,8 +205,8 @@ void setupFileSystemForEndToEndTest(FileSystem fileSystem) {
|
||||
fileSystem.path.join('lib', 'main.dart'),
|
||||
fileSystem.path.join('packages', 'flutter_tools', 'lib', 'src', 'build_system', 'targets', 'web.dart'),
|
||||
fileSystem.path.join('bin', 'cache', 'flutter_web_sdk'),
|
||||
fileSystem.path.join('bin', 'cache', 'dart-sdk', 'bin', 'snapshots', 'dart2js.dart.snapshot'),
|
||||
fileSystem.path.join('bin', 'cache', 'dart-sdk', 'bin', 'dart'),
|
||||
fileSystem.path.join('bin', 'cache', 'dart-sdk', 'bin', 'dartaotruntime'),
|
||||
fileSystem.path.join('bin', 'cache', 'dart-sdk '),
|
||||
];
|
||||
for (final String dependency in dependencies) {
|
||||
|
||||
Reference in New Issue
Block a user