Unverified Commit be2c68c8 authored by Jonah Williams's avatar Jonah Williams Committed by GitHub

[flutter_tools] cache for UWP artifacts (#80069)

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