Unverified Commit f08b1ae6 authored by Jenn Magder's avatar Jenn Magder Committed by GitHub

Avoid broken symlinks in embedded Flutter frameworks (#73052)

parent 36373f8d
......@@ -80,6 +80,9 @@ Future<void> main() async {
'Frameworks',
'Flutter.framework',
));
checkDirectoryNotExists(path.join(outputFlutterFramework.path, 'Headers'));
checkDirectoryNotExists(path.join(outputFlutterFramework.path, 'Modules'));
final File outputFlutterFrameworkBinary = File(path.join(
outputFlutterFramework.path,
'Flutter',
......
......@@ -109,13 +109,13 @@ EmbedFrameworks() {
# 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/" "${BUILT_PRODUCTS_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/" "${BUILT_PRODUCTS_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
......
......@@ -279,13 +279,13 @@ EmbedFlutterFrameworks() {
# 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/" "${BUILT_PRODUCTS_DIR}/App.framework" "${xcode_frameworks_dir}"
RunCommand rsync -av --delete --filter "- .DS_Store" "${BUILT_PRODUCTS_DIR}/App.framework" "${xcode_frameworks_dir}"
# Embed the actual Flutter.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/" "${BUILT_PRODUCTS_DIR}/Flutter.framework" "${xcode_frameworks_dir}/"
RunCommand rsync -av --delete --filter "- .DS_Store" --filter "- Headers" --filter "- Modules" "${BUILT_PRODUCTS_DIR}/Flutter.framework" "${xcode_frameworks_dir}/"
if [[ "$ACTION" != "install" || "$ENABLE_BITCODE" == "NO" ]]; then
# Strip bitcode from the destination unless archiving, or if bitcode is disabled entirely.
RunCommand "${DT_TOOLCHAIN_DIR}"/usr/bin/bitcode_strip "${BUILT_PRODUCTS_DIR}/Flutter.framework/Flutter" -r -o "${xcode_frameworks_dir}/Flutter.framework/Flutter"
......
......@@ -78,19 +78,39 @@ void main() {
expect(vmSnapshot.existsSync(), buildMode == 'Debug');
final File outputFlutterFrameworkBinary =
fileSystem.file(fileSystem.path.join(
outputApp.path,
'Contents',
'Frameworks',
'FlutterMacOS.framework',
'FlutterMacOS',
));
expect(outputFlutterFrameworkBinary, exists);
final Directory outputFlutterFramework = fileSystem.directory(
fileSystem.path.join(
outputApp.path,
'Contents',
'Frameworks',
'FlutterMacOS.framework',
),
);
// Check complicated macOS framework symlink structure.
final Link current = outputFlutterFramework.childDirectory('Versions').childLink('Current');
expect(current.targetSync(), 'A');
expect(outputFlutterFramework.childLink('FlutterMacOS').targetSync(),
fileSystem.path.join('Versions', 'Current', 'FlutterMacOS'));
expect(outputFlutterFramework.childLink('Resources'), exists);
expect(outputFlutterFramework.childLink('Resources').targetSync(),
fileSystem.path.join('Versions', 'Current', 'Resources'));
expect(outputFlutterFramework.childLink('Headers'), isNot(exists));
expect(outputFlutterFramework.childDirectory('Headers'), isNot(exists));
expect(outputFlutterFramework.childLink('Modules'), isNot(exists));
expect(outputFlutterFramework.childDirectory('Modules'), isNot(exists));
// Archiving should contain a bitcode blob, but not building.
// This mimics Xcode behavior and present a developer from having to install a
// 300+MB app.
final File outputFlutterFrameworkBinary = outputFlutterFramework
.childDirectory('Versions')
.childDirectory('A')
.childFile('FlutterMacOS');
expect(
await containsBitcode(outputFlutterFrameworkBinary.path),
isFalse,
......
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