Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Build macOS engine as an xcframework #50300

Merged
merged 6 commits into from
Feb 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions ci/builders/mac_host_engine.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
]
}
12 changes: 11 additions & 1 deletion shell/platform/darwin/macos/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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" ]
}

Expand Down
36 changes: 35 additions & 1 deletion sky/tools/create_macos_framework.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__), '..', '..', '..', '..'))

ARCH_SUBPATH = 'mac-arm64' if platform.processor() == 'arm' else 'mac-x64'
Expand All @@ -23,7 +25,9 @@


def main():
parser = argparse.ArgumentParser(description='Creates FlutterMacOS.framework for macOS')
parser = argparse.ArgumentParser(
description='Creates FlutterMacOS.framework and FlutterMacOS.xcframework for macOS'
)

parser.add_argument('--dst', type=str, required=True)
parser.add_argument('--arm64-out-dir', type=str, required=True)
Expand Down Expand Up @@ -96,6 +100,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
Expand Down Expand Up @@ -202,6 +210,32 @@ 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/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',
'-y',
'framework.zip',
'FlutterMacOS.xcframework',
'entitlements.txt',
'without_entitlements.txt',
],
cwd=dst)


if __name__ == '__main__':
sys.exit(main())