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 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
1 change: 0 additions & 1 deletion sky/tools/create_ios_framework.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ def main():
args = parser.parse_args()

dst = (args.dst if os.path.isabs(args.dst) else sky_utils.buildroot_relative_path(args.dst))

arm64_out_dir = (
args.arm64_out_dir if os.path.isabs(args.arm64_out_dir) else
sky_utils.buildroot_relative_path(args.arm64_out_dir)
Expand Down
40 changes: 15 additions & 25 deletions sky/tools/create_macos_framework.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,12 @@ def main():
args = parser.parse_args()

dst = args.dst if os.path.isabs(args.dst) else sky_utils.buildroot_relative_path(args.dst)

arm64_out_dir = (
args.arm64_out_dir if os.path.isabs(args.arm64_out_dir) else
sky_utils.buildroot_relative_path(args.arm64_out_dir)
)

x64_out_dir = (
args.x64_out_dir
if os.path.isabs(args.x64_out_dir) else sky_utils.buildroot_relative_path(args.x64_out_dir)
Expand All @@ -58,8 +60,7 @@ def main():
return 1

fat_framework = os.path.join(dst, 'FlutterMacOS.framework')
sky_utils.create_fat_macos_framework(fat_framework, arm64_framework, x64_framework)
process_framework(dst, args, fat_framework)
sky_utils.create_fat_macos_framework(args, dst, fat_framework, arm64_framework, x64_framework)

# Create XCFramework from the arm64 and x64 fat framework.
xcframeworks = [fat_framework]
Expand All @@ -71,29 +72,6 @@ def main():
return 0


def process_framework(dst, args, framework_path):
framework_binary = sky_utils.get_mac_framework_dylib_path(framework_path)

if args.dsym:
dsym_out = os.path.join(dst, 'FlutterMacOS.dSYM')
sky_utils.extract_dsym(framework_binary, dsym_out)
if args.zip:
dsym_dst = os.path.join(dst, 'FlutterMacOS.dSYM')
sky_utils.create_zip(dsym_dst, 'FlutterMacOS.dSYM.zip', ['.'])
# Create a zip of just the contents of the dSYM, then create a zip of that zip.
# TODO(fujino): remove this once https://github.com/flutter/flutter/issues/125067 is resolved
sky_utils.create_zip(dsym_dst, 'FlutterMacOS.dSYM_.zip', ['FlutterMacOS.dSYM.zip'])

# Overwrite the FlutterMacOS.dSYM.zip with the double-zipped archive.
dsym_final_src_path = os.path.join(dsym_dst, 'FlutterMacOS.dSYM_.zip')
dsym_final_dst_path = os.path.join(dst, 'FlutterMacOS.dSYM.zip')
shutil.move(dsym_final_src_path, dsym_final_dst_path)

if args.strip:
unstripped_out = os.path.join(dst, 'FlutterMacOS.unstripped')
sky_utils.strip_binary(framework_binary, unstripped_out)


def zip_framework(dst):
framework_dst = os.path.join(dst, 'FlutterMacOS.framework')
sky_utils.write_codesign_config(os.path.join(framework_dst, 'entitlements.txt'), [])
Expand Down Expand Up @@ -126,6 +104,18 @@ def zip_framework(dst):

zip_xcframework_archive(dst)

dsym_dst = os.path.join(dst, 'FlutterMacOS.dSYM')
if os.path.exists(dsym_dst):
# Create a zip of just the contents of the dSYM, then create a zip of that zip.
# TODO(cbracken): remove this once https://github.com/flutter/flutter/issues/125067 is resolved
sky_utils.create_zip(dsym_dst, 'FlutterMacOS.dSYM.zip', ['.'])
sky_utils.create_zip(dsym_dst, 'FlutterMacOS.dSYM_.zip', ['FlutterMacOS.dSYM.zip'])

# Move the double-zipped FlutterMacOS.dSYM.zip to dst.
dsym_final_src_path = os.path.join(dsym_dst, 'FlutterMacOS.dSYM_.zip')
dsym_final_dst_path = os.path.join(dst, 'FlutterMacOS.dSYM.zip')
shutil.move(dsym_final_src_path, dsym_final_dst_path)


def zip_xcframework_archive(dst):
sky_utils.write_codesign_config(os.path.join(dst, 'entitlements.txt'), [])
Expand Down
21 changes: 19 additions & 2 deletions sky/tools/sky_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,15 +118,23 @@ def copy_tree(source_path, destination_path, symlinks=False):
shutil.copytree(source_path, destination_path, symlinks=symlinks)


def create_fat_macos_framework(fat_framework, arm64_framework, x64_framework):
def create_fat_macos_framework(args, dst, fat_framework, arm64_framework, x64_framework):
"""Creates a fat framework from two arm64 and x64 frameworks."""
# Clone the arm64 framework bundle as a starting point.
copy_tree(arm64_framework, fat_framework, symlinks=True)
_regenerate_symlinks(fat_framework)
framework_dylib = get_mac_framework_dylib_path(fat_framework)
lipo([get_mac_framework_dylib_path(arm64_framework),
get_mac_framework_dylib_path(x64_framework)], get_mac_framework_dylib_path(fat_framework))
get_mac_framework_dylib_path(x64_framework)], framework_dylib)
_set_framework_permissions(fat_framework)

# Compute dsym output path, if enabled.
framework_dsym = None
if args.dsym:
framework_dsym = os.path.join(dst, get_framework_name(fat_framework) + '.dSYM')
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright -- it's over here.


_process_macos_framework(args, dst, framework_dylib, framework_dsym)


def _regenerate_symlinks(framework_dir):
"""Regenerates the framework symlink structure.
Expand Down Expand Up @@ -182,6 +190,15 @@ def _set_framework_permissions(framework_dir):
xargs_subprocess.wait()


def _process_macos_framework(args, dst, framework_dylib, dsym):
if dsym:
extract_dsym(framework_dylib, dsym)

if args.strip:
unstripped_out = os.path.join(dst, 'FlutterMacOS.unstripped')
strip_binary(framework_dylib, unstripped_out)


def create_zip(cwd, zip_filename, paths):
"""Creates a zip archive in cwd, containing a set of cwd-relative files.

Expand Down