mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00
Build/copy macOS frameworks to built products instead of ephemeral directory (#72378)
This commit is contained in:
parent
becf09c515
commit
d6857bc026
@ -416,10 +416,6 @@
|
||||
CODE_SIGN_ENTITLEMENTS = Runner/DebugProfile.entitlements;
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
COMBINE_HIDPI_IMAGES = YES;
|
||||
FRAMEWORK_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"$(PROJECT_DIR)/Flutter/ephemeral",
|
||||
);
|
||||
INFOPLIST_FILE = Runner/Info.plist;
|
||||
LD_RUNPATH_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
@ -546,10 +542,6 @@
|
||||
CODE_SIGN_ENTITLEMENTS = Runner/DebugProfile.entitlements;
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
COMBINE_HIDPI_IMAGES = YES;
|
||||
FRAMEWORK_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"$(PROJECT_DIR)/Flutter/ephemeral",
|
||||
);
|
||||
INFOPLIST_FILE = Runner/Info.plist;
|
||||
LD_RUNPATH_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
@ -570,10 +562,6 @@
|
||||
CODE_SIGN_ENTITLEMENTS = Runner/Release.entitlements;
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
COMBINE_HIDPI_IMAGES = YES;
|
||||
FRAMEWORK_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"$(PROJECT_DIR)/Flutter/ephemeral",
|
||||
);
|
||||
INFOPLIST_FILE = Runner/Info.plist;
|
||||
LD_RUNPATH_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
|
@ -421,10 +421,6 @@
|
||||
CODE_SIGN_ENTITLEMENTS = Runner/DebugProfile.entitlements;
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
COMBINE_HIDPI_IMAGES = YES;
|
||||
FRAMEWORK_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"$(PROJECT_DIR)/Flutter/ephemeral",
|
||||
);
|
||||
INFOPLIST_FILE = Runner/Info.plist;
|
||||
LD_RUNPATH_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
@ -551,10 +547,6 @@
|
||||
CODE_SIGN_ENTITLEMENTS = Runner/DebugProfile.entitlements;
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
COMBINE_HIDPI_IMAGES = YES;
|
||||
FRAMEWORK_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"$(PROJECT_DIR)/Flutter/ephemeral",
|
||||
);
|
||||
INFOPLIST_FILE = Runner/Info.plist;
|
||||
LD_RUNPATH_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
@ -575,10 +567,6 @@
|
||||
CODE_SIGN_ENTITLEMENTS = Runner/Release.entitlements;
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
COMBINE_HIDPI_IMAGES = YES;
|
||||
FRAMEWORK_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"$(PROJECT_DIR)/Flutter/ephemeral",
|
||||
);
|
||||
INFOPLIST_FILE = Runner/Info.plist;
|
||||
LD_RUNPATH_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
|
@ -361,10 +361,6 @@
|
||||
CODE_SIGN_ENTITLEMENTS = Runner/DebugProfile.entitlements;
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
COMBINE_HIDPI_IMAGES = YES;
|
||||
FRAMEWORK_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"$(PROJECT_DIR)/Flutter/ephemeral",
|
||||
);
|
||||
INFOPLIST_FILE = Runner/Info.plist;
|
||||
LD_RUNPATH_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
@ -491,10 +487,6 @@
|
||||
CODE_SIGN_ENTITLEMENTS = Runner/DebugProfile.entitlements;
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
COMBINE_HIDPI_IMAGES = YES;
|
||||
FRAMEWORK_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"$(PROJECT_DIR)/Flutter/ephemeral",
|
||||
);
|
||||
INFOPLIST_FILE = Runner/Info.plist;
|
||||
LD_RUNPATH_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
@ -515,10 +507,6 @@
|
||||
CODE_SIGN_ENTITLEMENTS = Runner/Release.entitlements;
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
COMBINE_HIDPI_IMAGES = YES;
|
||||
FRAMEWORK_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"$(PROJECT_DIR)/Flutter/ephemeral",
|
||||
);
|
||||
INFOPLIST_FILE = Runner/Info.plist;
|
||||
LD_RUNPATH_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
|
@ -361,10 +361,6 @@
|
||||
CODE_SIGN_ENTITLEMENTS = Runner/DebugProfile.entitlements;
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
COMBINE_HIDPI_IMAGES = YES;
|
||||
FRAMEWORK_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"$(PROJECT_DIR)/Flutter/ephemeral",
|
||||
);
|
||||
INFOPLIST_FILE = Runner/Info.plist;
|
||||
LD_RUNPATH_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
@ -491,10 +487,6 @@
|
||||
CODE_SIGN_ENTITLEMENTS = Runner/DebugProfile.entitlements;
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
COMBINE_HIDPI_IMAGES = YES;
|
||||
FRAMEWORK_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"$(PROJECT_DIR)/Flutter/ephemeral",
|
||||
);
|
||||
INFOPLIST_FILE = Runner/Info.plist;
|
||||
LD_RUNPATH_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
@ -515,10 +507,6 @@
|
||||
CODE_SIGN_ENTITLEMENTS = Runner/Release.entitlements;
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
COMBINE_HIDPI_IMAGES = YES;
|
||||
FRAMEWORK_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"$(PROJECT_DIR)/Flutter/ephemeral",
|
||||
);
|
||||
INFOPLIST_FILE = Runner/Info.plist;
|
||||
LD_RUNPATH_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
|
@ -98,26 +98,24 @@ BuildApp() {
|
||||
--ExtraFrontEndOptions="${EXTRA_FRONT_END_OPTIONS}" \
|
||||
--build-inputs="${build_inputs_path}" \
|
||||
--build-outputs="${build_outputs_path}" \
|
||||
--output="${ephemeral_dir}" \
|
||||
--output="${BUILT_PRODUCTS_DIR}" \
|
||||
"${build_mode}_macos_bundle_flutter_assets"
|
||||
}
|
||||
|
||||
# Adds the App.framework as an embedded binary and the flutter_assets as
|
||||
# resources.
|
||||
EmbedFrameworks() {
|
||||
local ephemeral_dir="${SOURCE_ROOT}/Flutter/ephemeral"
|
||||
|
||||
# Embed App.framework from Flutter into the app (after creating the Frameworks directory
|
||||
# if it doesn't already exist).
|
||||
local xcode_frameworks_dir="${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}"
|
||||
RunCommand mkdir -p -- "${xcode_frameworks_dir}"
|
||||
RunCommand rsync -av --delete --filter "- .DS_Store/" "${ephemeral_dir}/App.framework" "${xcode_frameworks_dir}"
|
||||
RunCommand rsync -av --delete --filter "- .DS_Store/" "${BUILT_PRODUCTS_DIR}/App.framework" "${xcode_frameworks_dir}"
|
||||
|
||||
# Embed the actual FlutterMacOS.framework that the Flutter app expects to run against,
|
||||
# which could be a local build or an arch/type specific build.
|
||||
|
||||
# Copy Xcode behavior and don't copy over headers or modules.
|
||||
RunCommand rsync -av --delete --filter "- .DS_Store/" --filter "- Headers/" --filter "- Modules/" "${ephemeral_dir}/FlutterMacOS.framework" "${xcode_frameworks_dir}/"
|
||||
RunCommand rsync -av --delete --filter "- .DS_Store/" --filter "- Headers/" --filter "- Modules/" "${BUILT_PRODUCTS_DIR}/FlutterMacOS.framework" "${xcode_frameworks_dir}/"
|
||||
|
||||
# Sign the binaries we moved.
|
||||
if [[ -n "${EXPANDED_CODE_SIGN_IDENTITY:-}" ]]; then
|
||||
|
@ -16,15 +16,12 @@ import 'assets.dart';
|
||||
import 'common.dart';
|
||||
import 'icon_tree_shaker.dart';
|
||||
|
||||
/// Copy the macOS framework to the correct copy dir by invoking 'cp -R'.
|
||||
/// Copy the macOS framework to the correct copy dir by invoking 'rsync'.
|
||||
///
|
||||
/// This class is abstract to share logic between the three concrete
|
||||
/// implementations. The shelling out is done to avoid complications with
|
||||
/// preserving special files (e.g., symbolic links) in the framework structure.
|
||||
///
|
||||
/// Removes any previous version of the framework that already exists in the
|
||||
/// target directory.
|
||||
///
|
||||
/// The real implementations are:
|
||||
/// * [DebugUnpackMacOS]
|
||||
/// * [ProfileUnpackMacOS]
|
||||
@ -38,14 +35,13 @@ abstract class UnpackMacOS extends Target {
|
||||
];
|
||||
|
||||
@override
|
||||
List<Source> get outputs => const <Source>[];
|
||||
List<Source> get outputs => const <Source>[
|
||||
Source.pattern('{OUTPUT_DIR}/FlutterMacOS.framework/FlutterMacOS'),
|
||||
];
|
||||
|
||||
@override
|
||||
List<Target> get dependencies => <Target>[];
|
||||
|
||||
@override
|
||||
List<String> get depfiles => const <String>['unpack_macos.d'];
|
||||
|
||||
@override
|
||||
Future<void> build(Environment environment) async {
|
||||
if (environment.defines[kBuildMode] == null) {
|
||||
@ -53,38 +49,22 @@ abstract class UnpackMacOS extends Target {
|
||||
}
|
||||
final BuildMode buildMode = getBuildModeForName(environment.defines[kBuildMode]);
|
||||
final String basePath = environment.artifacts.getArtifactPath(Artifact.flutterMacOSFramework, mode: buildMode);
|
||||
final Directory targetDirectory = environment
|
||||
.outputDir
|
||||
.childDirectory('FlutterMacOS.framework');
|
||||
// Deleting this directory is required or else the FlutterMacOS module
|
||||
// cannot be found.
|
||||
if (targetDirectory.existsSync()) {
|
||||
targetDirectory.deleteSync(recursive: true);
|
||||
}
|
||||
final List<File> inputs = environment.fileSystem.directory(basePath)
|
||||
.listSync(recursive: true)
|
||||
.whereType<File>()
|
||||
.toList();
|
||||
final List<File> outputs = inputs.map((File file) {
|
||||
final String relativePath = environment.fileSystem.path.relative(file.path, from: basePath);
|
||||
return environment.fileSystem.file(environment.fileSystem.path.join(targetDirectory.path, relativePath));
|
||||
}).toList();
|
||||
final ProcessResult result = await environment.processManager
|
||||
.run(<String>['cp', '-R', basePath, targetDirectory.path]);
|
||||
|
||||
final ProcessResult result = environment.processManager.runSync(<String>[
|
||||
'rsync',
|
||||
'-av',
|
||||
'--delete',
|
||||
'--filter',
|
||||
'- .DS_Store/',
|
||||
basePath,
|
||||
environment.outputDir.path,
|
||||
]);
|
||||
if (result.exitCode != 0) {
|
||||
throw Exception(
|
||||
'Failed to copy framework (exit ${result.exitCode}:\n'
|
||||
'${result.stdout}\n---\n${result.stderr}',
|
||||
'${result.stdout}\n---\n${result.stderr}',
|
||||
);
|
||||
}
|
||||
final DepfileService depfileService = DepfileService(
|
||||
logger: environment.logger,
|
||||
fileSystem: environment.fileSystem,
|
||||
);
|
||||
depfileService.writeToFile(
|
||||
Depfile(inputs, outputs),
|
||||
environment.buildDir.childFile('unpack_macos.d'),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -361,10 +361,6 @@
|
||||
CODE_SIGN_ENTITLEMENTS = Runner/DebugProfile.entitlements;
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
COMBINE_HIDPI_IMAGES = YES;
|
||||
FRAMEWORK_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"$(PROJECT_DIR)/Flutter/ephemeral",
|
||||
);
|
||||
INFOPLIST_FILE = Runner/Info.plist;
|
||||
LD_RUNPATH_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
@ -491,10 +487,6 @@
|
||||
CODE_SIGN_ENTITLEMENTS = Runner/DebugProfile.entitlements;
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
COMBINE_HIDPI_IMAGES = YES;
|
||||
FRAMEWORK_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"$(PROJECT_DIR)/Flutter/ephemeral",
|
||||
);
|
||||
INFOPLIST_FILE = Runner/Info.plist;
|
||||
LD_RUNPATH_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
@ -515,10 +507,6 @@
|
||||
CODE_SIGN_ENTITLEMENTS = Runner/Release.entitlements;
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
COMBINE_HIDPI_IMAGES = YES;
|
||||
FRAMEWORK_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"$(PROJECT_DIR)/Flutter/ephemeral",
|
||||
);
|
||||
INFOPLIST_FILE = Runner/Info.plist;
|
||||
LD_RUNPATH_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
|
@ -44,13 +44,17 @@ void main() {
|
||||
});
|
||||
|
||||
testUsingContext('Copies files to correct cache directory', () async {
|
||||
final Directory outputDir = fileSystem.directory('output');
|
||||
final FakeProcessManager processManager = FakeProcessManager.list(<FakeCommand>[
|
||||
const FakeCommand(
|
||||
FakeCommand(
|
||||
command: <String>[
|
||||
'cp',
|
||||
'-R',
|
||||
'rsync',
|
||||
'-av',
|
||||
'--delete',
|
||||
'--filter',
|
||||
'- .DS_Store/',
|
||||
'Artifact.flutterMacOSFramework.debug',
|
||||
'/FlutterMacOS.framework',
|
||||
outputDir.path,
|
||||
],
|
||||
),
|
||||
]);
|
||||
@ -65,19 +69,10 @@ void main() {
|
||||
processManager: processManager,
|
||||
logger: BufferLogger.test(),
|
||||
fileSystem: fileSystem,
|
||||
engineVersion: '2'
|
||||
engineVersion: '2',
|
||||
outputDir: outputDir,
|
||||
);
|
||||
|
||||
final Directory cacheDirectory = fileSystem.directory(
|
||||
artifacts.getArtifactPath(
|
||||
Artifact.flutterMacOSFramework,
|
||||
mode: BuildMode.debug,
|
||||
))
|
||||
..createSync();
|
||||
cacheDirectory.childFile('dummy').createSync();
|
||||
environment.buildDir.createSync(recursive: true);
|
||||
environment.outputDir.createSync(recursive: true);
|
||||
|
||||
await const DebugUnpackMacOS().build(environment);
|
||||
|
||||
expect(processManager.hasRemainingExpectations, false);
|
||||
|
Loading…
Reference in New Issue
Block a user