[flutter_tools] use correct sdk path for analysis (#58871)
flutter analyze was unconditionally using the cached dart-sdk for analysis, and was not running with the built SDK during local engine. This broke when trying to update the analyzer for null safety, since it required us to wait for the dart change to roll into the framework first.
This commit is contained in:
@@ -10,7 +10,6 @@ import 'base/platform.dart';
|
||||
import 'base/utils.dart';
|
||||
import 'build_info.dart';
|
||||
import 'cache.dart';
|
||||
import 'dart/sdk.dart';
|
||||
import 'globals.dart' as globals;
|
||||
|
||||
enum Artifact {
|
||||
@@ -339,9 +338,9 @@ class CachedArtifacts extends Artifacts {
|
||||
final String platformDirName = getNameForTargetPlatform(platform);
|
||||
return _fileSystem.path.join(engineArtifactsPath, platformDirName, _artifactToFileName(artifact, platform, mode));
|
||||
case Artifact.engineDartSdkPath:
|
||||
return dartSdkPath;
|
||||
return _dartSdkPath(_fileSystem);
|
||||
case Artifact.engineDartBinary:
|
||||
return _fileSystem.path.join(dartSdkPath, 'bin', _artifactToFileName(artifact, platform));
|
||||
return _fileSystem.path.join(_dartSdkPath(_fileSystem), 'bin', _artifactToFileName(artifact, platform));
|
||||
case Artifact.platformKernelDill:
|
||||
return _fileSystem.path.join(_getFlutterPatchedSdkPath(mode), _artifactToFileName(artifact));
|
||||
case Artifact.platformLibrariesJson:
|
||||
@@ -355,11 +354,11 @@ class CachedArtifacts extends Artifacts {
|
||||
case Artifact.webPlatformKernelDill:
|
||||
return _fileSystem.path.join(_getFlutterWebSdkPath(), 'kernel', _artifactToFileName(artifact));
|
||||
case Artifact.dart2jsSnapshot:
|
||||
return _fileSystem.path.join(dartSdkPath, 'bin', 'snapshots', _artifactToFileName(artifact));
|
||||
return _fileSystem.path.join(_dartSdkPath(_fileSystem), 'bin', 'snapshots', _artifactToFileName(artifact));
|
||||
case Artifact.dartdevcSnapshot:
|
||||
return _fileSystem.path.join(dartSdkPath, 'bin', 'snapshots', _artifactToFileName(artifact));
|
||||
return _fileSystem.path.join(_dartSdkPath(_fileSystem), 'bin', 'snapshots', _artifactToFileName(artifact));
|
||||
case Artifact.kernelWorkerSnapshot:
|
||||
return _fileSystem.path.join(dartSdkPath, 'bin', 'snapshots', _artifactToFileName(artifact));
|
||||
return _fileSystem.path.join(_dartSdkPath(_fileSystem), 'bin', 'snapshots', _artifactToFileName(artifact));
|
||||
case Artifact.flutterMacOSFramework:
|
||||
case Artifact.linuxDesktopPath:
|
||||
case Artifact.windowsDesktopPath:
|
||||
@@ -528,7 +527,7 @@ class LocalEngineArtifacts extends Artifacts {
|
||||
case Artifact.dart2jsSnapshot:
|
||||
return _fileSystem.path.join(_hostEngineOutPath, 'dart-sdk', 'bin', 'snapshots', artifactFileName);
|
||||
case Artifact.dartdevcSnapshot:
|
||||
return _fileSystem.path.join(dartSdkPath, 'bin', 'snapshots', artifactFileName);
|
||||
return _fileSystem.path.join(_dartSdkPath(_fileSystem), 'bin', 'snapshots', artifactFileName);
|
||||
case Artifact.kernelWorkerSnapshot:
|
||||
return _fileSystem.path.join(_hostEngineOutPath, 'dart-sdk', 'bin', 'snapshots', artifactFileName);
|
||||
case Artifact.idevicescreenshot:
|
||||
@@ -661,3 +660,8 @@ class OverrideArtifacts implements Artifacts {
|
||||
@override
|
||||
bool get isLocalEngine => parent.isLocalEngine;
|
||||
}
|
||||
|
||||
/// Locate the Dart SDK.
|
||||
String _dartSdkPath(FileSystem fileSystem) {
|
||||
return fileSystem.path.join(Cache.flutterRoot, 'bin', 'cache', 'dart-sdk');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user