forked from firka/flutter
[flutter_tools] precache and unpack updates for desktop release artifacts (#55510)
- Update windows precache to include placeholder profile/release artifacts - Update Linux and windows unpack to account for the cpp_client_wrapper code to live separate from the engine binaries - Cleanup testing in unpack_linux and remove test cases that are covered in build_system_test.dart
This commit is contained in:
@@ -49,8 +49,12 @@ enum Artifact {
|
||||
iproxy,
|
||||
/// The root of the Linux desktop sources.
|
||||
linuxDesktopPath,
|
||||
// The root of the cpp client code for Linux desktop.
|
||||
linuxCppClientWrapper,
|
||||
/// The root of the Windows desktop sources.
|
||||
windowsDesktopPath,
|
||||
/// The root of the cpp client code for Windows desktop.
|
||||
windowsCppClientWrapper,
|
||||
/// The root of the sky_engine package
|
||||
skyEnginePath,
|
||||
/// The location of the macOS engine podspec file.
|
||||
@@ -116,6 +120,10 @@ String _artifactToFileName(Artifact artifact, [ TargetPlatform platform, BuildMo
|
||||
return '';
|
||||
case Artifact.windowsDesktopPath:
|
||||
return '';
|
||||
case Artifact.windowsCppClientWrapper:
|
||||
return 'cpp_client_wrapper';
|
||||
case Artifact.linuxCppClientWrapper:
|
||||
return 'cpp_client_wrapper_glfw';
|
||||
case Artifact.skyEnginePath:
|
||||
return 'sky_engine';
|
||||
case Artifact.flutterMacOSPodspec:
|
||||
@@ -357,6 +365,12 @@ class CachedArtifacts extends Artifacts {
|
||||
}
|
||||
final String engineArtifactsPath = _cache.getArtifactDirectory('engine').path;
|
||||
return _fileSystem.path.join(engineArtifactsPath, platformDirName, _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));
|
||||
case Artifact.linuxCppClientWrapper:
|
||||
final String engineArtifactsPath = _cache.getArtifactDirectory('engine').path;
|
||||
return _fileSystem.path.join(engineArtifactsPath, 'linux-x64', _artifactToFileName(artifact, platform, mode));
|
||||
case Artifact.skyEnginePath:
|
||||
final Directory dartPackageDirectory = _cache.getCacheDir('pkg');
|
||||
return _fileSystem.path.join(dartPackageDirectory.path, _artifactToFileName(artifact));
|
||||
@@ -517,8 +531,12 @@ class LocalEngineArtifacts extends Artifacts {
|
||||
return _cache.getArtifactDirectory('usbmuxd').childFile(artifactFileName).path;
|
||||
case Artifact.linuxDesktopPath:
|
||||
return _fileSystem.path.join(_hostEngineOutPath, artifactFileName);
|
||||
case Artifact.linuxCppClientWrapper:
|
||||
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:
|
||||
|
||||
@@ -7,59 +7,67 @@ import 'package:meta/meta.dart';
|
||||
import '../../base/file_system.dart';
|
||||
import '../depfile.dart';
|
||||
|
||||
/// Unpack the artifact list [artifacts] from [artifactPath] into a directory
|
||||
/// [outputDirectory], returning a [Depfile] including all copied files.
|
||||
/// Unpack the engine artifact list [artifacts] from [engineSourcePath] and
|
||||
/// [clientSourcePath] (if provided) into a directory [outputDirectory].
|
||||
///
|
||||
/// Returns a [Depfile] including all copied files.
|
||||
///
|
||||
/// Throws an [Exception] if [artifacts] includes missing files, directories,
|
||||
/// or links.
|
||||
Depfile unpackDesktopArtifacts({
|
||||
@required FileSystem fileSystem,
|
||||
@required List<String> artifacts,
|
||||
@required Directory outputDirectory,
|
||||
@required String artifactPath,
|
||||
@required String engineSourcePath,
|
||||
String clientSourcePath,
|
||||
}) {
|
||||
final List<File> inputs = <File>[];
|
||||
final List<File> outputs = <File>[];
|
||||
for (final String artifact in artifacts) {
|
||||
final String entityPath = fileSystem.path.join(artifactPath, artifact);
|
||||
final String entityPath = fileSystem.path.join(engineSourcePath, artifact);
|
||||
final FileSystemEntityType entityType = fileSystem.typeSync(entityPath);
|
||||
|
||||
if (entityType == FileSystemEntityType.notFound
|
||||
|| entityType == FileSystemEntityType.directory
|
||||
|| entityType == FileSystemEntityType.link) {
|
||||
throw Exception('Unsupported file type: $entityType');
|
||||
}
|
||||
|
||||
// If this artifact is a file then copy the source over.
|
||||
if (entityType == FileSystemEntityType.file) {
|
||||
final String outputPath = fileSystem.path.join(
|
||||
outputDirectory.path,
|
||||
fileSystem.path.relative(entityPath, from: artifactPath),
|
||||
);
|
||||
final File destinationFile = fileSystem.file(outputPath);
|
||||
if (!destinationFile.parent.existsSync()) {
|
||||
destinationFile.parent.createSync(recursive: true);
|
||||
}
|
||||
final File inputFile = fileSystem.file(entityPath);
|
||||
inputFile.copySync(destinationFile.path);
|
||||
inputs.add(inputFile);
|
||||
outputs.add(destinationFile);
|
||||
continue;
|
||||
assert(entityType == FileSystemEntityType.file);
|
||||
final String outputPath = fileSystem.path.join(
|
||||
outputDirectory.path,
|
||||
fileSystem.path.relative(entityPath, from: engineSourcePath),
|
||||
);
|
||||
final File destinationFile = fileSystem.file(outputPath);
|
||||
if (!destinationFile.parent.existsSync()) {
|
||||
destinationFile.parent.createSync(recursive: true);
|
||||
}
|
||||
|
||||
// If the artifact is a directory, recursively copy every file from it.
|
||||
for (final File input in fileSystem.directory(entityPath)
|
||||
.listSync(recursive: true)
|
||||
.whereType<File>()) {
|
||||
final String outputPath = fileSystem.path.join(
|
||||
outputDirectory.path,
|
||||
fileSystem.path.relative(input.path, from: artifactPath),
|
||||
);
|
||||
final File destinationFile = fileSystem.file(outputPath);
|
||||
if (!destinationFile.parent.existsSync()) {
|
||||
destinationFile.parent.createSync(recursive: true);
|
||||
}
|
||||
final File inputFile = fileSystem.file(input);
|
||||
inputFile.copySync(destinationFile.path);
|
||||
inputs.add(inputFile);
|
||||
outputs.add(destinationFile);
|
||||
final File inputFile = fileSystem.file(entityPath);
|
||||
inputFile.copySync(destinationFile.path);
|
||||
inputs.add(inputFile);
|
||||
outputs.add(destinationFile);
|
||||
}
|
||||
if (clientSourcePath == null) {
|
||||
return Depfile(inputs, outputs);
|
||||
}
|
||||
final Directory clientSourceDirectory = fileSystem.directory(clientSourcePath);
|
||||
if (!clientSourceDirectory.existsSync()) {
|
||||
throw Exception('Missing clientSourceDirectory: $clientSourcePath');
|
||||
}
|
||||
for (final File input in clientSourceDirectory
|
||||
.listSync(recursive: true)
|
||||
.whereType<File>()) {
|
||||
final String outputPath = fileSystem.path.join(
|
||||
outputDirectory.path,
|
||||
fileSystem.path.relative(input.path, from: clientSourceDirectory.parent.path),
|
||||
);
|
||||
final File destinationFile = fileSystem.file(outputPath);
|
||||
if (!destinationFile.parent.existsSync()) {
|
||||
destinationFile.parent.createSync(recursive: true);
|
||||
}
|
||||
final File inputFile = fileSystem.file(input);
|
||||
inputFile.copySync(destinationFile.path);
|
||||
inputs.add(inputFile);
|
||||
outputs.add(destinationFile);
|
||||
}
|
||||
return Depfile(inputs, outputs);
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
import '../../artifacts.dart';
|
||||
import '../../base/file_system.dart';
|
||||
import '../../build_info.dart';
|
||||
import '../../globals.dart' as globals;
|
||||
import '../build_system.dart';
|
||||
import '../depfile.dart';
|
||||
import '../exceptions.dart';
|
||||
@@ -22,17 +21,16 @@ const List<String> _kLinuxArtifacts = <String>[
|
||||
'flutter_plugin_registrar.h',
|
||||
'flutter_glfw.h',
|
||||
'icudtl.dat',
|
||||
'cpp_client_wrapper_glfw/',
|
||||
];
|
||||
|
||||
const String _kLinuxDepfile = 'linux_engine_sources.d';
|
||||
|
||||
/// Copies the Linux desktop embedding files to the copy directory.
|
||||
class UnpackLinuxDebug extends Target {
|
||||
const UnpackLinuxDebug();
|
||||
class UnpackLinux extends Target {
|
||||
const UnpackLinux();
|
||||
|
||||
@override
|
||||
String get name => 'unpack_linux_debug';
|
||||
String get name => 'unpack_linux';
|
||||
|
||||
@override
|
||||
List<Source> get inputs => const <Source>[
|
||||
@@ -50,7 +48,19 @@ class UnpackLinuxDebug extends Target {
|
||||
|
||||
@override
|
||||
Future<void> build(Environment environment) async {
|
||||
final String artifactPath = globals.artifacts.getArtifactPath(Artifact.linuxDesktopPath);
|
||||
final BuildMode buildMode = getBuildModeForName(environment.defines[kBuildMode]);
|
||||
final String engineSourcePath = environment.artifacts
|
||||
.getArtifactPath(
|
||||
Artifact.linuxDesktopPath,
|
||||
mode: buildMode,
|
||||
platform: TargetPlatform.linux_x64,
|
||||
);
|
||||
final String clientSourcePath = environment.artifacts
|
||||
.getArtifactPath(
|
||||
Artifact.linuxCppClientWrapper,
|
||||
mode: buildMode,
|
||||
platform: TargetPlatform.linux_x64,
|
||||
);
|
||||
final Directory outputDirectory = environment.fileSystem.directory(
|
||||
environment.fileSystem.path.join(
|
||||
environment.projectDir.path,
|
||||
@@ -60,13 +70,14 @@ class UnpackLinuxDebug extends Target {
|
||||
));
|
||||
final Depfile depfile = unpackDesktopArtifacts(
|
||||
fileSystem: environment.fileSystem,
|
||||
artifactPath: artifactPath,
|
||||
engineSourcePath: engineSourcePath,
|
||||
outputDirectory: outputDirectory,
|
||||
artifacts: _kLinuxArtifacts,
|
||||
clientSourcePath: clientSourcePath,
|
||||
);
|
||||
final DepfileService depfileService = DepfileService(
|
||||
fileSystem: globals.fs,
|
||||
logger: globals.logger,
|
||||
fileSystem: environment.fileSystem,
|
||||
logger: environment.logger,
|
||||
);
|
||||
depfileService.writeToFile(
|
||||
depfile,
|
||||
@@ -85,7 +96,7 @@ class DebugBundleLinuxAssets extends Target {
|
||||
@override
|
||||
List<Target> get dependencies => const <Target>[
|
||||
KernelSnapshot(),
|
||||
UnpackLinuxDebug(),
|
||||
UnpackLinux(),
|
||||
];
|
||||
|
||||
@override
|
||||
@@ -125,8 +136,8 @@ class DebugBundleLinuxAssets extends Target {
|
||||
}
|
||||
final Depfile depfile = await copyAssets(environment, outputDirectory);
|
||||
final DepfileService depfileService = DepfileService(
|
||||
fileSystem: globals.fs,
|
||||
logger: globals.logger,
|
||||
fileSystem: environment.fileSystem,
|
||||
logger: environment.logger,
|
||||
);
|
||||
depfileService.writeToFile(
|
||||
depfile,
|
||||
|
||||
@@ -24,7 +24,6 @@ const List<String> _kWindowsArtifacts = <String>[
|
||||
'flutter_plugin_registrar.h',
|
||||
'flutter_windows.h',
|
||||
'icudtl.dat',
|
||||
'cpp_client_wrapper',
|
||||
];
|
||||
|
||||
const String _kWindowsDepfile = 'windows_engine_sources.d';
|
||||
@@ -52,7 +51,19 @@ class UnpackWindows extends Target {
|
||||
|
||||
@override
|
||||
Future<void> build(Environment environment) async {
|
||||
final String artifactPath = environment.artifacts.getArtifactPath(Artifact.windowsDesktopPath);
|
||||
final BuildMode buildMode = getBuildModeForName(environment.defines[kBuildMode]);
|
||||
final String engineSourcePath = environment.artifacts
|
||||
.getArtifactPath(
|
||||
Artifact.windowsDesktopPath,
|
||||
platform: TargetPlatform.windows_x64,
|
||||
mode: buildMode,
|
||||
);
|
||||
final String clientSourcePath = environment.artifacts
|
||||
.getArtifactPath(
|
||||
Artifact.windowsCppClientWrapper,
|
||||
platform: TargetPlatform.windows_x64,
|
||||
mode: buildMode,
|
||||
);
|
||||
final Directory outputDirectory = environment.fileSystem.directory(
|
||||
environment.fileSystem.path.join(
|
||||
environment.projectDir.path,
|
||||
@@ -64,8 +75,9 @@ class UnpackWindows extends Target {
|
||||
final Depfile depfile = unpackDesktopArtifacts(
|
||||
fileSystem: environment.fileSystem,
|
||||
artifacts: _kWindowsArtifacts,
|
||||
artifactPath: artifactPath,
|
||||
engineSourcePath: engineSourcePath,
|
||||
outputDirectory: outputDirectory,
|
||||
clientSourcePath: clientSourcePath,
|
||||
);
|
||||
final DepfileService depfileService = DepfileService(
|
||||
fileSystem: environment.fileSystem,
|
||||
|
||||
@@ -118,9 +118,9 @@ class Cache {
|
||||
_artifacts.add(IOSEngineArtifacts(this));
|
||||
_artifacts.add(FlutterWebSdk(this));
|
||||
_artifacts.add(FlutterSdk(this));
|
||||
_artifacts.add(WindowsEngineArtifacts(this));
|
||||
_artifacts.add(WindowsEngineArtifacts(this, platform: _platform));
|
||||
_artifacts.add(MacOSEngineArtifacts(this));
|
||||
_artifacts.add(LinuxEngineArtifacts(this));
|
||||
_artifacts.add(LinuxEngineArtifacts(this, platform: _platform));
|
||||
_artifacts.add(LinuxFuchsiaSDKArtifacts(this));
|
||||
_artifacts.add(MacOSFuchsiaSDKArtifacts(this));
|
||||
_artifacts.add(FlutterRunnerSDKArtifacts(this));
|
||||
@@ -879,19 +879,25 @@ class MacOSEngineArtifacts extends EngineCachedArtifact {
|
||||
List<String> getLicenseDirs() => const <String>[];
|
||||
}
|
||||
|
||||
/// Artifacts required for desktop Windows builds.
|
||||
class WindowsEngineArtifacts extends EngineCachedArtifact {
|
||||
WindowsEngineArtifacts(Cache cache) : super(
|
||||
'windows-sdk',
|
||||
cache,
|
||||
DevelopmentArtifact.windows,
|
||||
);
|
||||
WindowsEngineArtifacts(Cache cache, {
|
||||
@required Platform platform,
|
||||
}) : _platform = platform,
|
||||
super(
|
||||
'windows-sdk',
|
||||
cache,
|
||||
DevelopmentArtifact.windows,
|
||||
);
|
||||
|
||||
final Platform _platform;
|
||||
|
||||
@override
|
||||
List<String> getPackageDirs() => const <String>[];
|
||||
|
||||
@override
|
||||
List<List<String>> getBinaryDirs() {
|
||||
if (globals.platform.isWindows || ignorePlatformFiltering) {
|
||||
if (_platform.isWindows || ignorePlatformFiltering) {
|
||||
return _windowsDesktopBinaryDirs;
|
||||
}
|
||||
return const <List<String>>[];
|
||||
@@ -901,19 +907,25 @@ class WindowsEngineArtifacts extends EngineCachedArtifact {
|
||||
List<String> getLicenseDirs() => const <String>[];
|
||||
}
|
||||
|
||||
/// Artifacts required for desktop Linux builds.
|
||||
class LinuxEngineArtifacts extends EngineCachedArtifact {
|
||||
LinuxEngineArtifacts(Cache cache) : super(
|
||||
'linux-sdk',
|
||||
cache,
|
||||
DevelopmentArtifact.linux,
|
||||
);
|
||||
LinuxEngineArtifacts(Cache cache, {
|
||||
@required Platform platform
|
||||
}) : _platform = platform,
|
||||
super(
|
||||
'linux-sdk',
|
||||
cache,
|
||||
DevelopmentArtifact.linux,
|
||||
);
|
||||
|
||||
final Platform _platform;
|
||||
|
||||
@override
|
||||
List<String> getPackageDirs() => const <String>[];
|
||||
|
||||
@override
|
||||
List<List<String>> getBinaryDirs() {
|
||||
if (globals.platform.isLinux || ignorePlatformFiltering) {
|
||||
if (_platform.isLinux || ignorePlatformFiltering) {
|
||||
return _linuxDesktopBinaryDirs;
|
||||
}
|
||||
return const <List<String>>[];
|
||||
@@ -1364,9 +1376,14 @@ void _ensureExists(Directory directory) {
|
||||
}
|
||||
}
|
||||
|
||||
// TODO(jonahwilliams): upload debug desktop artifacts to host-debug and
|
||||
// remove from existing host folder.
|
||||
// https://github.com/flutter/flutter/issues/38935
|
||||
const List<List<String>> _windowsDesktopBinaryDirs = <List<String>>[
|
||||
<String>['windows-x64', 'windows-x64/windows-x64-flutter.zip'],
|
||||
<String>['windows-x64', 'windows-x64/flutter-cpp-client-wrapper.zip'],
|
||||
<String>['windows-x64-profile', 'windows-x64-profile/windows-x64-flutter.zip'],
|
||||
<String>['windows-x64-release', 'windows-x64-release/windows-x64-flutter.zip'],
|
||||
];
|
||||
|
||||
const List<List<String>> _linuxDesktopBinaryDirs = <List<String>>[
|
||||
@@ -1374,9 +1391,6 @@ const List<List<String>> _linuxDesktopBinaryDirs = <List<String>>[
|
||||
<String>['linux-x64', 'linux-x64/flutter-cpp-client-wrapper-glfw.zip'],
|
||||
];
|
||||
|
||||
// TODO(jonahwilliams): upload debug desktop artifacts to host-debug and
|
||||
// remove from existing host folder.
|
||||
// https://github.com/flutter/flutter/issues/38935
|
||||
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'],
|
||||
|
||||
Reference in New Issue
Block a user