Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
create_ios_framework.py
Go to the documentation of this file.
1#!/usr/bin/env python3
2#
3# Copyright 2013 The Flutter Authors. All rights reserved.
4# Use of this source code is governed by a BSD-style license that can be
5# found in the LICENSE file.
6
7import argparse
8import platform
9import subprocess
10import shutil
11import sys
12import os
13
14from create_xcframework import create_xcframework # pylint: disable=import-error
15
16ARCH_SUBPATH = 'mac-arm64' if platform.processor() == 'arm' else 'mac-x64'
17DSYMUTIL = os.path.join(
18 os.path.dirname(__file__), '..', '..', 'buildtools', ARCH_SUBPATH, 'clang', 'bin', 'dsymutil'
19)
20
21
22def main():
23 parser = argparse.ArgumentParser(description='Creates Flutter.framework and Flutter.xcframework')
24
25 parser.add_argument('--dst', type=str, required=True)
26 parser.add_argument('--arm64-out-dir', type=str, required=True)
27 parser.add_argument('--armv7-out-dir', type=str, required=False)
28 # TODO(gw280): Remove --simulator-out-dir alias when all recipes are updated
29 parser.add_argument('--simulator-x64-out-dir', '--simulator-out-dir', type=str, required=True)
30 parser.add_argument('--simulator-arm64-out-dir', type=str, required=False)
31 parser.add_argument('--strip', action='store_true', default=False)
32 parser.add_argument('--dsym', action='store_true', default=False)
33
34 args = parser.parse_args()
35
36 framework = os.path.join(args.dst, 'Flutter.framework')
37 simulator_framework = os.path.join(args.dst, 'sim', 'Flutter.framework')
38 arm64_framework = os.path.join(args.arm64_out_dir, 'Flutter.framework')
39 simulator_x64_framework = os.path.join(args.simulator_x64_out_dir, 'Flutter.framework')
40 if args.simulator_arm64_out_dir is not None:
41 simulator_arm64_framework = os.path.join(args.simulator_arm64_out_dir, 'Flutter.framework')
42 simulator_arm64_dylib = os.path.join(simulator_arm64_framework, 'Flutter')
43
44 arm64_dylib = os.path.join(arm64_framework, 'Flutter')
45 simulator_x64_dylib = os.path.join(simulator_x64_framework, 'Flutter')
46
47 if not os.path.isdir(arm64_framework):
48 print('Cannot find iOS arm64 Framework at %s' % arm64_framework)
49 return 1
50
51 if not os.path.isdir(simulator_x64_framework):
52 print('Cannot find iOS x64 simulator Framework at %s' % simulator_framework)
53 return 1
54
55 if not os.path.isfile(arm64_dylib):
56 print('Cannot find iOS arm64 dylib at %s' % arm64_dylib)
57 return 1
58
59 if not os.path.isfile(simulator_x64_dylib):
60 print('Cannot find iOS simulator dylib at %s' % simulator_x64_dylib)
61 return 1
62
63 if not os.path.isfile(DSYMUTIL):
64 print('Cannot find dsymutil at %s' % DSYMUTIL)
65 return 1
66
67 shutil.rmtree(framework, True)
68 shutil.copytree(arm64_framework, framework)
69 framework_binary = os.path.join(framework, 'Flutter')
70 process_framework(args, framework, framework_binary)
71
72 if args.simulator_arm64_out_dir is not None:
73 shutil.rmtree(simulator_framework, True)
74 shutil.copytree(simulator_arm64_framework, simulator_framework)
75
76 simulator_framework_binary = os.path.join(simulator_framework, 'Flutter')
77
78 # Create the arm64/x64 simulator fat framework.
79 subprocess.check_call([
80 'lipo', simulator_x64_dylib, simulator_arm64_dylib, '-create', '-output',
81 simulator_framework_binary
82 ])
83 process_framework(args, simulator_framework, simulator_framework_binary)
84 else:
85 simulator_framework = simulator_x64_framework
86
87 # Create XCFramework from the arm-only fat framework and the arm64/x64
88 # simulator frameworks, or just the x64 simulator framework if only that one
89 # exists.
90 xcframeworks = [simulator_framework, framework]
91 create_xcframework(location=args.dst, name='Flutter', frameworks=xcframeworks)
92
93 # Add the x64 simulator into the fat framework
94 subprocess.check_call([
95 'lipo', arm64_dylib, simulator_x64_dylib, '-create', '-output', framework_binary
96 ])
97
98 process_framework(args, framework, framework_binary)
99 return 0
100
101
102def process_framework(args, framework, framework_binary):
103 if args.dsym:
104 dsym_out = os.path.splitext(framework)[0] + '.dSYM'
105 subprocess.check_call([DSYMUTIL, '-o', dsym_out, framework_binary])
106
107 if args.strip:
108 # copy unstripped
109 unstripped_out = os.path.join(args.dst, 'Flutter.unstripped')
110 shutil.copyfile(framework_binary, unstripped_out)
111
112 subprocess.check_call(['strip', '-x', '-S', framework_binary])
113
114
115if __name__ == '__main__':
116 sys.exit(main())
void print(void *str)
Definition bridge.cpp:126
process_framework(args, framework, framework_binary)
Definition main.py:1