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 = 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,
True)
79 shutil.copytree(arm64_framework, fat_framework, symlinks=
True)
83 fat_framework_binary = os.path.join(fat_framework,
'Versions',
'A',
'FlutterMacOS')
86 subprocess.check_call([
87 'lipo', arm64_dylib, x64_dylib,
'-create',
'-output', fat_framework_binary
91 versions_path = os.path.join(fat_framework,
'Versions')
92 subprocess.check_call([
'chmod',
'-R',
'og+r', versions_path])
94 find_subprocess = subprocess.Popen([
'find', versions_path,
'-perm',
'-100',
'-print0'],
95 stdout=subprocess.PIPE)
97 xargs_subprocess = subprocess.Popen([
'xargs',
'-0',
'chmod',
'og+x'],
98 stdin=find_subprocess.stdout)
99 find_subprocess.wait()
100 xargs_subprocess.wait()
105 xcframeworks = [fat_framework]
114 """Regenerates the symlinks structure.
116 Recipes V2 upload artifacts in CAS before integration and CAS follows symlinks.
117 This logic regenerates the symlinks in the expected structure.
119 if os.path.islink(os.path.join(fat_framework,
'FlutterMacOS')):
121 os.remove(os.path.join(fat_framework,
'FlutterMacOS'))
122 shutil.rmtree(os.path.join(fat_framework,
'Headers'),
True)
123 shutil.rmtree(os.path.join(fat_framework,
'Modules'),
True)
124 shutil.rmtree(os.path.join(fat_framework,
'Resources'),
True)
125 current_version_path = os.path.join(fat_framework,
'Versions',
'Current')
126 shutil.rmtree(current_version_path,
True)
127 os.symlink(
'A', current_version_path)
129 os.path.join(
'Versions',
'Current',
'FlutterMacOS'),
130 os.path.join(fat_framework,
'FlutterMacOS')
132 os.symlink(os.path.join(
'Versions',
'Current',
'Headers'), os.path.join(fat_framework,
'Headers'))
133 os.symlink(os.path.join(
'Versions',
'Current',
'Modules'), os.path.join(fat_framework,
'Modules'))
135 os.path.join(
'Versions',
'Current',
'Resources'), os.path.join(fat_framework,
'Resources')
146 dsym_out = os.path.splitext(fat_framework)[0] +
'.dSYM'
147 subprocess.check_call([DSYMUTIL,
'-o', dsym_out, fat_framework_binary])
149 dsym_dst = os.path.join(dst,
'FlutterMacOS.dSYM')
150 subprocess.check_call([
'zip',
'-r',
'-y',
'FlutterMacOS.dSYM.zip',
'.'], cwd=dsym_dst)
153 subprocess.check_call([
156 'FlutterMacOS.dSYM_.zip',
157 'FlutterMacOS.dSYM.zip',
161 dsym_final_src_path = os.path.join(dsym_dst,
'FlutterMacOS.dSYM_.zip')
162 dsym_final_dst_path = os.path.join(dst,
'FlutterMacOS.dSYM.zip')
163 shutil.move(dsym_final_src_path, dsym_final_dst_path)
167 unstripped_out = os.path.join(dst,
'FlutterMacOS.unstripped')
168 shutil.copyfile(fat_framework_binary, unstripped_out)
170 subprocess.check_call([
'strip',
'-x',
'-S', fat_framework_binary])
176 filepath_with_entitlements =
''
178 framework_dst = os.path.join(dst,
'FlutterMacOS.framework')
180 filepath_without_entitlements =
'FlutterMacOS.framework.zip/Versions/A/FlutterMacOS'
183 os.path.join(framework_dst,
'entitlements.txt'), filepath_with_entitlements
187 os.path.join(framework_dst,
'without_entitlements.txt'), filepath_without_entitlements
189 subprocess.check_call([
193 'FlutterMacOS.framework.zip',
199 subprocess.check_call(
203 'FlutterMacOS.framework_.zip',
204 'FlutterMacOS.framework.zip',
207 'without_entitlements.txt',
212 final_src_path = os.path.join(framework_dst,
'FlutterMacOS.framework_.zip')
213 final_dst_path = os.path.join(dst,
'FlutterMacOS.framework.zip')
214 shutil.move(final_src_path, final_dst_path)