mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00
[flutter_tools] migrate artifacts to null safety (#83073)
This commit is contained in:
parent
31e755452c
commit
b891adb4bd
@ -2,8 +2,6 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// @dart = 2.8
|
||||
|
||||
import 'package:file/memory.dart';
|
||||
import 'package:meta/meta.dart';
|
||||
import 'package:process/process.dart';
|
||||
@ -114,7 +112,31 @@ String _enginePlatformDirectoryName(TargetPlatform platform) {
|
||||
return getNameForTargetPlatform(platform);
|
||||
}
|
||||
|
||||
bool _isWindows(TargetPlatform platform) {
|
||||
// Remove android target platform type.
|
||||
TargetPlatform? _mapTargetPlatform(TargetPlatform? targetPlatform) {
|
||||
switch (targetPlatform) {
|
||||
case TargetPlatform.android:
|
||||
return TargetPlatform.android_arm64;
|
||||
case TargetPlatform.ios:
|
||||
case TargetPlatform.darwin:
|
||||
case TargetPlatform.linux_x64:
|
||||
case TargetPlatform.linux_arm64:
|
||||
case TargetPlatform.windows_x64:
|
||||
case TargetPlatform.windows_uwp_x64:
|
||||
case TargetPlatform.fuchsia_arm64:
|
||||
case TargetPlatform.fuchsia_x64:
|
||||
case TargetPlatform.tester:
|
||||
case TargetPlatform.web_javascript:
|
||||
case TargetPlatform.android_arm:
|
||||
case TargetPlatform.android_arm64:
|
||||
case TargetPlatform.android_x64:
|
||||
case TargetPlatform.android_x86:
|
||||
case null:
|
||||
return targetPlatform;
|
||||
}
|
||||
}
|
||||
|
||||
bool _isWindows(TargetPlatform? platform) {
|
||||
switch (platform) {
|
||||
case TargetPlatform.windows_x64:
|
||||
case TargetPlatform.windows_uwp_x64:
|
||||
@ -132,12 +154,12 @@ bool _isWindows(TargetPlatform platform) {
|
||||
case TargetPlatform.linux_x64:
|
||||
case TargetPlatform.tester:
|
||||
case TargetPlatform.web_javascript:
|
||||
case null:
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
String _artifactToFileName(Artifact artifact, [ TargetPlatform platform, BuildMode mode ]) {
|
||||
String? _artifactToFileName(Artifact artifact, [ TargetPlatform? platform, BuildMode? mode ]) {
|
||||
final String exe = _isWindows(platform) ? '.exe' : '';
|
||||
switch (artifact) {
|
||||
case Artifact.genSnapshot:
|
||||
@ -181,7 +203,7 @@ String _artifactToFileName(Artifact artifact, [ TargetPlatform platform, BuildMo
|
||||
case Artifact.fuchsiaKernelCompiler:
|
||||
return 'kernel_compiler.snapshot';
|
||||
case Artifact.fuchsiaFlutterRunner:
|
||||
final String jitOrAot = mode.isJit ? '_jit' : '_aot';
|
||||
final String jitOrAot = mode!.isJit ? '_jit' : '_aot';
|
||||
final String productOrNo = mode.isRelease ? '_product' : '';
|
||||
return 'flutter$jitOrAot${productOrNo}_runner-0.far';
|
||||
case Artifact.fontSubset:
|
||||
@ -191,8 +213,6 @@ String _artifactToFileName(Artifact artifact, [ TargetPlatform platform, BuildMo
|
||||
case Artifact.uwptool:
|
||||
return 'uwptool$exe';
|
||||
}
|
||||
assert(false, 'Invalid artifact $artifact.');
|
||||
return null;
|
||||
}
|
||||
|
||||
String _hostArtifactToFileName(HostArtifact artifact, bool windows) {
|
||||
@ -246,14 +266,12 @@ String _hostArtifactToFileName(HostArtifact artifact, bool windows) {
|
||||
}
|
||||
return 'pub';
|
||||
}
|
||||
assert(false, 'Invalid artifact $artifact.');
|
||||
return null;
|
||||
}
|
||||
|
||||
class EngineBuildPaths {
|
||||
const EngineBuildPaths({
|
||||
@required this.targetEngine,
|
||||
@required this.hostEngine,
|
||||
required this.targetEngine,
|
||||
required this.hostEngine,
|
||||
}) : assert(targetEngine != null),
|
||||
assert(hostEngine != null);
|
||||
|
||||
@ -270,7 +288,7 @@ abstract class Artifacts {
|
||||
///
|
||||
/// Creates a [LocalEngineArtifacts] if `localEngine` is non-null
|
||||
@visibleForTesting
|
||||
factory Artifacts.test({String localEngine, FileSystem fileSystem}) {
|
||||
factory Artifacts.test({String? localEngine, FileSystem? fileSystem}) {
|
||||
fileSystem ??= MemoryFileSystem.test();
|
||||
if (localEngine != null) {
|
||||
return _TestLocalEngine(localEngine, fileSystem);
|
||||
@ -293,9 +311,9 @@ abstract class Artifacts {
|
||||
/// Returns the requested [artifact] for the [platform], [mode], and [environmentType] combination.
|
||||
String getArtifactPath(
|
||||
Artifact artifact, {
|
||||
TargetPlatform platform,
|
||||
BuildMode mode,
|
||||
EnvironmentType environmentType,
|
||||
TargetPlatform? platform,
|
||||
BuildMode? mode,
|
||||
EnvironmentType? environmentType,
|
||||
});
|
||||
|
||||
/// Retrieve a host specific artifact that does not depend on the
|
||||
@ -306,7 +324,7 @@ abstract class Artifacts {
|
||||
|
||||
// Returns which set of engine artifacts is currently used for the [platform]
|
||||
// and [mode] combination.
|
||||
String getEngineType(TargetPlatform platform, [ BuildMode mode ]);
|
||||
String getEngineType(TargetPlatform platform, [ BuildMode? mode ]);
|
||||
|
||||
/// Whether these artifacts correspond to a non-versioned local engine.
|
||||
bool get isLocalEngine;
|
||||
@ -315,10 +333,10 @@ abstract class Artifacts {
|
||||
/// Manages the engine artifacts downloaded to the local cache.
|
||||
class CachedArtifacts implements Artifacts {
|
||||
CachedArtifacts({
|
||||
@required FileSystem fileSystem,
|
||||
@required Platform platform,
|
||||
@required Cache cache,
|
||||
@required OperatingSystemUtils operatingSystemUtils,
|
||||
required FileSystem fileSystem,
|
||||
required Platform platform,
|
||||
required Cache cache,
|
||||
required OperatingSystemUtils operatingSystemUtils,
|
||||
}) : _fileSystem = fileSystem,
|
||||
_platform = platform,
|
||||
_cache = cache,
|
||||
@ -380,7 +398,6 @@ class CachedArtifacts implements Artifacts {
|
||||
case HostArtifact.idevicescreenshot:
|
||||
final String artifactFileName = _hostArtifactToFileName(artifact, _platform.isWindows);
|
||||
return _cache.getArtifactDirectory('libimobiledevice').childFile(artifactFileName);
|
||||
break;
|
||||
case HostArtifact.skyEnginePath:
|
||||
final Directory dartPackageDirectory = _cache.getCacheDir('pkg');
|
||||
final String path = _fileSystem.path.join(dartPackageDirectory.path, _hostArtifactToFileName(artifact, _platform.isWindows));
|
||||
@ -400,25 +417,24 @@ class CachedArtifacts implements Artifacts {
|
||||
final String artifactFileName = _hostArtifactToFileName(artifact, _platform.isWindows);
|
||||
return _cache.getArtifactDirectory('usbmuxd').childFile(artifactFileName);
|
||||
}
|
||||
assert(false);
|
||||
return null;
|
||||
}
|
||||
|
||||
@override
|
||||
String getArtifactPath(
|
||||
Artifact artifact, {
|
||||
TargetPlatform platform,
|
||||
BuildMode mode,
|
||||
EnvironmentType environmentType,
|
||||
TargetPlatform? platform,
|
||||
BuildMode? mode,
|
||||
EnvironmentType? environmentType,
|
||||
}) {
|
||||
platform = _mapTargetPlatform(platform);
|
||||
switch (platform) {
|
||||
case TargetPlatform.android_arm:
|
||||
case TargetPlatform.android_arm64:
|
||||
case TargetPlatform.android_x64:
|
||||
case TargetPlatform.android_x86:
|
||||
return _getAndroidArtifactPath(artifact, platform, mode);
|
||||
return _getAndroidArtifactPath(artifact, platform!, mode!);
|
||||
case TargetPlatform.ios:
|
||||
return _getIosArtifactPath(artifact, platform, mode, environmentType);
|
||||
return _getIosArtifactPath(artifact, platform!, mode, environmentType);
|
||||
case TargetPlatform.darwin:
|
||||
case TargetPlatform.linux_x64:
|
||||
case TargetPlatform.linux_arm64:
|
||||
@ -427,7 +443,7 @@ class CachedArtifacts implements Artifacts {
|
||||
return _getDesktopArtifactPath(artifact, platform, mode);
|
||||
case TargetPlatform.fuchsia_arm64:
|
||||
case TargetPlatform.fuchsia_x64:
|
||||
return _getFuchsiaArtifactPath(artifact, platform, mode);
|
||||
return _getFuchsiaArtifactPath(artifact, platform!, mode!);
|
||||
case TargetPlatform.tester:
|
||||
case TargetPlatform.web_javascript:
|
||||
default: // could be null, but that can't be specified as a case.
|
||||
@ -436,22 +452,22 @@ class CachedArtifacts implements Artifacts {
|
||||
}
|
||||
|
||||
@override
|
||||
String getEngineType(TargetPlatform platform, [ BuildMode mode ]) {
|
||||
return _fileSystem.path.basename(_getEngineArtifactsPath(platform, mode));
|
||||
String getEngineType(TargetPlatform platform, [ BuildMode? mode ]) {
|
||||
return _fileSystem.path.basename(_getEngineArtifactsPath(platform, mode)!);
|
||||
}
|
||||
|
||||
String _getDesktopArtifactPath(Artifact artifact, TargetPlatform platform, BuildMode mode) {
|
||||
String _getDesktopArtifactPath(Artifact artifact, TargetPlatform? platform, BuildMode? mode) {
|
||||
// When platform is null, a generic host platform artifact is being requested
|
||||
// and not the gen_snapshot for darwin as a target platform.
|
||||
if (platform != null && artifact == Artifact.genSnapshot) {
|
||||
final String engineDir = _getEngineArtifactsPath(platform, mode);
|
||||
final String engineDir = _getEngineArtifactsPath(platform, mode)!;
|
||||
return _fileSystem.path.join(engineDir, _artifactToFileName(artifact));
|
||||
}
|
||||
return _getHostArtifactPath(artifact, platform ?? _currentHostPlatform(_platform, _operatingSystemUtils), mode);
|
||||
}
|
||||
|
||||
String _getAndroidArtifactPath(Artifact artifact, TargetPlatform platform, BuildMode mode) {
|
||||
final String engineDir = _getEngineArtifactsPath(platform, mode);
|
||||
final String engineDir = _getEngineArtifactsPath(platform, mode)!;
|
||||
switch (artifact) {
|
||||
case Artifact.frontendServerSnapshotForEngineDartSdk:
|
||||
assert(mode != BuildMode.debug, 'Artifact $artifact only available in non-debug mode.');
|
||||
@ -465,17 +481,16 @@ class CachedArtifacts implements Artifacts {
|
||||
}
|
||||
}
|
||||
|
||||
String _getIosArtifactPath(Artifact artifact, TargetPlatform platform,
|
||||
BuildMode mode, EnvironmentType environmentType) {
|
||||
String _getIosArtifactPath(Artifact artifact, TargetPlatform platform, BuildMode? mode, EnvironmentType? environmentType) {
|
||||
switch (artifact) {
|
||||
case Artifact.genSnapshot:
|
||||
case Artifact.flutterXcframework:
|
||||
case Artifact.frontendServerSnapshotForEngineDartSdk:
|
||||
final String artifactFileName = _artifactToFileName(artifact);
|
||||
final String engineDir = _getEngineArtifactsPath(platform, mode);
|
||||
final String artifactFileName = _artifactToFileName(artifact)!;
|
||||
final String engineDir = _getEngineArtifactsPath(platform, mode)!;
|
||||
return _fileSystem.path.join(engineDir, artifactFileName);
|
||||
case Artifact.flutterFramework:
|
||||
final String engineDir = _getEngineArtifactsPath(platform, mode);
|
||||
final String engineDir = _getEngineArtifactsPath(platform, mode)!;
|
||||
return _getIosEngineArtifactPath(engineDir, environmentType, _fileSystem);
|
||||
default:
|
||||
return _getHostArtifactPath(artifact, platform, mode);
|
||||
@ -498,20 +513,20 @@ class CachedArtifacts implements Artifacts {
|
||||
const String artifactFileName = 'flutter_runner_patched_sdk';
|
||||
return _fileSystem.path.join(root, runtime, artifactFileName);
|
||||
case Artifact.platformKernelDill:
|
||||
final String artifactFileName = _artifactToFileName(artifact, platform, mode);
|
||||
final String artifactFileName = _artifactToFileName(artifact, platform, mode)!;
|
||||
return _fileSystem.path.join(root, runtime, 'flutter_runner_patched_sdk', artifactFileName);
|
||||
case Artifact.fuchsiaKernelCompiler:
|
||||
final String artifactFileName = _artifactToFileName(artifact, platform, mode);
|
||||
final String artifactFileName = _artifactToFileName(artifact, platform, mode)!;
|
||||
return _fileSystem.path.join(root, runtime, 'dart_binaries', artifactFileName);
|
||||
case Artifact.fuchsiaFlutterRunner:
|
||||
final String artifactFileName = _artifactToFileName(artifact, platform, mode);
|
||||
final String artifactFileName = _artifactToFileName(artifact, platform, mode)!;
|
||||
return _fileSystem.path.join(root, runtime, artifactFileName);
|
||||
default:
|
||||
return _getHostArtifactPath(artifact, platform, mode);
|
||||
}
|
||||
}
|
||||
|
||||
String _getFlutterPatchedSdkPath(BuildMode mode) {
|
||||
String _getFlutterPatchedSdkPath(BuildMode? mode) {
|
||||
final String engineArtifactsPath = _cache.getArtifactDirectory('engine').path;
|
||||
return _fileSystem.path.join(engineArtifactsPath, 'common',
|
||||
mode == BuildMode.release ? 'flutter_patched_sdk_product' : 'flutter_patched_sdk');
|
||||
@ -521,7 +536,7 @@ class CachedArtifacts implements Artifacts {
|
||||
return _cache.getWebSdkDirectory().path;
|
||||
}
|
||||
|
||||
String _getHostArtifactPath(Artifact artifact, TargetPlatform platform, BuildMode mode) {
|
||||
String _getHostArtifactPath(Artifact artifact, TargetPlatform platform, BuildMode? mode) {
|
||||
assert(platform != null);
|
||||
switch (artifact) {
|
||||
case Artifact.genSnapshot:
|
||||
@ -552,13 +567,13 @@ class CachedArtifacts implements Artifacts {
|
||||
// https://github.com/flutter/flutter/issues/38935
|
||||
String platformDirName = _enginePlatformDirectoryName(platform);
|
||||
if (mode == BuildMode.profile || mode == BuildMode.release) {
|
||||
platformDirName = '$platformDirName-${getNameForBuildMode(mode)}';
|
||||
platformDirName = '$platformDirName-${getNameForBuildMode(mode!)}';
|
||||
}
|
||||
final String engineArtifactsPath = _cache.getArtifactDirectory('engine').path;
|
||||
return _fileSystem.path.join(engineArtifactsPath, platformDirName, _artifactToFileName(artifact, platform, mode));
|
||||
case Artifact.windowsUwpDesktopPath:
|
||||
final String engineArtifactsPath = _cache.getArtifactDirectory('engine').path;
|
||||
return _fileSystem.path.join(engineArtifactsPath, 'windows-uwp-x64-${getNameForBuildMode(mode)}', _artifactToFileName(artifact, platform, mode));
|
||||
return _fileSystem.path.join(engineArtifactsPath, 'windows-uwp-x64-${getNameForBuildMode(mode!)}', _artifactToFileName(artifact, platform, mode));
|
||||
case Artifact.windowsCppClientWrapper:
|
||||
final String engineArtifactsPath = _cache.getArtifactDirectory('engine').path;
|
||||
return _fileSystem.path.join(engineArtifactsPath, 'windows-x64', _artifactToFileName(artifact, platform, mode));
|
||||
@ -569,20 +584,19 @@ class CachedArtifacts implements Artifacts {
|
||||
case Artifact.constFinder:
|
||||
return _cache.getArtifactDirectory('engine')
|
||||
.childDirectory(_enginePlatformDirectoryName(platform))
|
||||
.childFile(_artifactToFileName(artifact, platform, mode))
|
||||
.childFile(_artifactToFileName(artifact, platform, mode)!)
|
||||
.path;
|
||||
case Artifact.uwptool:
|
||||
return _cache.getArtifactDirectory('engine')
|
||||
.childDirectory('windows-uwp-x64-${getNameForBuildMode(mode ?? BuildMode.debug)}')
|
||||
.childFile(_artifactToFileName(artifact, platform, mode))
|
||||
.childFile(_artifactToFileName(artifact, platform, mode)!)
|
||||
.path;
|
||||
default:
|
||||
assert(false, 'Artifact $artifact not available for platform $platform.');
|
||||
return null;
|
||||
throw StateError('Artifact $artifact not available for platform $platform.');
|
||||
}
|
||||
}
|
||||
|
||||
String _getEngineArtifactsPath(TargetPlatform platform, [ BuildMode mode ]) {
|
||||
String? _getEngineArtifactsPath(TargetPlatform platform, [ BuildMode? mode ]) {
|
||||
final String engineDir = _cache.getArtifactDirectory('engine').path;
|
||||
final String platformName = _enginePlatformDirectoryName(platform);
|
||||
switch (platform) {
|
||||
@ -611,14 +625,12 @@ class CachedArtifacts implements Artifacts {
|
||||
case TargetPlatform.android_x86:
|
||||
case TargetPlatform.windows_uwp_x64:
|
||||
assert(mode != null, 'Need to specify a build mode for platform $platform.');
|
||||
final String suffix = mode != BuildMode.debug ? '-${snakeCase(getModeName(mode), '-')}' : '';
|
||||
final String suffix = mode != BuildMode.debug ? '-${snakeCase(getModeName(mode!), '-')}' : '';
|
||||
return _fileSystem.path.join(engineDir, platformName + suffix);
|
||||
case TargetPlatform.android:
|
||||
assert(false, 'cannot use TargetPlatform.android to look up artifacts');
|
||||
return null;
|
||||
}
|
||||
assert(false, 'Invalid platform $platform.');
|
||||
return null;
|
||||
}
|
||||
|
||||
@override
|
||||
@ -640,15 +652,15 @@ TargetPlatform _currentHostPlatform(Platform platform, OperatingSystemUtils oper
|
||||
}
|
||||
|
||||
String _getIosEngineArtifactPath(String engineDirectory,
|
||||
EnvironmentType environmentType, FileSystem fileSystem) {
|
||||
EnvironmentType? environmentType, FileSystem fileSystem) {
|
||||
final Directory xcframeworkDirectory = fileSystem
|
||||
.directory(engineDirectory)
|
||||
.childDirectory(_artifactToFileName(Artifact.flutterXcframework));
|
||||
.childDirectory(_artifactToFileName(Artifact.flutterXcframework)!);
|
||||
|
||||
if (!xcframeworkDirectory.existsSync()) {
|
||||
throwToolExit('No xcframework found at ${xcframeworkDirectory.path}. Try running "flutter precache --ios".');
|
||||
}
|
||||
Directory flutterFrameworkSource;
|
||||
Directory? flutterFrameworkSource;
|
||||
for (final Directory platformDirectory
|
||||
in xcframeworkDirectory.listSync().whereType<Directory>()) {
|
||||
if (!platformDirectory.basename.startsWith('ios-')) {
|
||||
@ -667,17 +679,17 @@ String _getIosEngineArtifactPath(String engineDirectory,
|
||||
}
|
||||
|
||||
return flutterFrameworkSource
|
||||
.childDirectory(_artifactToFileName(Artifact.flutterFramework))
|
||||
.childDirectory(_artifactToFileName(Artifact.flutterFramework)!)
|
||||
.path;
|
||||
}
|
||||
|
||||
abstract class LocalEngineArtifacts implements Artifacts {
|
||||
factory LocalEngineArtifacts(String engineOutPath, String hostEngineOutPath, {
|
||||
@required FileSystem fileSystem,
|
||||
@required Cache cache,
|
||||
@required ProcessManager processManager,
|
||||
@required Platform platform,
|
||||
@required OperatingSystemUtils operatingSystemUtils,
|
||||
required FileSystem fileSystem,
|
||||
required Cache cache,
|
||||
required ProcessManager processManager,
|
||||
required Platform platform,
|
||||
required OperatingSystemUtils operatingSystemUtils,
|
||||
}) = CachedLocalEngineArtifacts;
|
||||
|
||||
String get engineOutPath;
|
||||
@ -688,11 +700,11 @@ class CachedLocalEngineArtifacts implements LocalEngineArtifacts {
|
||||
CachedLocalEngineArtifacts(
|
||||
this.engineOutPath,
|
||||
this._hostEngineOutPath, {
|
||||
@required FileSystem fileSystem,
|
||||
@required Cache cache,
|
||||
@required ProcessManager processManager,
|
||||
@required Platform platform,
|
||||
@required OperatingSystemUtils operatingSystemUtils,
|
||||
required FileSystem fileSystem,
|
||||
required Cache cache,
|
||||
required ProcessManager processManager,
|
||||
required Platform platform,
|
||||
required OperatingSystemUtils operatingSystemUtils,
|
||||
}) : _fileSystem = fileSystem,
|
||||
_cache = cache,
|
||||
_processManager = processManager,
|
||||
@ -770,7 +782,6 @@ class CachedLocalEngineArtifacts implements LocalEngineArtifacts {
|
||||
case HostArtifact.idevicescreenshot:
|
||||
final String artifactFileName = _hostArtifactToFileName(artifact, _platform.isWindows);
|
||||
return _cache.getArtifactDirectory('libimobiledevice').childFile(artifactFileName);
|
||||
break;
|
||||
case HostArtifact.skyEnginePath:
|
||||
final Directory dartPackageDirectory = _cache.getCacheDir('pkg');
|
||||
final String path = _fileSystem.path.join(dartPackageDirectory.path, _hostArtifactToFileName(artifact, _platform.isWindows));
|
||||
@ -785,25 +796,24 @@ class CachedLocalEngineArtifacts implements LocalEngineArtifacts {
|
||||
final String artifactFileName = _hostArtifactToFileName(artifact, _platform.isWindows);
|
||||
return _cache.getArtifactDirectory('usbmuxd').childFile(artifactFileName);
|
||||
}
|
||||
assert(false);
|
||||
return null;
|
||||
}
|
||||
|
||||
@override
|
||||
String getArtifactPath(
|
||||
Artifact artifact, {
|
||||
TargetPlatform platform,
|
||||
BuildMode mode,
|
||||
EnvironmentType environmentType,
|
||||
TargetPlatform? platform,
|
||||
BuildMode? mode,
|
||||
EnvironmentType? environmentType,
|
||||
}) {
|
||||
platform ??= _currentHostPlatform(_platform, _operatingSystemUtils);
|
||||
platform = _mapTargetPlatform(platform);
|
||||
final bool isDirectoryArtifact = artifact == Artifact.flutterPatchedSdkPath;
|
||||
final String artifactFileName = isDirectoryArtifact ? null : _artifactToFileName(artifact, platform, mode);
|
||||
final String? artifactFileName = isDirectoryArtifact ? null : _artifactToFileName(artifact, platform, mode);
|
||||
switch (artifact) {
|
||||
case Artifact.genSnapshot:
|
||||
return _genSnapshotPath();
|
||||
case Artifact.flutterTester:
|
||||
return _flutterTesterPath(platform);
|
||||
return _flutterTesterPath(platform!);
|
||||
case Artifact.isolateSnapshotData:
|
||||
case Artifact.vmSnapshotData:
|
||||
return _fileSystem.path.join(engineOutPath, 'gen', 'flutter', 'lib', 'snapshot', artifactFileName);
|
||||
@ -830,18 +840,17 @@ class CachedLocalEngineArtifacts implements LocalEngineArtifacts {
|
||||
return _fileSystem.path.join(engineOutPath, 'flutter_runner_patched_sdk');
|
||||
}
|
||||
return _getFlutterPatchedSdkPath(BuildMode.debug);
|
||||
return _fileSystem.path.join(_hostEngineOutPath, 'dart-sdk', 'bin', 'snapshots', artifactFileName);
|
||||
case Artifact.skyEnginePath:
|
||||
return _fileSystem.path.join(_hostEngineOutPath, 'gen', 'dart-pkg', artifactFileName);
|
||||
case Artifact.flutterMacOSPodspec:
|
||||
return _fileSystem.path.join(_hostEngineOutPath, _artifactToFileName(artifact));
|
||||
case Artifact.fuchsiaKernelCompiler:
|
||||
final String hostPlatform = getNameForHostPlatform(getCurrentHostPlatform());
|
||||
final String modeName = mode.isRelease ? 'release' : mode.toString();
|
||||
final String modeName = mode!.isRelease ? 'release' : mode.toString();
|
||||
final String dartBinaries = 'dart_binaries-$modeName-$hostPlatform';
|
||||
return _fileSystem.path.join(engineOutPath, 'host_bundle', dartBinaries, 'kernel_compiler.dart.snapshot');
|
||||
case Artifact.fuchsiaFlutterRunner:
|
||||
final String jitOrAot = mode.isJit ? '_jit' : '_aot';
|
||||
final String jitOrAot = mode!.isJit ? '_jit' : '_aot';
|
||||
final String productOrNo = mode.isRelease ? '_product' : '';
|
||||
return _fileSystem.path.join(engineOutPath, 'flutter$jitOrAot${productOrNo}_runner-0.far');
|
||||
case Artifact.fontSubset:
|
||||
@ -856,20 +865,17 @@ class CachedLocalEngineArtifacts implements LocalEngineArtifacts {
|
||||
return _fileSystem.path.join(_hostEngineOutPath, artifactFileName);
|
||||
case Artifact.frontendServerSnapshotForEngineDartSdk:
|
||||
return _fileSystem.path.join(_hostEngineOutPath, 'gen', artifactFileName);
|
||||
break;
|
||||
case Artifact.uwptool:
|
||||
return _fileSystem.path.join(_hostEngineOutPath, artifactFileName);
|
||||
}
|
||||
assert(false, 'Invalid artifact $artifact.');
|
||||
return null;
|
||||
}
|
||||
|
||||
@override
|
||||
String getEngineType(TargetPlatform platform, [ BuildMode mode ]) {
|
||||
String getEngineType(TargetPlatform platform, [ BuildMode? mode ]) {
|
||||
return _fileSystem.path.basename(engineOutPath);
|
||||
}
|
||||
|
||||
String _getFlutterPatchedSdkPath(BuildMode buildMode) {
|
||||
String _getFlutterPatchedSdkPath(BuildMode? buildMode) {
|
||||
return _fileSystem.path.join(engineOutPath,
|
||||
buildMode == BuildMode.release ? 'flutter_patched_sdk_product' : 'flutter_patched_sdk');
|
||||
}
|
||||
@ -880,7 +886,7 @@ class CachedLocalEngineArtifacts implements LocalEngineArtifacts {
|
||||
|
||||
String _genSnapshotPath() {
|
||||
const List<String> clangDirs = <String>['.', 'clang_x64', 'clang_x86', 'clang_i386', 'clang_arm64'];
|
||||
final String genSnapshotName = _artifactToFileName(Artifact.genSnapshot);
|
||||
final String genSnapshotName = _artifactToFileName(Artifact.genSnapshot)!;
|
||||
for (final String clangDir in clangDirs) {
|
||||
final String genSnapshotPath = _fileSystem.path.join(engineOutPath, clangDir, genSnapshotName);
|
||||
if (_processManager.canRun(genSnapshotPath)) {
|
||||
@ -913,7 +919,7 @@ class OverrideArtifacts implements Artifacts {
|
||||
///
|
||||
/// [parent] must be provided.
|
||||
OverrideArtifacts({
|
||||
@required this.parent,
|
||||
required this.parent,
|
||||
this.frontendServer,
|
||||
this.engineDartBinary,
|
||||
this.platformKernelDill,
|
||||
@ -921,26 +927,26 @@ class OverrideArtifacts implements Artifacts {
|
||||
}) : assert(parent != null);
|
||||
|
||||
final Artifacts parent;
|
||||
final File frontendServer;
|
||||
final File engineDartBinary;
|
||||
final File platformKernelDill;
|
||||
final File flutterPatchedSdk;
|
||||
final File? frontendServer;
|
||||
final File? engineDartBinary;
|
||||
final File? platformKernelDill;
|
||||
final File? flutterPatchedSdk;
|
||||
|
||||
@override
|
||||
String getArtifactPath(
|
||||
Artifact artifact, {
|
||||
TargetPlatform platform,
|
||||
BuildMode mode,
|
||||
EnvironmentType environmentType,
|
||||
TargetPlatform? platform,
|
||||
BuildMode? mode,
|
||||
EnvironmentType? environmentType,
|
||||
}) {
|
||||
if (artifact == Artifact.frontendServerSnapshotForEngineDartSdk && frontendServer != null) {
|
||||
return frontendServer.path;
|
||||
return frontendServer!.path;
|
||||
}
|
||||
if (artifact == Artifact.platformKernelDill && platformKernelDill != null) {
|
||||
return platformKernelDill.path;
|
||||
return platformKernelDill!.path;
|
||||
}
|
||||
if (artifact == Artifact.flutterPatchedSdkPath && flutterPatchedSdk != null) {
|
||||
return flutterPatchedSdk.path;
|
||||
return flutterPatchedSdk!.path;
|
||||
}
|
||||
return parent.getArtifactPath(
|
||||
artifact,
|
||||
@ -951,7 +957,7 @@ class OverrideArtifacts implements Artifacts {
|
||||
}
|
||||
|
||||
@override
|
||||
String getEngineType(TargetPlatform platform, [ BuildMode mode ]) => parent.getEngineType(platform, mode);
|
||||
String getEngineType(TargetPlatform platform, [ BuildMode? mode ]) => parent.getEngineType(platform, mode);
|
||||
|
||||
@override
|
||||
bool get isLocalEngine => parent.isLocalEngine;
|
||||
@ -959,7 +965,7 @@ class OverrideArtifacts implements Artifacts {
|
||||
@override
|
||||
FileSystemEntity getHostArtifact(HostArtifact artifact) {
|
||||
if (artifact == HostArtifact.engineDartBinary && engineDartBinary != null) {
|
||||
return engineDartBinary;
|
||||
return engineDartBinary!;
|
||||
}
|
||||
return parent.getHostArtifact(
|
||||
artifact,
|
||||
@ -969,7 +975,7 @@ class OverrideArtifacts implements Artifacts {
|
||||
|
||||
/// Locate the Dart SDK.
|
||||
String _dartSdkPath(FileSystem fileSystem) {
|
||||
return fileSystem.path.join(Cache.flutterRoot, 'bin', 'cache', 'dart-sdk');
|
||||
return fileSystem.path.join(Cache.flutterRoot!, 'bin', 'cache', 'dart-sdk');
|
||||
}
|
||||
|
||||
class _TestArtifacts implements Artifacts {
|
||||
@ -980,9 +986,9 @@ class _TestArtifacts implements Artifacts {
|
||||
@override
|
||||
String getArtifactPath(
|
||||
Artifact artifact, {
|
||||
TargetPlatform platform,
|
||||
BuildMode mode,
|
||||
EnvironmentType environmentType,
|
||||
TargetPlatform? platform,
|
||||
BuildMode? mode,
|
||||
EnvironmentType? environmentType,
|
||||
}) {
|
||||
final StringBuffer buffer = StringBuffer();
|
||||
buffer.write(artifact);
|
||||
@ -999,7 +1005,7 @@ class _TestArtifacts implements Artifacts {
|
||||
}
|
||||
|
||||
@override
|
||||
String getEngineType(TargetPlatform platform, [ BuildMode mode ]) {
|
||||
String getEngineType(TargetPlatform platform, [ BuildMode? mode ]) {
|
||||
return 'test-engine';
|
||||
}
|
||||
|
||||
|
@ -2,8 +2,6 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// @dart = 2.8
|
||||
|
||||
import 'package:file/memory.dart';
|
||||
import 'package:flutter_tools/src/artifacts.dart';
|
||||
import 'package:flutter_tools/src/base/file_system.dart';
|
||||
@ -18,10 +16,10 @@ import '../src/fakes.dart';
|
||||
|
||||
void main() {
|
||||
group('CachedArtifacts', () {
|
||||
CachedArtifacts artifacts;
|
||||
Cache cache;
|
||||
FileSystem fileSystem;
|
||||
Platform platform;
|
||||
late CachedArtifacts artifacts;
|
||||
late Cache cache;
|
||||
late FileSystem fileSystem;
|
||||
late Platform platform;
|
||||
|
||||
setUp(() {
|
||||
fileSystem = MemoryFileSystem.test();
|
||||
@ -185,10 +183,10 @@ void main() {
|
||||
});
|
||||
|
||||
group('LocalEngineArtifacts', () {
|
||||
LocalEngineArtifacts artifacts;
|
||||
Cache cache;
|
||||
FileSystem fileSystem;
|
||||
Platform platform;
|
||||
late LocalEngineArtifacts artifacts;
|
||||
late Cache cache;
|
||||
late FileSystem fileSystem;
|
||||
late Platform platform;
|
||||
|
||||
setUp(() {
|
||||
fileSystem = MemoryFileSystem.test();
|
||||
|
Loading…
Reference in New Issue
Block a user