[flutter_tools] cache for UWP artifacts (#80069)
This commit is contained in:
@@ -62,7 +62,7 @@ or
|
||||
'flutter'
|
||||
]);
|
||||
final bool uwp = targetPlatform.contains('uwp');
|
||||
final String bundlePlatform = targetPlatform.startsWith('windows-x64') ? 'windows' : targetPlatform;
|
||||
final String bundlePlatform = targetPlatform.startsWith('windows') ? 'windows' : targetPlatform;
|
||||
final String target = '${buildMode}_bundle_${bundlePlatform}_assets${uwp ? '_uwp' : ''}';
|
||||
final Process assembleProcess = await Process.start(
|
||||
flutterExecutable,
|
||||
|
||||
@@ -74,8 +74,10 @@ enum Artifact {
|
||||
linuxHeaders,
|
||||
/// The root of the Windows desktop sources.
|
||||
windowsDesktopPath,
|
||||
/// The root of the cpp client code for Windows desktop.
|
||||
/// The root of the cpp client code for Windows desktop and Windows UWP desktop.
|
||||
windowsCppClientWrapper,
|
||||
/// The root of the Windows UWP desktop sources.
|
||||
windowsUwpDesktopPath,
|
||||
/// The root of the sky_engine package.
|
||||
skyEnginePath,
|
||||
/// The location of the macOS engine podspec file.
|
||||
@@ -146,10 +148,11 @@ String _artifactToFileName(Artifact artifact, [ TargetPlatform platform, BuildMo
|
||||
return '';
|
||||
case Artifact.linuxHeaders:
|
||||
return 'flutter_linux';
|
||||
case Artifact.windowsDesktopPath:
|
||||
return '';
|
||||
case Artifact.windowsCppClientWrapper:
|
||||
return 'cpp_client_wrapper';
|
||||
case Artifact.windowsUwpDesktopPath:
|
||||
case Artifact.windowsDesktopPath:
|
||||
return '';
|
||||
case Artifact.skyEnginePath:
|
||||
return 'sky_engine';
|
||||
case Artifact.flutterMacOSPodspec:
|
||||
@@ -284,6 +287,7 @@ class CachedArtifacts implements Artifacts {
|
||||
case TargetPlatform.linux_x64:
|
||||
case TargetPlatform.linux_arm64:
|
||||
case TargetPlatform.windows_x64:
|
||||
case TargetPlatform.windows_uwp_x64:
|
||||
return _getDesktopArtifactPath(artifact, platform, mode);
|
||||
case TargetPlatform.fuchsia_arm64:
|
||||
case TargetPlatform.fuchsia_x64:
|
||||
@@ -444,6 +448,9 @@ class CachedArtifacts implements Artifacts {
|
||||
}
|
||||
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));
|
||||
case Artifact.windowsCppClientWrapper:
|
||||
final String engineArtifactsPath = _cache.getArtifactDirectory('engine').path;
|
||||
return _fileSystem.path.join(engineArtifactsPath, 'windows-x64', _artifactToFileName(artifact, platform, mode));
|
||||
@@ -515,15 +522,13 @@ class CachedArtifacts implements Artifacts {
|
||||
case TargetPlatform.android_arm64:
|
||||
case TargetPlatform.android_x64:
|
||||
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), '-')}' : '';
|
||||
return _fileSystem.path.join(engineDir, platformName + suffix);
|
||||
case TargetPlatform.android:
|
||||
assert(false, 'cannot use TargetPlatform.android to look up artifacts');
|
||||
return null;
|
||||
case TargetPlatform.windows_uwp_x64:
|
||||
assert(false, 'cannot use TargetPlatform.windows_uwp_x64 to look up artifacts');
|
||||
return null;
|
||||
}
|
||||
assert(false, 'Invalid platform $platform.');
|
||||
return null;
|
||||
@@ -679,13 +684,6 @@ class CachedLocalEngineArtifacts implements LocalEngineArtifacts {
|
||||
return _cache.getArtifactDirectory('ios-deploy').childFile(artifactFileName).path;
|
||||
case Artifact.iproxy:
|
||||
return _cache.getArtifactDirectory('usbmuxd').childFile(artifactFileName).path;
|
||||
case Artifact.linuxDesktopPath:
|
||||
case Artifact.linuxHeaders:
|
||||
return _fileSystem.path.join(_hostEngineOutPath, artifactFileName);
|
||||
case Artifact.windowsDesktopPath:
|
||||
return _fileSystem.path.join(_hostEngineOutPath, artifactFileName);
|
||||
case Artifact.windowsCppClientWrapper:
|
||||
return _fileSystem.path.join(_hostEngineOutPath, artifactFileName);
|
||||
case Artifact.skyEnginePath:
|
||||
return _fileSystem.path.join(_hostEngineOutPath, 'gen', 'dart-pkg', artifactFileName);
|
||||
case Artifact.flutterMacOSPodspec:
|
||||
@@ -735,6 +733,12 @@ class CachedLocalEngineArtifacts implements LocalEngineArtifacts {
|
||||
return _fileSystem.path.join(_getFlutterWebSdkPath(), 'kernel', 'amd-canvaskit-html-sound', artifactFileName);
|
||||
case Artifact.pubExecutable:
|
||||
return _fileSystem.path.join(_hostEngineOutPath, 'dart-sdk', 'bin', _artifactToFileName(artifact, platform, mode));
|
||||
case Artifact.windowsUwpDesktopPath:
|
||||
case Artifact.linuxDesktopPath:
|
||||
case Artifact.linuxHeaders:
|
||||
case Artifact.windowsDesktopPath:
|
||||
case Artifact.windowsCppClientWrapper:
|
||||
return _fileSystem.path.join(_hostEngineOutPath, artifactFileName);
|
||||
}
|
||||
assert(false, 'Invalid artifact $artifact.');
|
||||
return null;
|
||||
|
||||
@@ -315,6 +315,7 @@ class AOTSnapshotter {
|
||||
TargetPlatform.linux_x64,
|
||||
TargetPlatform.linux_arm64,
|
||||
TargetPlatform.windows_x64,
|
||||
TargetPlatform.windows_uwp_x64,
|
||||
].contains(platform);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -600,6 +600,8 @@ TargetPlatform? getTargetPlatformForName(String platform) {
|
||||
return TargetPlatform.linux_arm64;
|
||||
case 'windows-x64':
|
||||
return TargetPlatform.windows_x64;
|
||||
case 'windows-uwp-x64':
|
||||
return TargetPlatform.windows_uwp_x64;
|
||||
case 'web-javascript':
|
||||
return TargetPlatform.web_javascript;
|
||||
}
|
||||
|
||||
@@ -133,12 +133,10 @@ class UnpackWindowsUwp extends Target {
|
||||
|
||||
@override
|
||||
Future<void> build(Environment environment) async {
|
||||
// These artifact look ups need to modified to windows-x64-uwp once
|
||||
// the cache updates have landed.
|
||||
final BuildMode buildMode = getBuildModeForName(environment.defines[kBuildMode]);
|
||||
final String engineSourcePath = environment.artifacts
|
||||
.getArtifactPath(
|
||||
Artifact.windowsDesktopPath,
|
||||
Artifact.windowsUwpDesktopPath,
|
||||
platform: TargetPlatform.windows_x64,
|
||||
mode: buildMode,
|
||||
);
|
||||
@@ -338,7 +336,6 @@ class DebugBundleWindowsAssets extends BundleWindowsAssets {
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
class ReleaseBundleWindowsAssetsUwp extends BundleWindowsAssetsUwp {
|
||||
const ReleaseBundleWindowsAssetsUwp();
|
||||
|
||||
@@ -351,7 +348,7 @@ class ReleaseBundleWindowsAssetsUwp extends BundleWindowsAssetsUwp {
|
||||
@override
|
||||
List<Target> get dependencies => <Target>[
|
||||
...super.dependencies,
|
||||
const WindowsAotBundle(AotElfRelease(TargetPlatform.windows_x64)),
|
||||
const WindowsAotBundle(AotElfRelease(TargetPlatform.windows_uwp_x64)),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -367,7 +364,7 @@ class ProfileBundleWindowsAssetsUwp extends BundleWindowsAssetsUwp {
|
||||
@override
|
||||
List<Target> get dependencies => <Target>[
|
||||
...super.dependencies,
|
||||
const WindowsAotBundle(AotElfProfile(TargetPlatform.windows_x64)),
|
||||
const WindowsAotBundle(AotElfProfile(TargetPlatform.windows_uwp_x64)),
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -69,6 +69,9 @@ class DevelopmentArtifact {
|
||||
/// Artifacts required for the Flutter Runner.
|
||||
static const DevelopmentArtifact flutterRunner = DevelopmentArtifact._('flutter_runner', feature: flutterFuchsiaFeature);
|
||||
|
||||
/// Artifacts required for desktop Windows UWP.
|
||||
static const DevelopmentArtifact windowsUwp = DevelopmentArtifact._('winuwp', feature: windowsUwpEmbedding);
|
||||
|
||||
/// Artifacts required for any development platform.
|
||||
///
|
||||
/// This does not need to be explicitly returned from requiredArtifacts as
|
||||
@@ -88,6 +91,7 @@ class DevelopmentArtifact {
|
||||
fuchsia,
|
||||
universal,
|
||||
flutterRunner,
|
||||
windowsUwp,
|
||||
];
|
||||
|
||||
@override
|
||||
|
||||
@@ -31,8 +31,7 @@ class BuildWindowsUwpCommand extends BuildSubCommand {
|
||||
|
||||
@override
|
||||
Future<Set<DevelopmentArtifact>> get requiredArtifacts async => <DevelopmentArtifact>{
|
||||
// TODO(flutter): add a windows_uwp artifact here once that is updated.
|
||||
// https://github.com/flutter/flutter/issues/78627
|
||||
DevelopmentArtifact.windowsUwp,
|
||||
};
|
||||
|
||||
@override
|
||||
|
||||
@@ -50,6 +50,8 @@ class PrecacheCommand extends FlutterCommand {
|
||||
help: 'Precache artifacts for Linux desktop development.');
|
||||
argParser.addFlag('windows', negatable: true, defaultsTo: false,
|
||||
help: 'Precache artifacts for Windows desktop development.');
|
||||
argParser.addFlag('winuwp', negatable: true, defaultsTo: false,
|
||||
help: 'Precache artifacts for Windows UWP desktop development.');
|
||||
argParser.addFlag('macos', negatable: true, defaultsTo: false,
|
||||
help: 'Precache artifacts for macOS desktop development.');
|
||||
argParser.addFlag('fuchsia', negatable: true, defaultsTo: false,
|
||||
|
||||
@@ -41,6 +41,7 @@ class FlutterCache extends Cache {
|
||||
registerArtifact(FlutterWebSdk(this, platform: platform));
|
||||
registerArtifact(FlutterSdk(this, platform: platform));
|
||||
registerArtifact(WindowsEngineArtifacts(this, platform: platform));
|
||||
registerArtifact(WindowsUwpEngineArtifacts(this, platform: platform));
|
||||
registerArtifact(MacOSEngineArtifacts(this, platform: platform));
|
||||
registerArtifact(LinuxEngineArtifacts(this, platform: platform));
|
||||
registerArtifact(LinuxFuchsiaSDKArtifacts(this, platform: platform));
|
||||
@@ -300,6 +301,33 @@ class WindowsEngineArtifacts extends EngineCachedArtifact {
|
||||
List<String> getLicenseDirs() => const <String>[];
|
||||
}
|
||||
|
||||
class WindowsUwpEngineArtifacts extends EngineCachedArtifact {
|
||||
WindowsUwpEngineArtifacts(Cache cache, {
|
||||
@required Platform platform,
|
||||
}) : _platform = platform,
|
||||
super(
|
||||
'windows-uwp-sdk',
|
||||
cache,
|
||||
DevelopmentArtifact.windowsUwp,
|
||||
);
|
||||
|
||||
final Platform _platform;
|
||||
|
||||
@override
|
||||
List<String> getPackageDirs() => const <String>[];
|
||||
|
||||
@override
|
||||
List<List<String>> getBinaryDirs() {
|
||||
if (_platform.isWindows || ignorePlatformFiltering) {
|
||||
return _windowsUwpDesktopBinaryDirs;
|
||||
}
|
||||
return const <List<String>>[];
|
||||
}
|
||||
|
||||
@override
|
||||
List<String> getLicenseDirs() => const <String>[];
|
||||
}
|
||||
|
||||
/// Artifacts required for desktop Linux builds.
|
||||
class LinuxEngineArtifacts extends EngineCachedArtifact {
|
||||
LinuxEngineArtifacts(Cache cache, {
|
||||
@@ -832,6 +860,13 @@ const List<List<String>> _windowsDesktopBinaryDirs = <List<String>>[
|
||||
<String>['windows-x64-release', 'windows-x64-release/windows-x64-flutter.zip'],
|
||||
];
|
||||
|
||||
const List<List<String>> _windowsUwpDesktopBinaryDirs = <List<String>>[
|
||||
<String>['windows-uwp-x64-debug', 'windows-x64-debug/windows-uwp-x64-flutter.zip'],
|
||||
<String>['windows-uwp-x64-debug', 'windows-x64/flutter-cpp-client-wrapper.zip'],
|
||||
<String>['windows-uwp-x64-profile', 'windows-x64-profile/windows-uwp-x64-flutter.zip'],
|
||||
<String>['windows-uwp-x64-release', 'windows-x64-release/windows-uwp-x64-flutter.zip'],
|
||||
];
|
||||
|
||||
const List<List<String>> _macOSDesktopBinaryDirs = <List<String>>[
|
||||
<String>['darwin-x64', 'darwin-x64/FlutterMacOS.framework.zip'],
|
||||
<String>['darwin-x64-profile', 'darwin-x64-profile/FlutterMacOS.framework.zip'],
|
||||
|
||||
@@ -118,6 +118,18 @@ void main() {
|
||||
artifacts.getArtifactPath(Artifact.flutterTester, platform: TargetPlatform.linux_arm64),
|
||||
fileSystem.path.join('root', 'bin', 'cache', 'artifacts', 'engine', 'linux-arm64', 'flutter_tester'),
|
||||
);
|
||||
expect(
|
||||
artifacts.getArtifactPath(Artifact.windowsUwpDesktopPath, platform: TargetPlatform.windows_uwp_x64, mode: BuildMode.debug),
|
||||
fileSystem.path.join('root', 'bin', 'cache', 'artifacts', 'engine', 'windows-uwp-x64-debug'),
|
||||
);
|
||||
expect(
|
||||
artifacts.getArtifactPath(Artifact.windowsUwpDesktopPath, platform: TargetPlatform.windows_uwp_x64, mode: BuildMode.profile),
|
||||
fileSystem.path.join('root', 'bin', 'cache', 'artifacts', 'engine', 'windows-uwp-x64-profile'),
|
||||
);
|
||||
expect(
|
||||
artifacts.getArtifactPath(Artifact.windowsUwpDesktopPath, platform: TargetPlatform.windows_uwp_x64, mode: BuildMode.release),
|
||||
fileSystem.path.join('root', 'bin', 'cache', 'artifacts', 'engine', 'windows-uwp-x64-release'),
|
||||
);
|
||||
});
|
||||
|
||||
testWithoutContext('precompiled web artifact paths are correct', () {
|
||||
@@ -314,6 +326,20 @@ void main() {
|
||||
expect(artifacts.getArtifactPath(Artifact.engineDartBinary), contains('.exe'));
|
||||
});
|
||||
|
||||
testWithoutContext('Looks up windows UWP artifacts in host engine', () async {
|
||||
artifacts = LocalEngineArtifacts(
|
||||
fileSystem.path.join(fileSystem.currentDirectory.path, 'out', 'winuwp_debug_unopt'),
|
||||
fileSystem.path.join(fileSystem.currentDirectory.path, 'out', 'winuwp_debug_unopt'),
|
||||
cache: cache,
|
||||
fileSystem: fileSystem,
|
||||
platform: FakePlatform(operatingSystem: 'windows'),
|
||||
processManager: FakeProcessManager.any(),
|
||||
operatingSystemUtils: FakeOperatingSystemUtils(),
|
||||
);
|
||||
|
||||
expect(artifacts.getArtifactPath(Artifact.windowsUwpDesktopPath), '/out/winuwp_debug_unopt');
|
||||
});
|
||||
|
||||
testWithoutContext('Looks up dart on linux platforms', () async {
|
||||
expect(artifacts.getArtifactPath(Artifact.engineDartBinary), isNot(contains('.exe')));
|
||||
});
|
||||
|
||||
@@ -145,7 +145,7 @@ void main() {
|
||||
);
|
||||
environment.buildDir.createSync(recursive: true);
|
||||
|
||||
final String windowsDesktopPath = artifacts.getArtifactPath(Artifact.windowsDesktopPath, platform: TargetPlatform.windows_x64, mode: BuildMode.debug);
|
||||
final String windowsDesktopPath = artifacts.getArtifactPath(Artifact.windowsUwpDesktopPath, platform: TargetPlatform.windows_x64, mode: BuildMode.debug);
|
||||
final String windowsCppClientWrapper = artifacts.getArtifactPath(Artifact.windowsCppClientWrapper, platform: TargetPlatform.windows_x64, mode: BuildMode.debug);
|
||||
final String icuData = artifacts.getArtifactPath(Artifact.icuData, platform: TargetPlatform.windows_x64);
|
||||
final List<String> requiredFiles = <String>[
|
||||
|
||||
@@ -589,6 +589,20 @@ void main() {
|
||||
]));
|
||||
});
|
||||
|
||||
testWithoutContext('Windows UWP desktop artifacts include profile, debug, and release artifacts', () {
|
||||
final Cache cache = Cache.test(processManager: FakeProcessManager.any());
|
||||
final WindowsUwpEngineArtifacts artifacts = WindowsUwpEngineArtifacts(
|
||||
cache,
|
||||
platform: FakePlatform(operatingSystem: 'windows'),
|
||||
);
|
||||
|
||||
expect(artifacts.getBinaryDirs(), containsAll(<Matcher>[
|
||||
contains(contains('profile')),
|
||||
contains(contains('release')),
|
||||
contains(contains('debug')),
|
||||
]));
|
||||
});
|
||||
|
||||
testWithoutContext('Linux desktop artifacts ignore filtering when requested', () {
|
||||
fakeProcessManager.addCommand(unameCommandForX64);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user