@@ -64,15 +64,22 @@ def main():
6464
6565 # Create XCFramework from the arm64 and x64 fat framework.
6666 xcframeworks = [fat_framework ]
67- create_xcframework (location = dst , name = 'FlutterMacOS' , frameworks = xcframeworks )
67+ dsyms = [fat_framework + '.dSYM' ] if args .dsym else None
68+ create_xcframework (location = dst , name = 'FlutterMacOS' , frameworks = xcframeworks , dsyms = dsyms )
6869
6970 if args .zip :
70- zip_framework (dst )
71+ zip_framework (dst , args )
7172
7273 return 0
7374
7475
75- def zip_framework (dst ):
76+ def zip_framework (dst , args ):
77+ # pylint: disable=line-too-long
78+ # When updating with_entitlements and without_entitlements,
79+ # `binariesWithoutEntitlements` and `signedXcframeworks` should be updated in
80+ # the framework's `verifyCodeSignedTestRunner`.
81+ #
82+ # See: https://github.com/flutter/flutter/blob/62382c7b83a16b3f48dc06c19a47f6b8667005a5/dev/bots/suite_runners/run_verify_binaries_codesigned_tests.dart#L82-L130
7683 framework_dst = os .path .join (dst , 'FlutterMacOS.framework' )
7784 sky_utils .write_codesign_config (os .path .join (framework_dst , 'entitlements.txt' ), [])
7885 sky_utils .write_codesign_config (
@@ -83,6 +90,7 @@ def zip_framework(dst):
8390 ]
8491 )
8592 sky_utils .create_zip (framework_dst , 'FlutterMacOS.framework.zip' , ['.' ])
93+ # pylint: enable=line-too-long
8694
8795 # Double zip to make it consistent with legacy artifacts.
8896 # TODO(fujino): remove this once https://github.com/flutter/flutter/issues/125067 is resolved
@@ -102,40 +110,63 @@ def zip_framework(dst):
102110 final_dst_path = os .path .join (dst , 'FlutterMacOS.framework.zip' )
103111 shutil .move (final_src_path , final_dst_path )
104112
105- zip_xcframework_archive (dst )
113+ zip_xcframework_archive (dst , args )
114+
115+ # Generate Flutter.dSYM.zip for manual symbolification.
116+ #
117+ # Historically, the framework dSYM was named FlutterMacOS.dSYM, so in order
118+ # to remain backward-compatible with existing instructions in docs/Crashes.md
119+ # and existing tooling such as dart-lang/dart_ci, we rename back to that name
120+ #
121+ # TODO(cbracken): remove these archives and the upload steps once we bundle
122+ # dSYMs in app archives. https://github.com/flutter/flutter/issues/153879
123+ framework_dsym = framework_dst + '.dSYM'
124+ if os .path .exists (framework_dsym ):
125+ renamed_dsym = framework_dsym .replace ('FlutterMacOS.framework.dSYM' , 'FlutterMacOS.dSYM' )
126+ os .rename (framework_dsym , renamed_dsym )
106127
107- dsym_dst = os .path .join (dst , 'FlutterMacOS.dSYM' )
108- if os .path .exists (dsym_dst ):
109128 # Create a zip of just the contents of the dSYM, then create a zip of that zip.
110129 # 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' ])
130+ sky_utils .create_zip (renamed_dsym , 'FlutterMacOS.dSYM.zip' , ['.' ])
131+ sky_utils .create_zip (renamed_dsym , 'FlutterMacOS.dSYM_.zip' , ['FlutterMacOS.dSYM.zip' ])
113132
114133 # Move the double-zipped FlutterMacOS.dSYM.zip to dst.
115- dsym_final_src_path = os .path .join (dsym_dst , 'FlutterMacOS.dSYM_.zip' )
134+ dsym_final_src_path = os .path .join (renamed_dsym , 'FlutterMacOS.dSYM_.zip' )
116135 dsym_final_dst_path = os .path .join (dst , 'FlutterMacOS.dSYM.zip' )
117136 shutil .move (dsym_final_src_path , dsym_final_dst_path )
118137
119138
120- def zip_xcframework_archive (dst ):
121- sky_utils .write_codesign_config (os .path .join (dst , 'entitlements.txt' ), [])
122-
123- sky_utils .write_codesign_config (
124- os .path .join (dst , 'without_entitlements.txt' ), [
125- 'FlutterMacOS.xcframework/macos-arm64_x86_64/'
126- 'FlutterMacOS.framework/Versions/A/FlutterMacOS'
127- ]
128- )
129-
130- sky_utils .create_zip (
131- dst ,
132- 'framework.zip' ,
133- [
134- 'FlutterMacOS.xcframework' ,
135- 'entitlements.txt' ,
136- 'without_entitlements.txt' ,
137- ],
138- )
139+ def zip_xcframework_archive (dst , args ):
140+ # pylint: disable=line-too-long
141+
142+ # When updating with_entitlements and without_entitlements,
143+ # `binariesWithoutEntitlements` and `signedXcframeworks` should be updated in
144+ # the framework's `verifyCodeSignedTestRunner`.
145+ #
146+ # See: https://github.com/flutter/flutter/blob/62382c7b83a16b3f48dc06c19a47f6b8667005a5/dev/bots/suite_runners/run_verify_binaries_codesigned_tests.dart#L82-L130
147+ with_entitlements = []
148+ with_entitlements_file = os .path .join (dst , 'entitlements.txt' )
149+ sky_utils .write_codesign_config (with_entitlements_file , with_entitlements )
150+
151+ without_entitlements = [
152+ 'FlutterMacOS.xcframework/macos-arm64_x86_64/FlutterMacOS.framework/Versions/A/FlutterMacOS' ,
153+ ]
154+ if args .dsym :
155+ without_entitlements .extend ([
156+ 'FlutterMacOS.xcframework/macos-arm64_x86_64/dSYMs/FlutterMacOS.framework.dSYM/Contents/Resources/DWARF/FlutterMacOS' ,
157+ ])
158+
159+ without_entitlements_file = os .path .join (dst , 'without_entitlements.txt' )
160+ sky_utils .write_codesign_config (without_entitlements_file , without_entitlements )
161+ # pylint: enable=line-too-long
162+
163+ zip_contents = [
164+ 'FlutterMacOS.xcframework' ,
165+ 'entitlements.txt' ,
166+ 'without_entitlements.txt' ,
167+ ]
168+ sky_utils .assert_valid_codesign_config (dst , zip_contents , with_entitlements , without_entitlements )
169+ sky_utils .create_zip (dst , 'framework.zip' , zip_contents )
139170
140171
141172if __name__ == '__main__' :
0 commit comments