Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
Build macOS engine as an xcframework
  • Loading branch information
vashworth committed Feb 2, 2024
commit 599dac115cf53bbfbbe0d3d9e1e80c438ce9179d
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
33 changes: 32 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__), '..', '..', '..', '..')
)
Expand All @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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())