| OLD | NEW |
| (Empty) | |
| 1 #!/usr/bin/python |
| 2 # Copyright 2016 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. |
| 5 |
| 6 """ |
| 7 package_ios.py - Build and Package Release and Rebug fat libraries for iOS. |
| 8 """ |
| 9 |
| 10 import argparse |
| 11 import os |
| 12 import shutil |
| 13 import sys |
| 14 |
| 15 def run(command, extra_options=''): |
| 16 command = command + ' ' + extra_options |
| 17 print command |
| 18 return os.system(command) |
| 19 |
| 20 |
| 21 def build(out_dir, test_target, extra_options=''): |
| 22 return run('ninja -C ' + out_dir + ' ' + test_target, |
| 23 extra_options) |
| 24 |
| 25 |
| 26 def lipo_libraries(out_dir, input_dirs, out_lib, input_lib): |
| 27 lipo = "lipo -create " |
| 28 for input_dir in input_dirs: |
| 29 lipo += input_dir + "/" + input_lib + " " |
| 30 lipo += '-output ' + out_dir + "/" + out_lib |
| 31 return run(lipo) |
| 32 |
| 33 |
| 34 def copy_build_dir(target_dir, build_dir): |
| 35 try: |
| 36 shutil.copytree(build_dir, target_dir, ignore=shutil.ignore_patterns('*.a')) |
| 37 except OSError as e: |
| 38 print('Directory not copied. Error: %s' % e) |
| 39 return 0 |
| 40 |
| 41 def package_ios(out_dir, build_dir, build_config): |
| 42 build_dir_sim = build_dir |
| 43 build_dir_dev = build_dir +'-iphoneos' |
| 44 build_target = 'cronet_package' |
| 45 target_dir = out_dir + "/Cronet" |
| 46 return build(build_dir_sim, build_target) or \ |
| 47 build(build_dir_dev, build_target) or \ |
| 48 copy_build_dir(target_dir, build_dir_dev + "/cronet") or \ |
| 49 lipo_libraries(target_dir, [build_dir_sim, build_dir_dev], \ |
| 50 "libcronet_" + build_config + ".a", \ |
| 51 "cronet/libcronet_standalone.a") |
| 52 |
| 53 |
| 54 def main(): |
| 55 parser = argparse.ArgumentParser() |
| 56 parser.add_argument('out_dir', nargs=1, help='path to output directory') |
| 57 parser.add_argument('-g', '--skip_gyp', action='store_true', |
| 58 help='skip gyp') |
| 59 parser.add_argument('-d', '--debug', action='store_true', |
| 60 help='use release configuration') |
| 61 parser.add_argument('-r', '--release', action='store_true', |
| 62 help='use release configuration') |
| 63 |
| 64 options, extra_options_list = parser.parse_known_args() |
| 65 print options |
| 66 print extra_options_list |
| 67 |
| 68 gyp_defines = 'GYP_DEFINES="OS=ios enable_websockets=0 '+ \ |
| 69 'disable_file_support=1 disable_ftp_support=1 '+ \ |
| 70 'enable_errorprone=1 use_platform_icu_alternatives=1 ' + \ |
| 71 'disable_brotli_filter=1 use_openssl=1 ' + \ |
| 72 'target_subarch=both"' |
| 73 if not options.skip_gyp: |
| 74 run (gyp_defines + ' gclient runhooks') |
| 75 |
| 76 return package_ios(options.out_dir[0], "out/Release", "opt") or \ |
| 77 package_ios(options.out_dir[0], "out/Debug", "dbg") |
| 78 |
| 79 |
| 80 if __name__ == '__main__': |
| 81 sys.exit(main()) |
| OLD | NEW |