Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Functions | Variables
create_full_ios_framework Namespace Reference

Functions

 main ()
 
 create_extension_safe_framework (args, dst, arm64_out_dir, simulator_x64_out_dir, simulator_arm64_out_dir)
 
 create_framework (args, dst, framework, arm64_framework, simulator_framework, simulator_x64_framework, simulator_arm64_framework)
 
 embed_codesign_configuration (config_path, contents)
 
 zip_archive (dst)
 
 process_framework (args, dst, framework, framework_binary)
 
 generate_gen_snapshot (args, dst, x64_out_dir, arm64_out_dir)
 
 _generate_gen_snapshot (directory, destination)
 

Variables

str ARCH_SUBPATH = 'arm' else 'mac-x64'
 
 DSYMUTIL
 
 buildroot_dir = os.path.abspath(os.path.join(os.path.realpath(__file__), '..', '..', '..', '..'))
 

Function Documentation

◆ _generate_gen_snapshot()

create_full_ios_framework._generate_gen_snapshot (   directory,
  destination 
)
protected

Definition at line 242 of file create_full_ios_framework.py.

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)
246 sys.exit(1)
247
248 subprocess.check_call(['xcrun', 'bitcode_strip', '-r', gen_snapshot_dir, '-o', destination])
249
250
void print(void *str)
Definition bridge.cpp:126

◆ create_extension_safe_framework()

create_full_ios_framework.create_extension_safe_framework (   args,
  dst,
  arm64_out_dir,
  simulator_x64_out_dir,
  simulator_arm64_out_dir 
)

Definition at line 109 of file create_full_ios_framework.py.

111):
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')
117
118 if not os.path.isdir(arm64_framework):
119 print('Cannot find extension safe iOS arm64 Framework at %s' % arm64_framework)
120 return 1
121
122 if not os.path.isdir(simulator_x64_framework):
123 print('Cannot find extension safe iOS x64 simulator Framework at %s' % simulator_x64_framework)
124 return 1
125
126 create_framework(
127 args, dst, framework, arm64_framework, simulator_framework, simulator_x64_framework,
128 simulator_arm64_framework
129 )
130 return 0
131

◆ create_framework()

create_full_ios_framework.create_framework (   args,
  dst,
  framework,
  arm64_framework,
  simulator_framework,
  simulator_x64_framework,
  simulator_arm64_framework 
)

Definition at line 132 of file create_full_ios_framework.py.

135):
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)
141 return 1
142
143 if not os.path.isfile(simulator_x64_dylib):
144 print('Cannot find iOS simulator dylib at %s' % simulator_x64_dylib)
145 return 1
146
147 shutil.rmtree(framework, True)
148 shutil.copytree(arm64_framework, framework)
149 framework_binary = os.path.join(framework, 'Flutter')
150 process_framework(args, dst, framework, framework_binary)
151
152 if args.simulator_arm64_out_dir is not None:
153 shutil.rmtree(simulator_framework, True)
154 shutil.copytree(simulator_arm64_framework, simulator_framework)
155
156 simulator_framework_binary = os.path.join(simulator_framework, 'Flutter')
157
158 # Create the arm64/x64 simulator fat framework.
159 subprocess.check_call([
160 'lipo', simulator_x64_dylib, simulator_arm64_dylib, '-create', '-output',
161 simulator_framework_binary
162 ])
163 process_framework(args, dst, simulator_framework, simulator_framework_binary)
164 else:
165 simulator_framework = simulator_x64_framework
166
167 # Create XCFramework from the arm-only fat framework and the arm64/x64
168 # simulator frameworks, or just the x64 simulator framework if only that one
169 # exists.
170 xcframeworks = [simulator_framework, framework]
171 create_xcframework(location=dst, name='Flutter', frameworks=xcframeworks)
172
173 # Add the x64 simulator into the fat framework
174 subprocess.check_call([
175 'lipo', arm64_dylib, simulator_x64_dylib, '-create', '-output', framework_binary
176 ])
177
178 process_framework(args, dst, framework, framework_binary)
179 return 0
180
181

◆ embed_codesign_configuration()

create_full_ios_framework.embed_codesign_configuration (   config_path,
  contents 
)

Definition at line 182 of file create_full_ios_framework.py.

182def embed_codesign_configuration(config_path, contents):
183 with open(config_path, 'w') as file:
184 file.write('\n'.join(contents) + '\n')
185
186

◆ generate_gen_snapshot()

create_full_ios_framework.generate_gen_snapshot (   args,
  dst,
  x64_out_dir,
  arm64_out_dir 
)

Definition at line 232 of file create_full_ios_framework.py.

