14from create_xcframework
import create_xcframework
16buildroot_dir = os.path.abspath(os.path.join(os.path.realpath(__file__),
'..',
'..',
'..',
'..'))
18ARCH_SUBPATH =
'mac-arm64' if platform.processor() ==
'arm' else 'mac-x64'
19DSYMUTIL = os.path.join(
20 os.path.dirname(__file__),
'..',
'..',
'buildtools', ARCH_SUBPATH,
'clang',
'bin',
'dsymutil'
23out_dir = os.path.join(buildroot_dir,
'out')
27 parser = argparse.ArgumentParser(
28 description=
'Creates FlutterMacOS.framework and FlutterMacOS.xcframework for macOS'
31 parser.add_argument(
'--dst', type=str, required=
True)
32 parser.add_argument(
'--arm64-out-dir', type=str, required=
True)
33 parser.add_argument(
'--x64-out-dir', type=str, required=
True)
34 parser.add_argument(
'--strip', action=
'store_true', default=
False)
35 parser.add_argument(
'--dsym', action=
'store_true', default=
False)
37 parser.add_argument(
'--zip', action=
'store_true', default=
False)
39 args = parser.parse_args()
41 dst = (args.dst
if os.path.isabs(args.dst)
else os.path.join(buildroot_dir, args.dst))
44 if os.path.isabs(args.arm64_out_dir)
else os.path.join(buildroot_dir, args.arm64_out_dir)
48 if os.path.isabs(args.x64_out_dir)
else os.path.join(buildroot_dir, args.x64_out_dir)
51 fat_framework_bundle = os.path.join(dst,
'FlutterMacOS.framework')
52 arm64_framework = os.path.join(arm64_out_dir,
'FlutterMacOS.framework')
53 x64_framework = os.path.join(x64_out_dir,
'FlutterMacOS.framework')
55 arm64_dylib = os.path.join(arm64_framework,
'FlutterMacOS')
56 x64_dylib = os.path.join(x64_framework,
'FlutterMacOS')
58 if not os.path.isdir(arm64_framework):
59 print(
'Cannot find macOS arm64 Framework at %s' % arm64_framework)
62 if not os.path.isdir(x64_framework):
63 print(
'Cannot find macOS x64 Framework at %s' % x64_framework)
66 if not os.path.isfile(arm64_dylib):
67 print(
'Cannot find macOS arm64 dylib at %s' % arm64_dylib)
70 if not os.path.isfile(x64_dylib):
71 print(
'Cannot find macOS x64 dylib at %s' % x64_dylib)
74 if not os.path.isfile(DSYMUTIL):
75 print(
'Cannot find dsymutil at %s' % DSYMUTIL)
78 shutil.rmtree(fat_framework_bundle,
True)
79 shutil.copytree(arm64_framework, fat_framework_bundle, symlinks=
True)
83 fat_framework_binary = os.path.join(fat_framework_bundle,
'Versions',
'A',
'FlutterMacOS')
86 subprocess.check_call([
87 'lipo', arm64_dylib, x64_dylib,
'-create',
'-output', fat_framework_binary
90 subprocess.check_call([
'chmod',
'755', fat_framework_bundle])
93 versions_path = os.path.join(fat_framework_bundle,
'Versions')
94 subprocess.check_call([
'chmod',
'-R',
'og+r', versions_path])
96 find_subprocess = subprocess.Popen([
'find', versions_path,
'-perm',
'-100',
'-print0'],
97 stdout=subprocess.PIPE)
99 xargs_subprocess = subprocess.Popen([
'xargs',
'-0',
'chmod',
'og+x'],
100 stdin=find_subprocess.stdout)
101 find_subprocess.wait()
102 xargs_subprocess.wait()
107 xcframeworks = [fat_framework_bundle]
116 """Regenerates the symlinks structure.
118 Recipes V2 upload artifacts in CAS before integration
and CAS follows symlinks.
119 This logic regenerates the symlinks
in the expected structure.
121 if os.path.islink(os.path.join(fat_framework_bundle,
'FlutterMacOS')):
123 os.remove(os.path.join(fat_framework_bundle,
'FlutterMacOS'))
124 shutil.rmtree(os.path.join(fat_framework_bundle,
'Headers'),
True)
125 shutil.rmtree(os.path.join(fat_framework_bundle,
'Modules'),
True)
126 shutil.rmtree(os.path.join(fat_framework_bundle,
'Resources'),
True)
127 current_version_path = os.path.join(fat_framework_bundle,
'Versions',
'Current')
128 shutil.rmtree(current_version_path,
True)
129 os.symlink(
'A', current_version_path)
131 os.path.join(
'Versions',
'Current',
'FlutterMacOS'),
132 os.path.join(fat_framework_bundle,
'FlutterMacOS')
135 os.path.join(
'Versions',
'Current',
'Headers'), os.path.join(fat_framework_bundle,
'Headers')
138 os.path.join(
'Versions',
'Current',
'Modules'), os.path.join(fat_framework_bundle,
'Modules')
141 os.path.join(
'Versions',
'Current',
'Resources'),
142 os.path.join(fat_framework_bundle,
'Resources')
147 with open(config_path,
'w')
as file:
153 dsym_out = os.path.splitext(fat_framework_bundle)[0] +
'.dSYM'
154 subprocess.check_call([DSYMUTIL,
'-o', dsym_out, fat_framework_binary])
156 dsym_dst = os.path.join(dst,
'FlutterMacOS.dSYM')
157 subprocess.check_call([
'zip',
'-r',
'-y',
'FlutterMacOS.dSYM.zip',
'.'], cwd=dsym_dst)
160 subprocess.check_call([
163 'FlutterMacOS.dSYM_.zip',
164 'FlutterMacOS.dSYM.zip',
168 dsym_final_src_path = os.path.join(dsym_dst,
'FlutterMacOS.dSYM_.zip')
169 dsym_final_dst_path = os.path.join(dst,
'FlutterMacOS.dSYM.zip')
170 shutil.move(dsym_final_src_path, dsym_final_dst_path)
174 unstripped_out = os.path.join(dst,
'FlutterMacOS.unstripped')
175 shutil.copyfile(fat_framework_binary, unstripped_out)
177 subprocess.check_call([
'strip',
'-x',
'-S', fat_framework_binary])
183 filepath_with_entitlements =
''
185 framework_dst = os.path.join(dst,
'FlutterMacOS.framework')
187 filepath_without_entitlements =
'FlutterMacOS.framework.zip/Versions/A/FlutterMacOS'
190 os.path.join(framework_dst,
'entitlements.txt'), filepath_with_entitlements
194 os.path.join(framework_dst,
'without_entitlements.txt'), filepath_without_entitlements
196 subprocess.check_call([
200 'FlutterMacOS.framework.zip',
206 subprocess.check_call(
210 'FlutterMacOS.framework_.zip',
211 'FlutterMacOS.framework.zip',
214 'without_entitlements.txt',
219 final_src_path = os.path.join(framework_dst,
'FlutterMacOS.framework_.zip')
220 final_dst_path = os.path.join(dst,
'FlutterMacOS.framework.zip')
221 shutil.move(final_src_path, final_dst_path)
227 filepath_with_entitlements =
''
228 filepath_without_entitlements = (
229 'FlutterMacOS.xcframework/macos-arm64_x86_64/'
230 'FlutterMacOS.framework/Versions/A/FlutterMacOS'
235 os.path.join(dst,
'without_entitlements.txt'), filepath_without_entitlements
238 subprocess.check_call([
243 'FlutterMacOS.xcframework',
245 'without_entitlements.txt',
250if __name__ ==
'__main__':
def embed_codesign_configuration(config_path, content)
def process_framework(dst, args, fat_framework_bundle, fat_framework_binary)
def regenerate_symlinks(fat_framework_bundle)
def zip_xcframework_archive(dst)
def zip_framework(dst, args)
def print(*args, **kwargs)