mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
macOS: Make framework creation consistent with iOS (flutter/engine#54685)
Separates dSYM creation from archiving, consistent with iOS tooling. This introduces no semantic changes, but simply adjusts `create_fat_macos_framework` and `process_framework` for consistency with the equivalent iOS tooling in `create_ios_framework.py`. Related issue: https://github.com/flutter/flutter/issues/153879 [C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
This commit is contained in:
parent
c571a9aeb7
commit
1e7584e7a2
@ -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)
|
||||
|
||||
@ -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)
|
||||
@ -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]
|
||||
@ -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'), [])
|
||||
@ -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'), [])
|
||||
|
||||
@ -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')
|
||||
|
||||
_process_macos_framework(args, dst, framework_dylib, framework_dsym)
|
||||
|
||||
|
||||
def _regenerate_symlinks(framework_dir):
|
||||
"""Regenerates the framework symlink structure.
|
||||
@ -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.
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user