232def generate_gen_snapshot(args, dst, x64_out_dir, arm64_out_dir):
233 if x64_out_dir:
234 _generate_gen_snapshot(x64_out_dir, os.path.join(dst, 'gen_snapshot_x64'))
235
236 if arm64_out_dir:
237 _generate_gen_snapshot(
238 os.path.join(arm64_out_dir, args.clang_dir), os.path.join(dst, 'gen_snapshot_arm64')
239 )
240
241

◆ main()

create_full_ios_framework.main ( )

Definition at line 27 of file create_full_ios_framework.py.

27def main():
28 parser = argparse.ArgumentParser(
29 description=(
30 'Creates Flutter.framework, Flutter.xcframework and '
31 'copies architecture-dependent gen_snapshot binaries to output dir'
32 )
33 )
34
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)
43
44 args = parser.parse_args()
45
46 dst = (args.dst if os.path.isabs(args.dst) else os.path.join(buildroot_dir, args.dst))
47
48 arm64_out_dir = (
49 args.arm64_out_dir
50 if os.path.isabs(args.arm64_out_dir) else os.path.join(buildroot_dir, args.arm64_out_dir)
51 )
52
53 x64_out_dir = None
54 if args.x64_out_dir:
55 x64_out_dir = (
56 args.x64_out_dir
57 if os.path.isabs(args.x64_out_dir) else os.path.join(buildroot_dir, args.x64_out_dir)
58 )
59
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)
65 )
66
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')
71
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)
77 )
78
79 if args.simulator_arm64_out_dir is not None:
80 simulator_arm64_framework = os.path.join(simulator_arm64_out_dir, 'Flutter.framework')
81
82 if not os.path.isdir(arm64_framework):
83 print('Cannot find iOS arm64 Framework at %s' % arm64_framework)
84 return 1
85
86 if not os.path.isdir(simulator_x64_framework):
87 print('Cannot find iOS x64 simulator Framework at %s' % simulator_framework)
88 return 1
89
90 if not os.path.isfile(DSYMUTIL):
91 print('Cannot find dsymutil at %s' % DSYMUTIL)
92 return 1
93
94 create_framework(
95 args, dst, framework, arm64_framework, simulator_framework, simulator_x64_framework,
96 simulator_arm64_framework
97 )
98
99 extension_safe_dst = os.path.join(dst, 'extension_safe')
100 create_extension_safe_framework(
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
103 )
104
105 generate_gen_snapshot(args, dst, x64_out_dir, arm64_out_dir)
106 zip_archive(dst)
107 return 0
108
Definition main.py:1

◆ process_framework()

create_full_ios_framework.process_framework (   args,
  dst,
  framework,
  framework_binary 
)

Definition at line 219 of file create_full_ios_framework.py.

219def process_framework(args, dst, framework, framework_binary):
220 if args.dsym:
221 dsym_out = os.path.splitext(framework)[0] + '.dSYM'
222 subprocess.check_call([DSYMUTIL, '-o', dsym_out, framework_binary])
223
224 if args.strip:
225 # copy unstripped
226 unstripped_out = os.path.join(dst, 'Flutter.unstripped')
227 shutil.copyfile(framework_binary, unstripped_out)
228
229 subprocess.check_call(['strip', '-x', '-S', framework_binary])
230
231

◆ zip_archive()

create_full_ios_framework.zip_archive (   dst)

Definition at line 187 of file create_full_ios_framework.py.

187def zip_archive(dst):
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'
194 ]
195 embed_codesign_configuration(os.path.join(dst, 'entitlements.txt'), ios_file_with_entitlements)
196
197 embed_codesign_configuration(
198 os.path.join(dst, 'without_entitlements.txt'), ios_file_without_entitlements
199 )
200
201 subprocess.check_call([
202 'zip',
203 '-r',
204 'artifacts.zip',
205 'gen_snapshot_arm64',
206 'Flutter.xcframework',
207 'entitlements.txt',
208 'without_entitlements.txt',
209 'extension_safe/Flutter.xcframework',
210 ],
211 cwd=dst)
212 if os.path.exists(os.path.join(dst, 'Flutter.dSYM')):
213 subprocess.check_call(['zip', '-r', 'Flutter.dSYM.zip', 'Flutter.dSYM'], cwd=dst)
214
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)
217
218

Variable Documentation

◆ ARCH_SUBPATH

str create_full_ios_framework.ARCH_SUBPATH = 'arm' else 'mac-x64'

Definition at line 19 of file create_full_ios_framework.py.

◆ buildroot_dir

create_full_ios_framework.buildroot_dir = os.path.abspath(os.path.join(os.path.realpath(__file__), '..', '..', '..', '..'))

Definition at line 24 of file create_full_ios_framework.py.

◆ DSYMUTIL

create_full_ios_framework.DSYMUTIL
Initial value:
1= os.path.join(
2 os.path.dirname(__file__), '..', '..', 'buildtools', ARCH_SUBPATH, 'clang', 'bin', 'dsymutil'
3)

Definition at line 20 of file create_full_ios_framework.py.