flutter_flutter/sky/tools/create_ios_framework.py
Dan Field ff62dec5c9
Roll to clang11, mark 4 (#17483)
* "Reland Clang 11, roll buildroot to 1bc40a5f916adb93d87e2a2230a0ec43db876c1c, take 4 (#17467)" (#17482)"

This reverts commit 8166a91bca11b83c16fba8f8fd407e937a2ac89c.

* format code

* Roll buildroot to 3a27de1c5bb0f50be7d3efe3e00de4f6068c9f30
2020-04-02 13:04:49 -07:00

98 lines
3.1 KiB
Python
Executable File

#!/usr/bin/env python
# Copyright 2013 The Flutter Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import argparse
import subprocess
import shutil
import sys
import os
DSYMUTIL = os.path.join(os.path.dirname(__file__), '..', '..', '..',
'buildtools', 'mac-x64', 'clang', 'bin', 'dsymutil')
def main():
parser = argparse.ArgumentParser(description='Creates Flutter.framework')
parser.add_argument('--dst', type=str, required=True)
parser.add_argument('--arm64-out-dir', type=str, required=True)
parser.add_argument('--armv7-out-dir', type=str, required=True)
parser.add_argument('--simulator-out-dir', type=str, required=True)
parser.add_argument('--strip', action="store_true", default=False)
parser.add_argument('--dsym', action="store_true", default=False)
parser.add_argument('--strip-bitcode', dest='strip_bitcode', action="store_true", default=False)
args = parser.parse_args()
fat_framework = os.path.join(args.dst, 'Flutter.framework')
arm64_framework = os.path.join(args.arm64_out_dir, 'Flutter.framework')
armv7_framework = os.path.join(args.armv7_out_dir, 'Flutter.framework')
simulator_framework = os.path.join(args.simulator_out_dir, 'Flutter.framework')
arm64_dylib = os.path.join(arm64_framework, 'Flutter')
armv7_dylib = os.path.join(armv7_framework, 'Flutter')
simulator_dylib = os.path.join(simulator_framework, 'Flutter')
if not os.path.isdir(arm64_framework):
print('Cannot find iOS arm64 Framework at %s' % arm64_framework)
return 1
if not os.path.isdir(armv7_framework):
print('Cannot find iOS armv7 Framework at %s' % armv7_framework)
return 1
if not os.path.isdir(simulator_framework):
print('Cannot find iOS simulator Framework at %s' % simulator_framework)
return 1
if not os.path.isfile(arm64_dylib):
print('Cannot find iOS arm64 dylib at %s' % arm64_dylib)
return 1
if not os.path.isfile(armv7_dylib):
print('Cannot find iOS armv7 dylib at %s' % armv7_dylib)
return 1
if not os.path.isfile(simulator_dylib):
print('Cannot find iOS simulator dylib at %s' % simulator_dylib)
return 1
if not os.path.isfile(DSYMUTIL):
print('Cannot find dsymutil at %s' % DSYMUTIL)
return 1
shutil.rmtree(fat_framework, True)
shutil.copytree(arm64_framework, fat_framework)
linker_out = os.path.join(fat_framework, 'Flutter')
subprocess.check_call([
'lipo',
arm64_dylib,
armv7_dylib,
simulator_dylib,
'-create',
'-output',
linker_out
])
if args.strip_bitcode:
subprocess.check_call(['xcrun', 'bitcode_strip', '-r', linker_out, '-o', linker_out])
if args.dsym:
dsym_out = os.path.splitext(fat_framework)[0] + '.dSYM'
subprocess.check_call([DSYMUTIL, '-o', dsym_out, linker_out])
if args.strip:
# copy unstripped
unstripped_out = os.path.join(args.dst, 'Flutter.unstripped')
shutil.copyfile(linker_out, unstripped_out)
subprocess.check_call(["strip", "-x", "-S", linker_out])
if __name__ == '__main__':
sys.exit(main())