17from create_xcframework
import create_xcframework
19ARCH_SUBPATH =
'mac-arm64' if platform.processor() ==
'arm' else 'mac-x64'
20DSYMUTIL = os.path.join(
21 os.path.dirname(__file__),
'..',
'..',
'buildtools', ARCH_SUBPATH,
'clang',
'bin',
'dsymutil'
24buildroot_dir = os.path.abspath(os.path.join(os.path.realpath(__file__),
'..',
'..',
'..',
'..'))
28 parser = argparse.ArgumentParser(
30 'Creates Flutter.framework, Flutter.xcframework and '
31 'copies architecture-dependent gen_snapshot binaries to output dir'
35 parser.add_argument(
'--dst', type=str, required=
True)
36 parser.add_argument(
'--clang-dir', type=str, default=
'clang_x64')
37 parser.add_argument(
'--x64-out-dir', type=str)
38 parser.add_argument(
'--arm64-out-dir', type=str, required=
True)
39 parser.add_argument(
'--simulator-x64-out-dir', type=str, required=
True)
40 parser.add_argument(
'--simulator-arm64-out-dir', type=str, required=
False)
41 parser.add_argument(
'--strip', action=
'store_true', default=
False)
42 parser.add_argument(
'--dsym', action=
'store_true', default=
False)
44 args = parser.parse_args()
46 dst = (args.dst
if os.path.isabs(args.dst)
else os.path.join(buildroot_dir, args.dst))
50 if os.path.isabs(args.arm64_out_dir)
else os.path.join(buildroot_dir, args.arm64_out_dir)
57 if os.path.isabs(args.x64_out_dir)
else os.path.join(buildroot_dir, args.x64_out_dir)
60 simulator_x64_out_dir =
None
61 if args.simulator_x64_out_dir:
62 simulator_x64_out_dir = (
63 args.simulator_x64_out_dir
if os.path.isabs(args.simulator_x64_out_dir)
else
64 os.path.join(buildroot_dir, args.simulator_x64_out_dir)
67 framework = os.path.join(dst,
'Flutter.framework')
68 simulator_framework = os.path.join(dst,
'sim',
'Flutter.framework')
69 arm64_framework = os.path.join(arm64_out_dir,
'Flutter.framework')
70 simulator_x64_framework = os.path.join(simulator_x64_out_dir,
'Flutter.framework')
72 simulator_arm64_out_dir =
None
73 if args.simulator_arm64_out_dir:
74 simulator_arm64_out_dir = (
75 args.simulator_arm64_out_dir
if os.path.isabs(args.simulator_arm64_out_dir)
else
76 os.path.join(buildroot_dir, args.simulator_arm64_out_dir)
79 if args.simulator_arm64_out_dir
is not None:
80 simulator_arm64_framework = os.path.join(simulator_arm64_out_dir,
'Flutter.framework')
82 if not os.path.isdir(arm64_framework):
83 print(
'Cannot find iOS arm64 Framework at %s' % arm64_framework)
86 if not os.path.isdir(simulator_x64_framework):
87 print(
'Cannot find iOS x64 simulator Framework at %s' % simulator_framework)
90 if not os.path.isfile(DSYMUTIL):
91 print(
'Cannot find dsymutil at %s' % DSYMUTIL)
95 args, dst, framework, arm64_framework, simulator_framework, simulator_x64_framework,
96 simulator_arm64_framework
99 extension_safe_dst = os.path.join(dst,
'extension_safe')
101 args, extension_safe_dst,
'%s_extension_safe' % arm64_out_dir,
102 '%s_extension_safe' % simulator_x64_out_dir,
'%s_extension_safe' % simulator_arm64_out_dir
110 args, dst, arm64_out_dir, simulator_x64_out_dir, simulator_arm64_out_dir
112 framework = os.path.join(dst,
'Flutter.framework')
113 simulator_framework = os.path.join(dst,
'sim',
'Flutter.framework')
114 arm64_framework = os.path.join(arm64_out_dir,
'Flutter.framework')
115 simulator_x64_framework = os.path.join(simulator_x64_out_dir,
'Flutter.framework')
116 simulator_arm64_framework = os.path.join(simulator_arm64_out_dir,
'Flutter.framework')
118 if not os.path.isdir(arm64_framework):
119 print(
'Cannot find extension safe iOS arm64 Framework at %s' % arm64_framework)
122 if not os.path.isdir(simulator_x64_framework):
123 print(
'Cannot find extension safe iOS x64 simulator Framework at %s' % simulator_x64_framework)
127 args, dst, framework, arm64_framework, simulator_framework, simulator_x64_framework,
128 simulator_arm64_framework
133 args, dst, framework, arm64_framework, simulator_framework,
134 simulator_x64_framework, simulator_arm64_framework
136 arm64_dylib = os.path.join(arm64_framework,
'Flutter')
137 simulator_x64_dylib = os.path.join(simulator_x64_framework,
'Flutter')
138 simulator_arm64_dylib = os.path.join(simulator_arm64_framework,
'Flutter')
139 if not os.path.isfile(arm64_dylib):
140 print(
'Cannot find iOS arm64 dylib at %s' % arm64_dylib)
143 if not os.path.isfile(simulator_x64_dylib):
144 print(
'Cannot find iOS simulator dylib at %s' % simulator_x64_dylib)
147 shutil.rmtree(framework,
True)
148 shutil.copytree(arm64_framework, framework)
149 framework_binary = os.path.join(framework,
'Flutter')
152 if args.simulator_arm64_out_dir
is not None:
153 shutil.rmtree(simulator_framework,
True)
154 shutil.copytree(simulator_arm64_framework, simulator_framework)
156 simulator_framework_binary = os.path.join(simulator_framework,
'Flutter')
159 subprocess.check_call([
160 'lipo', simulator_x64_dylib, simulator_arm64_dylib,
'-create',
'-output',
161 simulator_framework_binary
165 simulator_framework = simulator_x64_framework
170 xcframeworks = [simulator_framework, framework]
174 subprocess.check_call([
175 'lipo', arm64_dylib, simulator_x64_dylib,
'-create',
'-output', framework_binary
183 with open(config_path,
'w')
as file:
184 file.write(
'\n'.
join(contents) +
'\n')
188 ios_file_with_entitlements = [
'gen_snapshot_arm64']
189 ios_file_without_entitlements = [
190 'Flutter.xcframework/ios-arm64/Flutter.framework/Flutter',
191 'Flutter.xcframework/ios-arm64_x86_64-simulator/Flutter.framework/Flutter',
192 'extension_safe/Flutter.xcframework/ios-arm64/Flutter.framework/Flutter',
193 'extension_safe/Flutter.xcframework/ios-arm64_x86_64-simulator/Flutter.framework/Flutter'
198 os.path.join(dst,
'without_entitlements.txt'), ios_file_without_entitlements
201 subprocess.check_call([
205 'gen_snapshot_arm64',
206 'Flutter.xcframework',
208 'without_entitlements.txt',
209 'extension_safe/Flutter.xcframework',
212 if os.path.exists(os.path.join(dst,
'Flutter.dSYM')):
213 subprocess.check_call([
'zip',
'-r',
'Flutter.dSYM.zip',
'Flutter.dSYM'], cwd=dst)
215 if os.path.exists(os.path.join(dst,
'extension_safe',
'Flutter.dSYM')):
216 subprocess.check_call([
'zip',
'-r',
'extension_safe_Flutter.dSYM.zip',
'Flutter.dSYM'], cwd=dst)
221 dsym_out = os.path.splitext(framework)[0] +
'.dSYM'
222 subprocess.check_call([DSYMUTIL,
'-o', dsym_out, framework_binary])
226 unstripped_out = os.path.join(dst,
'Flutter.unstripped')
227 shutil.copyfile(framework_binary, unstripped_out)
229 subprocess.check_call([
'strip',
'-x',
'-S', framework_binary])
234 _generate_gen_snapshot(x64_out_dir, os.path.join(dst,
'gen_snapshot_x64'))
237 _generate_gen_snapshot(
238 os.path.join(arm64_out_dir, args.clang_dir), os.path.join(dst,
'gen_snapshot_arm64')
242def _generate_gen_snapshot(directory, destination):
243 gen_snapshot_dir = os.path.join(directory,
'gen_snapshot')
244 if not os.path.isfile(gen_snapshot_dir):
245 print(
'Cannot find gen_snapshot at %s' % gen_snapshot_dir)
248 subprocess.check_call([
'xcrun',
'bitcode_strip',
'-r', gen_snapshot_dir,
'-o', destination])
251if __name__ ==
'__main__':
def create_extension_safe_framework(args, dst, arm64_out_dir, simulator_x64_out_dir, simulator_arm64_out_dir)
def embed_codesign_configuration(config_path, contents)
def process_framework(args, dst, framework, framework_binary)
def create_framework(args, dst, framework, arm64_framework, simulator_framework, simulator_x64_framework, simulator_arm64_framework)
def generate_gen_snapshot(args, dst, x64_out_dir, arm64_out_dir)
def print(*args, **kwargs)
static SkString join(const CommandLineFlags::StringArray &)