mirror of
https://github.com/flutter/flutter
synced 2024-08-25 02:46:31 +00:00
Reland https://github.com/flutter/flutter/pull/143244. It was reverted due to https://github.com/flutter/flutter/issues/144251, which is fixed by https://github.com/flutter/engine/pull/51023.
This commit is contained in:
parent
f89b4f151e
commit
39a13539e0
|
@ -1728,9 +1728,9 @@ List<String> binariesWithEntitlements(String flutterRoot) {
|
||||||
/// cache.
|
/// cache.
|
||||||
List<String> binariesWithoutEntitlements(String flutterRoot) {
|
List<String> binariesWithoutEntitlements(String flutterRoot) {
|
||||||
return <String>[
|
return <String>[
|
||||||
'artifacts/engine/darwin-x64-profile/FlutterMacOS.framework/Versions/A/FlutterMacOS',
|
'artifacts/engine/darwin-x64-profile/FlutterMacOS.xcframework/macos-arm64_x86_64/FlutterMacOS.framework/Versions/A/FlutterMacOS',
|
||||||
'artifacts/engine/darwin-x64-release/FlutterMacOS.framework/Versions/A/FlutterMacOS',
|
'artifacts/engine/darwin-x64-release/FlutterMacOS.xcframework/macos-arm64_x86_64/FlutterMacOS.framework/Versions/A/FlutterMacOS',
|
||||||
'artifacts/engine/darwin-x64/FlutterMacOS.framework/Versions/A/FlutterMacOS',
|
'artifacts/engine/darwin-x64/FlutterMacOS.xcframework/macos-arm64_x86_64/FlutterMacOS.framework/Versions/A/FlutterMacOS',
|
||||||
'artifacts/engine/darwin-x64/font-subset',
|
'artifacts/engine/darwin-x64/font-subset',
|
||||||
'artifacts/engine/darwin-x64/impellerc',
|
'artifacts/engine/darwin-x64/impellerc',
|
||||||
'artifacts/engine/darwin-x64/libpath_ops.dylib',
|
'artifacts/engine/darwin-x64/libpath_ops.dylib',
|
||||||
|
@ -1764,6 +1764,9 @@ List<String> signedXcframeworks(String flutterRoot) {
|
||||||
'artifacts/engine/ios-release/extension_safe/Flutter.xcframework',
|
'artifacts/engine/ios-release/extension_safe/Flutter.xcframework',
|
||||||
'artifacts/engine/ios/Flutter.xcframework',
|
'artifacts/engine/ios/Flutter.xcframework',
|
||||||
'artifacts/engine/ios/extension_safe/Flutter.xcframework',
|
'artifacts/engine/ios/extension_safe/Flutter.xcframework',
|
||||||
|
'artifacts/engine/darwin-x64-profile/FlutterMacOS.xcframework',
|
||||||
|
'artifacts/engine/darwin-x64-release/FlutterMacOS.xcframework',
|
||||||
|
'artifacts/engine/darwin-x64/FlutterMacOS.xcframework',
|
||||||
]
|
]
|
||||||
.map((String relativePath) => path.join(flutterRoot, 'bin', 'cache', relativePath)).toList();
|
.map((String relativePath) => path.join(flutterRoot, 'bin', 'cache', relativePath)).toList();
|
||||||
}
|
}
|
||||||
|
|
|
@ -118,6 +118,12 @@ class PluginTest {
|
||||||
// Currently this test is only implemented for macOS; it can be extended to
|
// Currently this test is only implemented for macOS; it can be extended to
|
||||||
// others as needed.
|
// others as needed.
|
||||||
if (buildTarget == 'macos') {
|
if (buildTarget == 'macos') {
|
||||||
|
// When using a local engine, podhelper.rb will search for a "macos-"
|
||||||
|
// directory within the FlutterMacOS.xcframework, so create a dummy one.
|
||||||
|
Directory(
|
||||||
|
path.join(buildDir.path, 'FlutterMacOS.xcframework/macos-arm64_x86_64'),
|
||||||
|
).createSync(recursive: true);
|
||||||
|
|
||||||
// Clean before regenerating the config to ensure that the pod steps run.
|
// Clean before regenerating the config to ensure that the pod steps run.
|
||||||
await inDirectory(Directory(app.rootPath), () async {
|
await inDirectory(Directory(app.rootPath), () async {
|
||||||
await evalFlutter('clean');
|
await evalFlutter('clean');
|
||||||
|
|
|
@ -137,8 +137,8 @@ def flutter_additional_macos_build_settings(target)
|
||||||
# This podhelper script is at $FLUTTER_ROOT/packages/flutter_tools/bin.
|
# This podhelper script is at $FLUTTER_ROOT/packages/flutter_tools/bin.
|
||||||
# Add search paths from $FLUTTER_ROOT/bin/cache/artifacts/engine.
|
# Add search paths from $FLUTTER_ROOT/bin/cache/artifacts/engine.
|
||||||
artifacts_dir = File.join('..', '..', '..', '..', 'bin', 'cache', 'artifacts', 'engine')
|
artifacts_dir = File.join('..', '..', '..', '..', 'bin', 'cache', 'artifacts', 'engine')
|
||||||
debug_framework_dir = File.expand_path(File.join(artifacts_dir, 'darwin-x64'), __FILE__)
|
debug_framework_dir = File.expand_path(File.join(artifacts_dir, 'darwin-x64', 'FlutterMacOS.xcframework'), __FILE__)
|
||||||
release_framework_dir = File.expand_path(File.join(artifacts_dir, 'darwin-x64-release'), __FILE__)
|
release_framework_dir = File.expand_path(File.join(artifacts_dir, 'darwin-x64-release', 'FlutterMacOS.xcframework'), __FILE__)
|
||||||
application_path = File.dirname(defined_in_file.realpath) if respond_to?(:defined_in_file)
|
application_path = File.dirname(defined_in_file.realpath) if respond_to?(:defined_in_file)
|
||||||
# Find the local engine path, if any.
|
# Find the local engine path, if any.
|
||||||
local_engine = application_path.nil? ?
|
local_engine = application_path.nil? ?
|
||||||
|
@ -156,9 +156,17 @@ def flutter_additional_macos_build_settings(target)
|
||||||
# Skip other updates if it does not depend on Flutter (including transitive dependency)
|
# Skip other updates if it does not depend on Flutter (including transitive dependency)
|
||||||
next unless depends_on_flutter(target, 'FlutterMacOS')
|
next unless depends_on_flutter(target, 'FlutterMacOS')
|
||||||
|
|
||||||
# Profile can't be derived from the CocoaPods build configuration. Use release framework (for linking only).
|
if local_engine
|
||||||
configuration_engine_dir = local_engine || (build_configuration.type == :debug ? debug_framework_dir : release_framework_dir)
|
configuration_engine_dir = File.expand_path(File.join(local_engine, 'FlutterMacOS.xcframework'), __FILE__)
|
||||||
build_configuration.build_settings['FRAMEWORK_SEARCH_PATHS'] = "\"#{configuration_engine_dir}\" $(inherited)"
|
else
|
||||||
|
# Profile can't be derived from the CocoaPods build configuration. Use release framework (for linking only).
|
||||||
|
configuration_engine_dir = (build_configuration.type == :debug ? debug_framework_dir : release_framework_dir)
|
||||||
|
end
|
||||||
|
Dir.new(configuration_engine_dir).each_child do |xcframework_file|
|
||||||
|
if xcframework_file.start_with?('macos-') # Could be macos-arm64_x86_64, macos-arm64, macos-x86_64
|
||||||
|
build_configuration.build_settings['FRAMEWORK_SEARCH_PATHS'] = "\"#{configuration_engine_dir}/#{xcframework_file}\" $(inherited)"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# When deleted, the deployment version will inherit from the higher version derived from the 'Runner' target.
|
# When deleted, the deployment version will inherit from the higher version derived from the 'Runner' target.
|
||||||
# If the pod only supports a higher version, do not delete to correctly produce an error.
|
# If the pod only supports a higher version, do not delete to correctly produce an error.
|
||||||
|
|
|
@ -25,6 +25,7 @@ enum Artifact {
|
||||||
flutterXcframework,
|
flutterXcframework,
|
||||||
/// The framework directory of the macOS desktop.
|
/// The framework directory of the macOS desktop.
|
||||||
flutterMacOSFramework,
|
flutterMacOSFramework,
|
||||||
|
flutterMacOSXcframework,
|
||||||
vmSnapshotData,
|
vmSnapshotData,
|
||||||
isolateSnapshotData,
|
isolateSnapshotData,
|
||||||
icuData,
|
icuData,
|
||||||
|
@ -184,6 +185,8 @@ String? _artifactToFileName(Artifact artifact, Platform hostPlatform, [ BuildMod
|
||||||
return 'Flutter.xcframework';
|
return 'Flutter.xcframework';
|
||||||
case Artifact.flutterMacOSFramework:
|
case Artifact.flutterMacOSFramework:
|
||||||
return 'FlutterMacOS.framework';
|
return 'FlutterMacOS.framework';
|
||||||
|
case Artifact.flutterMacOSXcframework:
|
||||||
|
return 'FlutterMacOS.xcframework';
|
||||||
case Artifact.vmSnapshotData:
|
case Artifact.vmSnapshotData:
|
||||||
return 'vm_isolate_snapshot.bin';
|
return 'vm_isolate_snapshot.bin';
|
||||||
case Artifact.isolateSnapshotData:
|
case Artifact.isolateSnapshotData:
|
||||||
|
@ -598,6 +601,10 @@ class CachedArtifacts implements Artifacts {
|
||||||
final String engineDir = _getEngineArtifactsPath(platform, mode)!;
|
final String engineDir = _getEngineArtifactsPath(platform, mode)!;
|
||||||
return _fileSystem.path.join(engineDir, _artifactToFileName(artifact, _platform));
|
return _fileSystem.path.join(engineDir, _artifactToFileName(artifact, _platform));
|
||||||
}
|
}
|
||||||
|
if (platform != null && artifact == Artifact.flutterMacOSFramework) {
|
||||||
|
final String engineDir = _getEngineArtifactsPath(platform, mode)!;
|
||||||
|
return _getMacOSEngineArtifactPath(engineDir, _fileSystem, _platform);
|
||||||
|
}
|
||||||
return _getHostArtifactPath(artifact, platform ?? _currentHostPlatform(_platform, _operatingSystemUtils), mode);
|
return _getHostArtifactPath(artifact, platform ?? _currentHostPlatform(_platform, _operatingSystemUtils), mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -617,6 +624,7 @@ class CachedArtifacts implements Artifacts {
|
||||||
case Artifact.constFinder:
|
case Artifact.constFinder:
|
||||||
case Artifact.flutterFramework:
|
case Artifact.flutterFramework:
|
||||||
case Artifact.flutterMacOSFramework:
|
case Artifact.flutterMacOSFramework:
|
||||||
|
case Artifact.flutterMacOSXcframework:
|
||||||
case Artifact.flutterPatchedSdkPath:
|
case Artifact.flutterPatchedSdkPath:
|
||||||
case Artifact.flutterTester:
|
case Artifact.flutterTester:
|
||||||
case Artifact.flutterXcframework:
|
case Artifact.flutterXcframework:
|
||||||
|
@ -657,6 +665,7 @@ class CachedArtifacts implements Artifacts {
|
||||||
case Artifact.frontendServerSnapshotForEngineDartSdk:
|
case Artifact.frontendServerSnapshotForEngineDartSdk:
|
||||||
case Artifact.constFinder:
|
case Artifact.constFinder:
|
||||||
case Artifact.flutterMacOSFramework:
|
case Artifact.flutterMacOSFramework:
|
||||||
|
case Artifact.flutterMacOSXcframework:
|
||||||
case Artifact.flutterPatchedSdkPath:
|
case Artifact.flutterPatchedSdkPath:
|
||||||
case Artifact.flutterTester:
|
case Artifact.flutterTester:
|
||||||
case Artifact.fontSubset:
|
case Artifact.fontSubset:
|
||||||
|
@ -705,6 +714,7 @@ class CachedArtifacts implements Artifacts {
|
||||||
case Artifact.constFinder:
|
case Artifact.constFinder:
|
||||||
case Artifact.flutterFramework:
|
case Artifact.flutterFramework:
|
||||||
case Artifact.flutterMacOSFramework:
|
case Artifact.flutterMacOSFramework:
|
||||||
|
case Artifact.flutterMacOSXcframework:
|
||||||
case Artifact.flutterTester:
|
case Artifact.flutterTester:
|
||||||
case Artifact.flutterXcframework:
|
case Artifact.flutterXcframework:
|
||||||
case Artifact.fontSubset:
|
case Artifact.fontSubset:
|
||||||
|
@ -771,6 +781,13 @@ class CachedArtifacts implements Artifacts {
|
||||||
case Artifact.engineDartAotRuntime:
|
case Artifact.engineDartAotRuntime:
|
||||||
return _fileSystem.path.join(_dartSdkPath(_cache), 'bin', _artifactToFileName(artifact, _platform));
|
return _fileSystem.path.join(_dartSdkPath(_cache), 'bin', _artifactToFileName(artifact, _platform));
|
||||||
case Artifact.flutterMacOSFramework:
|
case Artifact.flutterMacOSFramework:
|
||||||
|
String platformDirName = _enginePlatformDirectoryName(platform);
|
||||||
|
if (mode == BuildMode.profile || mode == BuildMode.release) {
|
||||||
|
platformDirName = '$platformDirName-${mode!.cliName}';
|
||||||
|
}
|
||||||
|
final String engineArtifactsPath = _cache.getArtifactDirectory('engine').path;
|
||||||
|
return _getMacOSEngineArtifactPath(_fileSystem.path.join(engineArtifactsPath, platformDirName), _fileSystem, _platform);
|
||||||
|
case Artifact.flutterMacOSXcframework:
|
||||||
case Artifact.linuxDesktopPath:
|
case Artifact.linuxDesktopPath:
|
||||||
case Artifact.windowsDesktopPath:
|
case Artifact.windowsDesktopPath:
|
||||||
case Artifact.linuxHeaders:
|
case Artifact.linuxHeaders:
|
||||||
|
@ -896,6 +913,33 @@ String _getIosEngineArtifactPath(String engineDirectory,
|
||||||
.path;
|
.path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String _getMacOSEngineArtifactPath(
|
||||||
|
String engineDirectory,
|
||||||
|
FileSystem fileSystem,
|
||||||
|
Platform hostPlatform,
|
||||||
|
) {
|
||||||
|
final Directory xcframeworkDirectory = fileSystem
|
||||||
|
.directory(engineDirectory)
|
||||||
|
.childDirectory(_artifactToFileName(Artifact.flutterMacOSXcframework, hostPlatform)!);
|
||||||
|
|
||||||
|
if (!xcframeworkDirectory.existsSync()) {
|
||||||
|
throwToolExit('No xcframework found at ${xcframeworkDirectory.path}. Try running "flutter precache --macos".');
|
||||||
|
}
|
||||||
|
final Directory? flutterFrameworkSource = xcframeworkDirectory
|
||||||
|
.listSync()
|
||||||
|
.whereType<Directory>()
|
||||||
|
.where((Directory platformDirectory) =>
|
||||||
|
platformDirectory.basename.startsWith('macos-'))
|
||||||
|
.firstOrNull;
|
||||||
|
if (flutterFrameworkSource == null) {
|
||||||
|
throwToolExit('No macOS frameworks found in ${xcframeworkDirectory.path}');
|
||||||
|
}
|
||||||
|
|
||||||
|
return flutterFrameworkSource
|
||||||
|
.childDirectory(_artifactToFileName(Artifact.flutterMacOSFramework, hostPlatform)!)
|
||||||
|
.path;
|
||||||
|
}
|
||||||
|
|
||||||
/// Manages the artifacts of a locally built engine.
|
/// Manages the artifacts of a locally built engine.
|
||||||
class CachedLocalEngineArtifacts implements Artifacts {
|
class CachedLocalEngineArtifacts implements Artifacts {
|
||||||
CachedLocalEngineArtifacts(
|
CachedLocalEngineArtifacts(
|
||||||
|
@ -1054,7 +1098,7 @@ class CachedLocalEngineArtifacts implements Artifacts {
|
||||||
return _fileSystem.path.join(localEngineInfo.targetOutPath, 'gen', 'flutter', 'lib', 'snapshot', artifactFileName);
|
return _fileSystem.path.join(localEngineInfo.targetOutPath, 'gen', 'flutter', 'lib', 'snapshot', artifactFileName);
|
||||||
case Artifact.icuData:
|
case Artifact.icuData:
|
||||||
case Artifact.flutterXcframework:
|
case Artifact.flutterXcframework:
|
||||||
case Artifact.flutterMacOSFramework:
|
case Artifact.flutterMacOSXcframework:
|
||||||
return _fileSystem.path.join(localEngineInfo.targetOutPath, artifactFileName);
|
return _fileSystem.path.join(localEngineInfo.targetOutPath, artifactFileName);
|
||||||
case Artifact.platformKernelDill:
|
case Artifact.platformKernelDill:
|
||||||
if (platform == TargetPlatform.fuchsia_x64 || platform == TargetPlatform.fuchsia_arm64) {
|
if (platform == TargetPlatform.fuchsia_x64 || platform == TargetPlatform.fuchsia_arm64) {
|
||||||
|
@ -1066,6 +1110,9 @@ class CachedLocalEngineArtifacts implements Artifacts {
|
||||||
case Artifact.flutterFramework:
|
case Artifact.flutterFramework:
|
||||||
return _getIosEngineArtifactPath(
|
return _getIosEngineArtifactPath(
|
||||||
localEngineInfo.targetOutPath, environmentType, _fileSystem, _platform);
|
localEngineInfo.targetOutPath, environmentType, _fileSystem, _platform);
|
||||||
|
case Artifact.flutterMacOSFramework:
|
||||||
|
return _getMacOSEngineArtifactPath(
|
||||||
|
localEngineInfo.targetOutPath, _fileSystem, _platform);
|
||||||
case Artifact.flutterPatchedSdkPath:
|
case Artifact.flutterPatchedSdkPath:
|
||||||
// When using local engine always use [BuildMode.debug] regardless of
|
// When using local engine always use [BuildMode.debug] regardless of
|
||||||
// what was specified in [mode] argument because local engine will
|
// what was specified in [mode] argument because local engine will
|
||||||
|
@ -1246,6 +1293,7 @@ class CachedLocalWebSdkArtifacts implements Artifacts {
|
||||||
case Artifact.flutterFramework:
|
case Artifact.flutterFramework:
|
||||||
case Artifact.flutterXcframework:
|
case Artifact.flutterXcframework:
|
||||||
case Artifact.flutterMacOSFramework:
|
case Artifact.flutterMacOSFramework:
|
||||||
|
case Artifact.flutterMacOSXcframework:
|
||||||
case Artifact.vmSnapshotData:
|
case Artifact.vmSnapshotData:
|
||||||
case Artifact.isolateSnapshotData:
|
case Artifact.isolateSnapshotData:
|
||||||
case Artifact.icuData:
|
case Artifact.icuData:
|
||||||
|
|
|
@ -157,7 +157,7 @@ class ReleaseUnpackMacOS extends UnpackMacOS {
|
||||||
@override
|
@override
|
||||||
List<Source> get inputs => <Source>[
|
List<Source> get inputs => <Source>[
|
||||||
...super.inputs,
|
...super.inputs,
|
||||||
const Source.artifact(Artifact.flutterMacOSFramework, mode: BuildMode.release),
|
const Source.artifact(Artifact.flutterMacOSXcframework, mode: BuildMode.release),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -171,7 +171,7 @@ class ProfileUnpackMacOS extends UnpackMacOS {
|
||||||
@override
|
@override
|
||||||
List<Source> get inputs => <Source>[
|
List<Source> get inputs => <Source>[
|
||||||
...super.inputs,
|
...super.inputs,
|
||||||
const Source.artifact(Artifact.flutterMacOSFramework, mode: BuildMode.profile),
|
const Source.artifact(Artifact.flutterMacOSXcframework, mode: BuildMode.profile),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -185,7 +185,7 @@ class DebugUnpackMacOS extends UnpackMacOS {
|
||||||
@override
|
@override
|
||||||
List<Source> get inputs => <Source>[
|
List<Source> get inputs => <Source>[
|
||||||
...super.inputs,
|
...super.inputs,
|
||||||
const Source.artifact(Artifact.flutterMacOSFramework, mode: BuildMode.debug),
|
const Source.artifact(Artifact.flutterMacOSXcframework, mode: BuildMode.debug),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -944,14 +944,6 @@ abstract class EngineCachedArtifact extends CachedArtifact {
|
||||||
await artifactUpdater.downloadZipArchive('Downloading $friendlyName tools...', Uri.parse(url + urlPath), dir);
|
await artifactUpdater.downloadZipArchive('Downloading $friendlyName tools...', Uri.parse(url + urlPath), dir);
|
||||||
|
|
||||||
_makeFilesExecutable(dir, operatingSystemUtils);
|
_makeFilesExecutable(dir, operatingSystemUtils);
|
||||||
|
|
||||||
final File frameworkZip = fileSystem.file(fileSystem.path.join(dir.path, 'FlutterMacOS.framework.zip'));
|
|
||||||
if (frameworkZip.existsSync()) {
|
|
||||||
final Directory framework = fileSystem.directory(fileSystem.path.join(dir.path, 'FlutterMacOS.framework'));
|
|
||||||
ErrorHandlingFileSystem.deleteIfExists(framework, recursive: true);
|
|
||||||
framework.createSync();
|
|
||||||
operatingSystemUtils.unzip(frameworkZip, framework);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
final File licenseSource = cache.getLicenseFile();
|
final File licenseSource = cache.getLicenseFile();
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
import 'package:meta/meta.dart';
|
import 'package:meta/meta.dart';
|
||||||
|
|
||||||
|
import '../artifacts.dart';
|
||||||
import '../base/common.dart';
|
import '../base/common.dart';
|
||||||
import '../base/file_system.dart';
|
import '../base/file_system.dart';
|
||||||
import '../base/io.dart';
|
import '../base/io.dart';
|
||||||
|
@ -83,13 +84,16 @@ class BuildMacOSFrameworkCommand extends BuildFrameworkCommand {
|
||||||
|
|
||||||
if (boolArg('cocoapods')) {
|
if (boolArg('cocoapods')) {
|
||||||
produceFlutterPodspec(buildInfo.mode, modeDirectory, force: boolArg('force'));
|
produceFlutterPodspec(buildInfo.mode, modeDirectory, force: boolArg('force'));
|
||||||
|
} else {
|
||||||
|
await _produceFlutterFramework(buildInfo, modeDirectory);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build aot, create App.framework and copy FlutterMacOS.framework. Make XCFrameworks.
|
final Directory buildOutput = modeDirectory.childDirectory('macos');
|
||||||
await _produceAppFramework(buildInfo, modeDirectory);
|
|
||||||
|
// Build aot, create App.framework. Make XCFrameworks.
|
||||||
|
await _produceAppFramework(buildInfo, modeDirectory, buildOutput);
|
||||||
|
|
||||||
// Build and copy plugins.
|
// Build and copy plugins.
|
||||||
final Directory buildOutput = modeDirectory.childDirectory('macos');
|
|
||||||
await processPodsIfNeeded(project.macos, getMacOSBuildDirectory(), buildInfo.mode);
|
await processPodsIfNeeded(project.macos, getMacOSBuildDirectory(), buildInfo.mode);
|
||||||
if (boolArg('plugins') && hasPlugins(project)) {
|
if (boolArg('plugins') && hasPlugins(project)) {
|
||||||
await _producePlugins(xcodeBuildConfiguration, buildOutput, modeDirectory);
|
await _producePlugins(xcodeBuildConfiguration, buildOutput, modeDirectory);
|
||||||
|
@ -200,15 +204,15 @@ end
|
||||||
Future<void> _produceAppFramework(
|
Future<void> _produceAppFramework(
|
||||||
BuildInfo buildInfo,
|
BuildInfo buildInfo,
|
||||||
Directory outputBuildDirectory,
|
Directory outputBuildDirectory,
|
||||||
|
Directory macosBuildOutput,
|
||||||
) async {
|
) async {
|
||||||
final Status status = globals.logger.startProgress(
|
final Status status = globals.logger.startProgress(
|
||||||
' ├─Building App.xcframework and FlutterMacOS.xcframework...',
|
' ├─Building App.xcframework...',
|
||||||
);
|
);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
final Environment environment = Environment(
|
final Environment environment = Environment(
|
||||||
projectDir: globals.fs.currentDirectory,
|
projectDir: globals.fs.currentDirectory,
|
||||||
outputDir: outputBuildDirectory,
|
outputDir: macosBuildOutput,
|
||||||
buildDir: project.dartTool.childDirectory('flutter_build'),
|
buildDir: project.dartTool.childDirectory('flutter_build'),
|
||||||
cacheDir: globals.cache.getRoot(),
|
cacheDir: globals.cache.getRoot(),
|
||||||
flutterRootDir: globals.fs.directory(Cache.flutterRoot),
|
flutterRootDir: globals.fs.directory(Cache.flutterRoot),
|
||||||
|
@ -251,7 +255,7 @@ end
|
||||||
status.stop();
|
status.stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
final Directory appFramework = outputBuildDirectory.childDirectory('App.framework');
|
final Directory appFramework = macosBuildOutput.childDirectory('App.framework');
|
||||||
await BuildFrameworkCommand.produceXCFramework(
|
await BuildFrameworkCommand.produceXCFramework(
|
||||||
<Directory>[appFramework],
|
<Directory>[appFramework],
|
||||||
'App',
|
'App',
|
||||||
|
@ -259,18 +263,37 @@ end
|
||||||
globals.processManager,
|
globals.processManager,
|
||||||
);
|
);
|
||||||
appFramework.deleteSync(recursive: true);
|
appFramework.deleteSync(recursive: true);
|
||||||
final Directory flutterFramework = outputBuildDirectory.childDirectory('FlutterMacOS.framework');
|
}
|
||||||
|
|
||||||
// If FlutterMacOS.podspec was generated, do not generate XCFramework.
|
Future<void> _produceFlutterFramework(
|
||||||
if (!boolArg('cocoapods')) {
|
BuildInfo buildInfo,
|
||||||
await BuildFrameworkCommand.produceXCFramework(
|
Directory modeDirectory,
|
||||||
<Directory>[flutterFramework],
|
) async {
|
||||||
'FlutterMacOS',
|
final Status status = globals.logger.startProgress(
|
||||||
outputBuildDirectory,
|
' ├─Copying FlutterMacOS.xcframework...',
|
||||||
globals.processManager,
|
);
|
||||||
|
final String engineCacheFlutterFrameworkDirectory = globals.artifacts!.getArtifactPath(
|
||||||
|
Artifact.flutterMacOSXcframework,
|
||||||
|
platform: TargetPlatform.darwin,
|
||||||
|
mode: buildInfo.mode,
|
||||||
|
);
|
||||||
|
final String flutterFrameworkFileName = globals.fs.path.basename(
|
||||||
|
engineCacheFlutterFrameworkDirectory,
|
||||||
|
);
|
||||||
|
final Directory flutterFrameworkCopy = modeDirectory.childDirectory(
|
||||||
|
flutterFrameworkFileName,
|
||||||
|
);
|
||||||
|
|
||||||
|
try {
|
||||||
|
// Copy xcframework engine cache framework to mode directory.
|
||||||
|
copyDirectory(
|
||||||
|
globals.fs.directory(engineCacheFlutterFrameworkDirectory),
|
||||||
|
flutterFrameworkCopy,
|
||||||
|
followLinks: false,
|
||||||
);
|
);
|
||||||
|
} finally {
|
||||||
|
status.stop();
|
||||||
}
|
}
|
||||||
flutterFramework.deleteSync(recursive: true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _producePlugins(
|
Future<void> _producePlugins(
|
||||||
|
|
|
@ -858,12 +858,12 @@ List<List<String>> _getWindowsDesktopBinaryDirs(String arch) {
|
||||||
}
|
}
|
||||||
|
|
||||||
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/framework.zip'],
|
||||||
<String>['darwin-x64', 'darwin-x64/gen_snapshot.zip'],
|
<String>['darwin-x64', 'darwin-x64/gen_snapshot.zip'],
|
||||||
<String>['darwin-x64-profile', 'darwin-x64-profile/FlutterMacOS.framework.zip'],
|
<String>['darwin-x64-profile', 'darwin-x64-profile/framework.zip'],
|
||||||
<String>['darwin-x64-profile', 'darwin-x64-profile/artifacts.zip'],
|
<String>['darwin-x64-profile', 'darwin-x64-profile/artifacts.zip'],
|
||||||
<String>['darwin-x64-profile', 'darwin-x64-profile/gen_snapshot.zip'],
|
<String>['darwin-x64-profile', 'darwin-x64-profile/gen_snapshot.zip'],
|
||||||
<String>['darwin-x64-release', 'darwin-x64-release/FlutterMacOS.framework.zip'],
|
<String>['darwin-x64-release', 'darwin-x64-release/framework.zip'],
|
||||||
<String>['darwin-x64-release', 'darwin-x64-release/artifacts.zip'],
|
<String>['darwin-x64-release', 'darwin-x64-release/artifacts.zip'],
|
||||||
<String>['darwin-x64-release', 'darwin-x64-release/gen_snapshot.zip'],
|
<String>['darwin-x64-release', 'darwin-x64-release/gen_snapshot.zip'],
|
||||||
];
|
];
|
||||||
|
|
|
@ -93,12 +93,6 @@ void main() {
|
||||||
.childDirectory('Flutter.framework')
|
.childDirectory('Flutter.framework')
|
||||||
.createSync(recursive: true);
|
.createSync(recursive: true);
|
||||||
|
|
||||||
// TODO(jmagman): Remove ios-arm64_armv7 checks when armv7 engine artifacts are removed.
|
|
||||||
fileSystem
|
|
||||||
.directory(xcframeworkPath)
|
|
||||||
.childDirectory('ios-arm64_armv7')
|
|
||||||
.childDirectory('Flutter.framework')
|
|
||||||
.createSync(recursive: true);
|
|
||||||
expect(
|
expect(
|
||||||
artifacts.getArtifactPath(Artifact.flutterFramework,
|
artifacts.getArtifactPath(Artifact.flutterFramework,
|
||||||
platform: TargetPlatform.ios,
|
platform: TargetPlatform.ios,
|
||||||
|
@ -118,16 +112,9 @@ void main() {
|
||||||
'ios-arm64',
|
'ios-arm64',
|
||||||
'Flutter.framework',
|
'Flutter.framework',
|
||||||
);
|
);
|
||||||
final String expectedArmv7ReleaseFrameworkArtifact = fileSystem.path.join(
|
|
||||||
xcframeworkPath,
|
|
||||||
'ios-arm64_armv7',
|
|
||||||
'Flutter.framework',
|
|
||||||
);
|
|
||||||
|
|
||||||
// TODO(jmagman): Replace with expect(actualReleaseFrameworkArtifact, expectedArm64ReleaseFrameworkArtifact) when armv7 engine artifacts are removed.
|
|
||||||
expect(
|
expect(
|
||||||
actualReleaseFrameworkArtifact,
|
actualReleaseFrameworkArtifact,
|
||||||
anyOf(expectedArm64ReleaseFrameworkArtifact, expectedArmv7ReleaseFrameworkArtifact),
|
expectedArm64ReleaseFrameworkArtifact,
|
||||||
);
|
);
|
||||||
expect(
|
expect(
|
||||||
artifacts.getArtifactPath(Artifact.flutterXcframework, platform: TargetPlatform.ios, mode: BuildMode.release),
|
artifacts.getArtifactPath(Artifact.flutterXcframework, platform: TargetPlatform.ios, mode: BuildMode.release),
|
||||||
|
@ -148,6 +135,87 @@ void main() {
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
testWithoutContext('getArtifactPath for FlutterMacOS.framework and FlutterMacOS.xcframework', () {
|
||||||
|
final String xcframeworkPath = fileSystem.path.join(
|
||||||
|
'root',
|
||||||
|
'bin',
|
||||||
|
'cache',
|
||||||
|
'artifacts',
|
||||||
|
'engine',
|
||||||
|
'darwin-x64-release',
|
||||||
|
'FlutterMacOS.xcframework',
|
||||||
|
);
|
||||||
|
final String xcframeworkPathWithUnsetPlatform = fileSystem.path.join(
|
||||||
|
'root',
|
||||||
|
'bin',
|
||||||
|
'cache',
|
||||||
|
'artifacts',
|
||||||
|
'engine',
|
||||||
|
'linux-x64-release',
|
||||||
|
'FlutterMacOS.xcframework',
|
||||||
|
);
|
||||||
|
expect(
|
||||||
|
artifacts.getArtifactPath(
|
||||||
|
Artifact.flutterMacOSXcframework,
|
||||||
|
platform: TargetPlatform.darwin,
|
||||||
|
mode: BuildMode.release,
|
||||||
|
),
|
||||||
|
xcframeworkPath,
|
||||||
|
);
|
||||||
|
expect(
|
||||||
|
artifacts.getArtifactPath(
|
||||||
|
Artifact.flutterMacOSXcframework,
|
||||||
|
mode: BuildMode.release,
|
||||||
|
),
|
||||||
|
xcframeworkPathWithUnsetPlatform,
|
||||||
|
);
|
||||||
|
expect(
|
||||||
|
() => artifacts.getArtifactPath(
|
||||||
|
Artifact.flutterMacOSFramework,
|
||||||
|
platform: TargetPlatform.darwin,
|
||||||
|
mode: BuildMode.release,
|
||||||
|
),
|
||||||
|
throwsToolExit(
|
||||||
|
message:
|
||||||
|
'No xcframework found at $xcframeworkPath.'),
|
||||||
|
);
|
||||||
|
expect(
|
||||||
|
() => artifacts.getArtifactPath(
|
||||||
|
Artifact.flutterMacOSFramework,
|
||||||
|
mode: BuildMode.release,
|
||||||
|
),
|
||||||
|
throwsToolExit(
|
||||||
|
message:
|
||||||
|
'No xcframework found at $xcframeworkPathWithUnsetPlatform.'),
|
||||||
|
);
|
||||||
|
fileSystem.directory(xcframeworkPath).createSync(recursive: true);
|
||||||
|
expect(
|
||||||
|
() => artifacts.getArtifactPath(
|
||||||
|
Artifact.flutterMacOSFramework,
|
||||||
|
platform: TargetPlatform.darwin,
|
||||||
|
mode: BuildMode.release,
|
||||||
|
),
|
||||||
|
throwsToolExit(message: 'No macOS frameworks found in $xcframeworkPath'),
|
||||||
|
);
|
||||||
|
fileSystem
|
||||||
|
.directory(xcframeworkPath)
|
||||||
|
.childDirectory('macos-arm64_x86_64')
|
||||||
|
.childDirectory('FlutterMacOS.framework')
|
||||||
|
.createSync(recursive: true);
|
||||||
|
expect(
|
||||||
|
artifacts.getArtifactPath(
|
||||||
|
Artifact.flutterMacOSFramework,
|
||||||
|
platform: TargetPlatform.darwin,
|
||||||
|
mode: BuildMode.release,
|
||||||
|
),
|
||||||
|
fileSystem.path.join(
|
||||||
|
xcframeworkPath,
|
||||||
|
'macos-arm64_x86_64',
|
||||||
|
'FlutterMacOS.framework',
|
||||||
|
),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
testWithoutContext('Precompiled web AMD module system artifact paths are correct', () {
|
testWithoutContext('Precompiled web AMD module system artifact paths are correct', () {
|
||||||
expect(
|
expect(
|
||||||
artifacts.getHostArtifact(HostArtifact.webPrecompiledAmdSdk).path,
|
artifacts.getHostArtifact(HostArtifact.webPrecompiledAmdSdk).path,
|
||||||
|
@ -269,6 +337,92 @@ void main() {
|
||||||
operatingSystemUtils: FakeOperatingSystemUtils());
|
operatingSystemUtils: FakeOperatingSystemUtils());
|
||||||
});
|
});
|
||||||
|
|
||||||
|
testWithoutContext('getArtifactPath for FlutterMacOS.framework and FlutterMacOS.xcframework', () {
|
||||||
|
final String xcframeworkPath = fileSystem.path.join(
|
||||||
|
'/out',
|
||||||
|
'android_debug_unopt',
|
||||||
|
'FlutterMacOS.xcframework',
|
||||||
|
);
|
||||||
|
expect(
|
||||||
|
artifacts.getArtifactPath(
|
||||||
|
Artifact.flutterMacOSXcframework,
|
||||||
|
platform: TargetPlatform.darwin,
|
||||||
|
mode: BuildMode.release,
|
||||||
|
),
|
||||||
|
xcframeworkPath,
|
||||||
|
);
|
||||||
|
expect(
|
||||||
|
artifacts.getArtifactPath(
|
||||||
|
Artifact.flutterMacOSXcframework,
|
||||||
|
mode: BuildMode.release,
|
||||||
|
),
|
||||||
|
xcframeworkPath,
|
||||||
|
);
|
||||||
|
expect(
|
||||||
|
() => artifacts.getArtifactPath(
|
||||||
|
Artifact.flutterMacOSFramework,
|
||||||
|
platform: TargetPlatform.darwin,
|
||||||
|
mode: BuildMode.release,
|
||||||
|
),
|
||||||
|
throwsToolExit(
|
||||||
|
message:
|
||||||
|
'No xcframework found at /out/android_debug_unopt/FlutterMacOS.xcframework'),
|
||||||
|
);
|
||||||
|
expect(
|
||||||
|
() => artifacts.getArtifactPath(
|
||||||
|
Artifact.flutterMacOSFramework,
|
||||||
|
mode: BuildMode.release,
|
||||||
|
),
|
||||||
|
throwsToolExit(
|
||||||
|
message:
|
||||||
|
'No xcframework found at /out/android_debug_unopt/FlutterMacOS.xcframework'),
|
||||||
|
);
|
||||||
|
fileSystem.directory(xcframeworkPath).createSync(recursive: true);
|
||||||
|
expect(
|
||||||
|
() => artifacts.getArtifactPath(
|
||||||
|
Artifact.flutterMacOSFramework,
|
||||||
|
platform: TargetPlatform.darwin,
|
||||||
|
mode: BuildMode.release,
|
||||||
|
),
|
||||||
|
throwsToolExit(
|
||||||
|
message:
|
||||||
|
'No macOS frameworks found in /out/android_debug_unopt/FlutterMacOS.xcframework'),
|
||||||
|
);
|
||||||
|
expect(
|
||||||
|
() => artifacts.getArtifactPath(
|
||||||
|
Artifact.flutterMacOSFramework,
|
||||||
|
mode: BuildMode.release,
|
||||||
|
),
|
||||||
|
throwsToolExit(
|
||||||
|
message:
|
||||||
|
'No macOS frameworks found in /out/android_debug_unopt/FlutterMacOS.xcframework'),
|
||||||
|
);
|
||||||
|
|
||||||
|
fileSystem
|
||||||
|
.directory(xcframeworkPath)
|
||||||
|
.childDirectory('macos-arm64_x86_64')
|
||||||
|
.childDirectory('FlutterMacOS.framework')
|
||||||
|
.createSync(recursive: true);
|
||||||
|
|
||||||
|
expect(
|
||||||
|
artifacts.getArtifactPath(
|
||||||
|
Artifact.flutterMacOSFramework,
|
||||||
|
platform: TargetPlatform.darwin,
|
||||||
|
mode: BuildMode.release,
|
||||||
|
),
|
||||||
|
fileSystem.path
|
||||||
|
.join(xcframeworkPath, 'macos-arm64_x86_64', 'FlutterMacOS.framework'),
|
||||||
|
);
|
||||||
|
expect(
|
||||||
|
artifacts.getArtifactPath(
|
||||||
|
Artifact.flutterMacOSFramework,
|
||||||
|
mode: BuildMode.release,
|
||||||
|
),
|
||||||
|
fileSystem.path
|
||||||
|
.join(xcframeworkPath, 'macos-arm64_x86_64', 'FlutterMacOS.framework'),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
testWithoutContext('getArtifactPath', () {
|
testWithoutContext('getArtifactPath', () {
|
||||||
final String xcframeworkPath = artifacts.getArtifactPath(
|
final String xcframeworkPath = artifacts.getArtifactPath(
|
||||||
Artifact.flutterXcframework,
|
Artifact.flutterXcframework,
|
||||||
|
@ -311,7 +465,7 @@ void main() {
|
||||||
.createSync(recursive: true);
|
.createSync(recursive: true);
|
||||||
fileSystem
|
fileSystem
|
||||||
.directory(xcframeworkPath)
|
.directory(xcframeworkPath)
|
||||||
.childDirectory('ios-arm64_armv7')
|
.childDirectory('ios-arm64')
|
||||||
.childDirectory('Flutter.framework')
|
.childDirectory('Flutter.framework')
|
||||||
.createSync(recursive: true);
|
.createSync(recursive: true);
|
||||||
fileSystem
|
fileSystem
|
||||||
|
@ -339,7 +493,7 @@ void main() {
|
||||||
environmentType: EnvironmentType.physical,
|
environmentType: EnvironmentType.physical,
|
||||||
),
|
),
|
||||||
fileSystem.path
|
fileSystem.path
|
||||||
.join(xcframeworkPath, 'ios-arm64_armv7', 'Flutter.framework'),
|
.join(xcframeworkPath, 'ios-arm64', 'Flutter.framework'),
|
||||||
);
|
);
|
||||||
expect(
|
expect(
|
||||||
artifacts.getArtifactPath(
|
artifacts.getArtifactPath(
|
||||||
|
|
|
@ -393,33 +393,6 @@ void main() {
|
||||||
expect(operatingSystemUtils.chmods, <List<String>>[<String>['/.tmp_rand0/flutter_cache_test_artifact.rand0/bin_dir', 'a+r,a+x']]);
|
expect(operatingSystemUtils.chmods, <List<String>>[<String>['/.tmp_rand0/flutter_cache_test_artifact.rand0/bin_dir', 'a+r,a+x']]);
|
||||||
});
|
});
|
||||||
|
|
||||||
testWithoutContext('EngineCachedArtifact removes unzipped FlutterMacOS.framework before replacing', () async {
|
|
||||||
final OperatingSystemUtils operatingSystemUtils = FakeOperatingSystemUtils();
|
|
||||||
final FileSystem fileSystem = MemoryFileSystem.test();
|
|
||||||
final Directory artifactDir = fileSystem.systemTempDirectory.createTempSync('flutter_cache_test_artifact.');
|
|
||||||
final Directory downloadDir = fileSystem.systemTempDirectory.createTempSync('flutter_cache_test_download.');
|
|
||||||
final FakeSecondaryCache cache = FakeSecondaryCache()
|
|
||||||
..artifactDirectory = artifactDir
|
|
||||||
..downloadDir = downloadDir;
|
|
||||||
|
|
||||||
final Directory binDir = artifactDir.childDirectory('bin_dir')..createSync();
|
|
||||||
binDir.childFile('FlutterMacOS.framework.zip').createSync();
|
|
||||||
final Directory unzippedFramework = binDir.childDirectory('FlutterMacOS.framework');
|
|
||||||
final File staleFile = unzippedFramework.childFile('stale_file')..createSync(recursive: true);
|
|
||||||
artifactDir.childFile('unused_url_path').createSync();
|
|
||||||
|
|
||||||
final FakeCachedArtifact artifact = FakeCachedArtifact(
|
|
||||||
cache: cache,
|
|
||||||
binaryDirs: <List<String>>[
|
|
||||||
<String>['bin_dir', 'unused_url_path'],
|
|
||||||
],
|
|
||||||
requiredArtifacts: DevelopmentArtifact.universal,
|
|
||||||
);
|
|
||||||
await artifact.updateInner(FakeArtifactUpdater(), fileSystem, operatingSystemUtils);
|
|
||||||
expect(unzippedFramework, exists);
|
|
||||||
expect(staleFile, isNot(exists));
|
|
||||||
});
|
|
||||||
|
|
||||||
testWithoutContext('Try to remove without a parent', () async {
|
testWithoutContext('Try to remove without a parent', () async {
|
||||||
final FileSystem fileSystem = MemoryFileSystem.test();
|
final FileSystem fileSystem = MemoryFileSystem.test();
|
||||||
final Directory parent = fileSystem.directory('dir');
|
final Directory parent = fileSystem.directory('dir');
|
||||||
|
|
|
@ -24,6 +24,38 @@ void main() {
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('verify FlutterMacOS.xcframework artifact', () {
|
||||||
|
final String flutterRoot = getFlutterRoot();
|
||||||
|
|
||||||
|
final Directory xcframeworkArtifact = fileSystem.directory(
|
||||||
|
fileSystem.path.join(
|
||||||
|
flutterRoot,
|
||||||
|
'bin',
|
||||||
|
'cache',
|
||||||
|
'artifacts',
|
||||||
|
'engine',
|
||||||
|
'darwin-x64',
|
||||||
|
'FlutterMacOS.xcframework',
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
final Directory tempDir = createResolvedTempDirectorySync('macos_content_validation.');
|
||||||
|
|
||||||
|
// Pre-cache iOS engine Flutter.xcframework artifacts.
|
||||||
|
final ProcessResult result = processManager.runSync(
|
||||||
|
<String>[
|
||||||
|
flutterBin,
|
||||||
|
...getLocalEngineArguments(),
|
||||||
|
'precache',
|
||||||
|
'--macos',
|
||||||
|
],
|
||||||
|
workingDirectory: tempDir.path,
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(result, const ProcessResultMatcher());
|
||||||
|
expect(xcframeworkArtifact.existsSync(), isTrue);
|
||||||
|
});
|
||||||
|
|
||||||
for (final String buildMode in <String>['Debug', 'Release']) {
|
for (final String buildMode in <String>['Debug', 'Release']) {
|
||||||
final String buildModeLower = buildMode.toLowerCase();
|
final String buildModeLower = buildMode.toLowerCase();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue