From 599dac115cf53bbfbbe0d3d9e1e80c438ce9179d Mon Sep 17 00:00:00 2001 From: Victoria Ashworth Date: Fri, 2 Feb 2024 15:05:09 -0600 Subject: [PATCH 1/5] Build macOS engine as an xcframework --- ci/builders/mac_host_engine.json | 15 +++++++++++++ shell/platform/darwin/macos/BUILD.gn | 12 +++++++++- sky/tools/create_macos_framework.py | 33 +++++++++++++++++++++++++++- 3 files changed, 58 insertions(+), 2 deletions(-) diff --git a/ci/builders/mac_host_engine.json b/ci/builders/mac_host_engine.json index e6f5ff00a5c54..8998f67ac928c 100644 --- a/ci/builders/mac_host_engine.json +++ b/ci/builders/mac_host_engine.json @@ -476,6 +476,21 @@ "source": "out/release/snapshot/gen_snapshot.zip", "destination": "darwin-x64-release/gen_snapshot.zip", "realm": "production" + }, + { + "source": "out/debug/framework/framework.zip", + "destination": "darwin-x64/framework.zip", + "realm": "production" + }, + { + "source": "out/profile/framework/framework.zip", + "destination": "darwin-x64-profile/framework.zip", + "realm": "production" + }, + { + "source": "out/release/framework/framework.zip", + "destination": "darwin-x64-release/framework.zip", + "realm": "production" } ] } diff --git a/shell/platform/darwin/macos/BUILD.gn b/shell/platform/darwin/macos/BUILD.gn index b29d51ed7f310..ed26a079ce43a 100644 --- a/shell/platform/darwin/macos/BUILD.gn +++ b/shell/platform/darwin/macos/BUILD.gn @@ -304,7 +304,17 @@ action("_generate_symlinks") { } } -group("flutter_framework") { +action("flutter_framework") { + script = "//flutter/sky/tools/create_xcframework.py" + outputs = [ "$root_out_dir/FlutterMacOS.xcframework" ] + args = [ + "--frameworks", + rebase_path("$_flutter_framework_dir"), + "--name", + "FlutterMacOS", + "--location", + rebase_path("$root_out_dir"), + ] deps = [ ":_generate_symlinks_and_verify_framework_module" ] } diff --git a/sky/tools/create_macos_framework.py b/sky/tools/create_macos_framework.py index bb78320bf29ac..fb913507e2155 100755 --- a/sky/tools/create_macos_framework.py +++ b/sky/tools/create_macos_framework.py @@ -11,6 +11,8 @@ import sys import os +from create_xcframework import create_xcframework # pylint: disable=import-error + buildroot_dir = os.path.abspath( os.path.join(os.path.realpath(__file__), '..', '..', '..', '..') ) @@ -26,7 +28,7 @@ def main(): parser = argparse.ArgumentParser( - description='Creates FlutterMacOS.framework for macOS' + description='Creates FlutterMacOS.framework and FlutterMacOS.xcframework for macOS' ) parser.add_argument('--dst', type=str, required=True) @@ -107,6 +109,10 @@ def main(): find_subprocess.wait() xargs_subprocess.wait() + # Create XCFramework from the arm64 and x64 fat framework. + xcframeworks = [fat_framework] + create_xcframework(location=dst, name='FlutterMacOS', frameworks=xcframeworks) + process_framework(dst, args, fat_framework, fat_framework_binary) return 0 @@ -223,6 +229,31 @@ def process_framework(dst, args, fat_framework, fat_framework_binary): final_dst_path = os.path.join(dst, 'FlutterMacOS.framework.zip') shutil.move(final_src_path, final_dst_path) + zip_xcframework_archive(dst) + + +def zip_xcframework_archive(dst): + filepath_with_entitlements = '' + filepath_without_entitlements = 'FlutterMacOS.xcframework/macos-arm64_x84_64/FlutterMacOS.framework.zip/Versions/A/FlutterMacOS' + embed_codesign_configuration( + os.path.join(dst, 'entitlements.txt'), filepath_with_entitlements + ) + + embed_codesign_configuration( + os.path.join(dst, 'without_entitlements.txt'), + filepath_without_entitlements + ) + + subprocess.check_call([ + 'zip', + '-r', + 'framework.zip', + 'FlutterMacOS.xcframework', + 'entitlements.txt', + 'without_entitlements.txt', + ], + cwd=dst) + if __name__ == '__main__': sys.exit(main()) From c45644d48e1799d16b9a92f7ea99cdb01846710e Mon Sep 17 00:00:00 2001 From: Victoria Ashworth Date: Fri, 2 Feb 2024 17:28:02 -0600 Subject: [PATCH 2/5] fix pylint --- sky/tools/create_macos_framework.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sky/tools/create_macos_framework.py b/sky/tools/create_macos_framework.py index fb913507e2155..d43e7e548dbfd 100755 --- a/sky/tools/create_macos_framework.py +++ b/sky/tools/create_macos_framework.py @@ -234,7 +234,10 @@ def process_framework(dst, args, fat_framework, fat_framework_binary): def zip_xcframework_archive(dst): filepath_with_entitlements = '' - filepath_without_entitlements = 'FlutterMacOS.xcframework/macos-arm64_x84_64/FlutterMacOS.framework.zip/Versions/A/FlutterMacOS' + filepath_without_entitlements = ( + 'FlutterMacOS.xcframework/macos-arm64_x84_64/' + 'FlutterMacOS.framework.zip/Versions/A/FlutterMacOS' + ) embed_codesign_configuration( os.path.join(dst, 'entitlements.txt'), filepath_with_entitlements ) From acf03c67338d403f08974c05ddea44180adb8154 Mon Sep 17 00:00:00 2001 From: Victoria Ashworth Date: Mon, 12 Feb 2024 15:27:40 -0600 Subject: [PATCH 3/5] Fix files without entitlements and zip command --- sky/tools/create_macos_framework.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sky/tools/create_macos_framework.py b/sky/tools/create_macos_framework.py index d43e7e548dbfd..a49fc9ea24fc0 100755 --- a/sky/tools/create_macos_framework.py +++ b/sky/tools/create_macos_framework.py @@ -236,7 +236,7 @@ def zip_xcframework_archive(dst): filepath_with_entitlements = '' filepath_without_entitlements = ( 'FlutterMacOS.xcframework/macos-arm64_x84_64/' - 'FlutterMacOS.framework.zip/Versions/A/FlutterMacOS' + 'FlutterMacOS.framework/Versions/A/FlutterMacOS' ) embed_codesign_configuration( os.path.join(dst, 'entitlements.txt'), filepath_with_entitlements @@ -250,6 +250,7 @@ def zip_xcframework_archive(dst): subprocess.check_call([ 'zip', '-r', + '-y', 'framework.zip', 'FlutterMacOS.xcframework', 'entitlements.txt', From 93f23b8e7d31ae8055f780a92111dddcf552ded6 Mon Sep 17 00:00:00 2001 From: Victoria Ashworth Date: Thu, 22 Feb 2024 14:48:22 -0600 Subject: [PATCH 4/5] fix formatting --- sky/tools/create_macos_framework.py | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/sky/tools/create_macos_framework.py b/sky/tools/create_macos_framework.py index 201b49ac9a84e..457a67e1cfc74 100755 --- a/sky/tools/create_macos_framework.py +++ b/sky/tools/create_macos_framework.py @@ -13,9 +13,7 @@ from create_xcframework import create_xcframework # pylint: disable=import-error -buildroot_dir = os.path.abspath( - os.path.join(os.path.realpath(__file__), '..', '..', '..', '..') -) +buildroot_dir = os.path.abspath(os.path.join(os.path.realpath(__file__), '..', '..', '..', '..')) ARCH_SUBPATH = 'mac-arm64' if platform.processor() == 'arm' else 'mac-x64' DSYMUTIL = os.path.join( @@ -221,13 +219,10 @@ def zip_xcframework_archive(dst): 'FlutterMacOS.xcframework/macos-arm64_x84_64/' 'FlutterMacOS.framework/Versions/A/FlutterMacOS' ) - embed_codesign_configuration( - os.path.join(dst, 'entitlements.txt'), filepath_with_entitlements - ) + embed_codesign_configuration(os.path.join(dst, 'entitlements.txt'), filepath_with_entitlements) embed_codesign_configuration( - os.path.join(dst, 'without_entitlements.txt'), - filepath_without_entitlements + os.path.join(dst, 'without_entitlements.txt'), filepath_without_entitlements ) subprocess.check_call([ From 5313437d094787db61a069f29ea3806f2accb24c Mon Sep 17 00:00:00 2001 From: Victoria Ashworth Date: Thu, 22 Feb 2024 14:52:23 -0600 Subject: [PATCH 5/5] fix nits --- shell/platform/darwin/macos/BUILD.gn | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/shell/platform/darwin/macos/BUILD.gn b/shell/platform/darwin/macos/BUILD.gn index ed26a079ce43a..aae1e5138ccc6 100644 --- a/shell/platform/darwin/macos/BUILD.gn +++ b/shell/platform/darwin/macos/BUILD.gn @@ -309,11 +309,11 @@ action("flutter_framework") { outputs = [ "$root_out_dir/FlutterMacOS.xcframework" ] args = [ "--frameworks", - rebase_path("$_flutter_framework_dir"), + rebase_path(_flutter_framework_dir), "--name", "FlutterMacOS", "--location", - rebase_path("$root_out_dir"), + rebase_path(root_out_dir), ] deps = [ ":_generate_symlinks_and_verify_framework_module" ] }