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

Commit 079c5ec

Browse files
authored
macOS: Make framework creation consistent with iOS (#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: flutter/flutter#153879 [C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
1 parent 786fb12 commit 079c5ec

File tree

3 files changed

+34
-28
lines changed

3 files changed

+34
-28
lines changed

sky/tools/create_ios_framework.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ def main():
3434
args = parser.parse_args()
3535

3636
dst = (args.dst if os.path.isabs(args.dst) else sky_utils.buildroot_relative_path(args.dst))
37-
3837
arm64_out_dir = (
3938
args.arm64_out_dir if os.path.isabs(args.arm64_out_dir) else
4039
sky_utils.buildroot_relative_path(args.arm64_out_dir)

sky/tools/create_macos_framework.py

Lines changed: 15 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,12 @@ def main():
2828
args = parser.parse_args()
2929

3030
dst = args.dst if os.path.isabs(args.dst) else sky_utils.buildroot_relative_path(args.dst)
31+
3132
arm64_out_dir = (
3233
args.arm64_out_dir if os.path.isabs(args.arm64_out_dir) else
3334
sky_utils.buildroot_relative_path(args.arm64_out_dir)
3435
)
36+
3537
x64_out_dir = (
3638
args.x64_out_dir
3739
if os.path.isabs(args.x64_out_dir) else sky_utils.buildroot_relative_path(args.x64_out_dir)
@@ -58,8 +60,7 @@ def main():
5860
return 1
5961

6062
fat_framework = os.path.join(dst, 'FlutterMacOS.framework')
61-
sky_utils.create_fat_macos_framework(fat_framework, arm64_framework, x64_framework)
62-
process_framework(dst, args, fat_framework)
63+
sky_utils.create_fat_macos_framework(args, dst, fat_framework, arm64_framework, x64_framework)
6364

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

7374

74-
def process_framework(dst, args, framework_path):
75-
framework_binary = sky_utils.get_mac_framework_dylib_path(framework_path)
76-
77-
if args.dsym:
78-
dsym_out = os.path.join(dst, 'FlutterMacOS.dSYM')
79-
sky_utils.extract_dsym(framework_binary, dsym_out)
80-
if args.zip:
81-
dsym_dst = os.path.join(dst, 'FlutterMacOS.dSYM')
82-
sky_utils.create_zip(dsym_dst, 'FlutterMacOS.dSYM.zip', ['.'])
83-
# Create a zip of just the contents of the dSYM, then create a zip of that zip.
84-
# TODO(fujino): remove this once https://github.com/flutter/flutter/issues/125067 is resolved
85-
sky_utils.create_zip(dsym_dst, 'FlutterMacOS.dSYM_.zip', ['FlutterMacOS.dSYM.zip'])
86-
87-
# Overwrite the FlutterMacOS.dSYM.zip with the double-zipped archive.
88-
dsym_final_src_path = os.path.join(dsym_dst, 'FlutterMacOS.dSYM_.zip')
89-
dsym_final_dst_path = os.path.join(dst, 'FlutterMacOS.dSYM.zip')
90-
shutil.move(dsym_final_src_path, dsym_final_dst_path)
91-
92-
if args.strip:
93-
unstripped_out = os.path.join(dst, 'FlutterMacOS.unstripped')
94-
sky_utils.strip_binary(framework_binary, unstripped_out)
95-
96-
9775
def zip_framework(dst):
9876
framework_dst = os.path.join(dst, 'FlutterMacOS.framework')
9977
sky_utils.write_codesign_config(os.path.join(framework_dst, 'entitlements.txt'), [])
@@ -126,6 +104,18 @@ def zip_framework(dst):
126104

127105
zip_xcframework_archive(dst)
128106

107+
dsym_dst = os.path.join(dst, 'FlutterMacOS.dSYM')
108+
if os.path.exists(dsym_dst):
109+
# Create a zip of just the contents of the dSYM, then create a zip of that zip.
110+
# TODO(cbracken): remove this once https://github.com/flutter/flutter/issues/125067 is resolved
111+
sky_utils.create_zip(dsym_dst, 'FlutterMacOS.dSYM.zip', ['.'])
112+
sky_utils.create_zip(dsym_dst, 'FlutterMacOS.dSYM_.zip', ['FlutterMacOS.dSYM.zip'])
113+
114+
# Move the double-zipped FlutterMacOS.dSYM.zip to dst.
115+
dsym_final_src_path = os.path.join(dsym_dst, 'FlutterMacOS.dSYM_.zip')
116+
dsym_final_dst_path = os.path.join(dst, 'FlutterMacOS.dSYM.zip')
117+
shutil.move(dsym_final_src_path, dsym_final_dst_path)
118+
129119

130120
def zip_xcframework_archive(dst):
131121
sky_utils.write_codesign_config(os.path.join(dst, 'entitlements.txt'), [])

sky/tools/sky_utils.py

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,15 +118,23 @@ def copy_tree(source_path, destination_path, symlinks=False):
118118
shutil.copytree(source_path, destination_path, symlinks=symlinks)
119119

120120

121-
def create_fat_macos_framework(fat_framework, arm64_framework, x64_framework):
121+
def create_fat_macos_framework(args, dst, fat_framework, arm64_framework, x64_framework):
122122
"""Creates a fat framework from two arm64 and x64 frameworks."""
123123
# Clone the arm64 framework bundle as a starting point.
124124
copy_tree(arm64_framework, fat_framework, symlinks=True)
125125
_regenerate_symlinks(fat_framework)
126+
framework_dylib = get_mac_framework_dylib_path(fat_framework)
126127
lipo([get_mac_framework_dylib_path(arm64_framework),
127-
get_mac_framework_dylib_path(x64_framework)], get_mac_framework_dylib_path(fat_framework))
128+
get_mac_framework_dylib_path(x64_framework)], framework_dylib)
128129
_set_framework_permissions(fat_framework)
129130

131+
# Compute dsym output path, if enabled.
132+
framework_dsym = None
133+
if args.dsym:
134+
framework_dsym = os.path.join(dst, get_framework_name(fat_framework) + '.dSYM')
135+
136+
_process_macos_framework(args, dst, framework_dylib, framework_dsym)
137+
130138

131139
def _regenerate_symlinks(framework_dir):
132140
"""Regenerates the framework symlink structure.
@@ -182,6 +190,15 @@ def _set_framework_permissions(framework_dir):
182190
xargs_subprocess.wait()
183191

184192

193+
def _process_macos_framework(args, dst, framework_dylib, dsym):
194+
if dsym:
195+
extract_dsym(framework_dylib, dsym)
196+
197+
if args.strip:
198+
unstripped_out = os.path.join(dst, 'FlutterMacOS.unstripped')
199+
strip_binary(framework_dylib, unstripped_out)
200+
201+
185202
def create_zip(cwd, zip_filename, paths):
186203
"""Creates a zip archive in cwd, containing a set of cwd-relative files.
187204

0 commit comments

Comments
 (0)