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 { ...@@ -80,6 +80,9 @@ Future<void> main() async {
'Frameworks', 'Frameworks',
'Flutter.framework', 'Flutter.framework',
)); ));
checkDirectoryNotExists(path.join(outputFlutterFramework.path, 'Headers'));
checkDirectoryNotExists(path.join(outputFlutterFramework.path, 'Modules'));
final File outputFlutterFrameworkBinary = File(path.join( final File outputFlutterFrameworkBinary = File(path.join(
outputFlutterFramework.path, outputFlutterFramework.path,
'Flutter', 'Flutter',
......
...@@ -109,13 +109,13 @@ EmbedFrameworks() { ...@@ -109,13 +109,13 @@ EmbedFrameworks() {
# if it doesn't already exist). # if it doesn't already exist).
local xcode_frameworks_dir="${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" local xcode_frameworks_dir="${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}"
RunCommand mkdir -p -- "${xcode_frameworks_dir}" 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, # 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. # which could be a local build or an arch/type specific build.
# Copy Xcode behavior and don't copy over headers or modules. # 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. # Sign the binaries we moved.
if [[ -n "${EXPANDED_CODE_SIGN_IDENTITY:-}" ]]; then if [[ -n "${EXPANDED_CODE_SIGN_IDENTITY:-}" ]]; then
......
...@@ -279,13 +279,13 @@ EmbedFlutterFrameworks() { ...@@ -279,13 +279,13 @@ EmbedFlutterFrameworks() {
# if it doesn't already exist). # if it doesn't already exist).
local xcode_frameworks_dir="${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" local xcode_frameworks_dir="${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}"
RunCommand mkdir -p -- "${xcode_frameworks_dir}" 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, # 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. # which could be a local build or an arch/type specific build.
# Copy Xcode behavior and don't copy over headers or modules. # 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 if [[ "$ACTION" != "install" || "$ENABLE_BITCODE" == "NO" ]]; then
# Strip bitcode from the destination unless archiving, or if bitcode is disabled entirely. # 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" 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() { ...@@ -78,19 +78,39 @@ void main() {
expect(vmSnapshot.existsSync(), buildMode == 'Debug'); expect(vmSnapshot.existsSync(), buildMode == 'Debug');
final File outputFlutterFrameworkBinary = final Directory outputFlutterFramework = fileSystem.directory(
fileSystem.file(fileSystem.path.join( fileSystem.path.join(
outputApp.path, outputApp.path,
'Contents', 'Contents',
'Frameworks', 'Frameworks',
'FlutterMacOS.framework', 'FlutterMacOS.framework',
'FlutterMacOS', ),
)); );
expect(outputFlutterFrameworkBinary, exists);
// 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. // Archiving should contain a bitcode blob, but not building.
// This mimics Xcode behavior and present a developer from having to install a // This mimics Xcode behavior and present a developer from having to install a
// 300+MB app. // 300+MB app.
final File outputFlutterFrameworkBinary = outputFlutterFramework
.childDirectory('Versions')
.childDirectory('A')
.childFile('FlutterMacOS');
expect( expect(
await containsBitcode(outputFlutterFrameworkBinary.path), await containsBitcode(outputFlutterFrameworkBinary.path),
isFalse, 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