27 parser = argparse.ArgumentParser(
28 description='Creates FlutterMacOS.framework and FlutterMacOS.xcframework for macOS'
29 )
30
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)
36
37 parser.add_argument('--zip', action='store_true', default=False)
38
39 args = parser.parse_args()
40
41 dst = (args.dst if os.path.isabs(args.dst) else os.path.join(buildroot_dir, args.dst))
42 arm64_out_dir = (
43 args.arm64_out_dir
44 if os.path.isabs(args.arm64_out_dir) else os.path.join(buildroot_dir, args.arm64_out_dir)
45 )
46 x64_out_dir = (
47 args.x64_out_dir
48 if os.path.isabs(args.x64_out_dir) else os.path.join(buildroot_dir, args.x64_out_dir)
49 )
50
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')
54
55 arm64_dylib = os.path.join(arm64_framework, 'FlutterMacOS')
56 x64_dylib = os.path.join(x64_framework, 'FlutterMacOS')
57
58 if not os.path.isdir(arm64_framework):
59 print(
'Cannot find macOS arm64 Framework at %s' % arm64_framework)
60 return 1
61
62 if not os.path.isdir(x64_framework):
63 print(
'Cannot find macOS x64 Framework at %s' % x64_framework)
64 return 1
65
66 if not os.path.isfile(arm64_dylib):
67 print(
'Cannot find macOS arm64 dylib at %s' % arm64_dylib)
68 return 1
69
70 if not os.path.isfile(x64_dylib):
71 print(
'Cannot find macOS x64 dylib at %s' % x64_dylib)
72 return 1
73
74 if not os.path.isfile(DSYMUTIL):
75 print(
'Cannot find dsymutil at %s' % DSYMUTIL)
76 return 1
77
78 shutil.rmtree(fat_framework_bundle, True)
79 shutil.copytree(arm64_framework, fat_framework_bundle, symlinks=True)
80
82
83 fat_framework_binary = os.path.join(fat_framework_bundle, 'Versions', 'A', 'FlutterMacOS')
84
85
86 subprocess.check_call([
87 'lipo', arm64_dylib, x64_dylib, '-create', '-output', fat_framework_binary
88 ])
89
90 subprocess.check_call(['chmod', '755', fat_framework_bundle])
91
92
93 versions_path = os.path.join(fat_framework_bundle, 'Versions')
94 subprocess.check_call(['chmod', '-R', 'og+r', versions_path])
95
96 find_subprocess = subprocess.Popen(['find', versions_path, '-perm', '-100', '-print0'],
97 stdout=subprocess.PIPE)
98
99 xargs_subprocess = subprocess.Popen(['xargs', '-0', 'chmod', 'og+x'],
100 stdin=find_subprocess.stdout)
101 find_subprocess.wait()
102 xargs_subprocess.wait()
103
105
106
107 xcframeworks = [fat_framework_bundle]
109
111
112 return 0
113
114
def process_framework(dst, args, fat_framework_bundle, fat_framework_binary)
def regenerate_symlinks(fat_framework_bundle)
def zip_framework(dst, args)
def print(*args, **kwargs)