Chromium Code Reviews| Index: components/cronet/tools/package_ios.py |
| diff --git a/components/cronet/tools/package_ios.py b/components/cronet/tools/package_ios.py |
| index 520cb65bb232bcad2059ca22a59620c44297fb03..8263f3733e465f64b7ea7e4c25ddeb85a29c2def 100755 |
| --- a/components/cronet/tools/package_ios.py |
| +++ b/components/cronet/tools/package_ios.py |
| @@ -17,6 +17,21 @@ def run(command, extra_options=''): |
| print command |
| return os.system(command) |
| +def eprint(message): |
|
mef
2016/05/11 12:55:02
only used once, inline?
kapishnikov
2016/05/11 19:48:15
Done.
|
| + print >>sys.stderr, message |
|
mef
2016/05/11 12:55:02
nit: 2 empty lines between functions. Here and els
kapishnikov
2016/05/11 19:48:15
Done.
|
| + |
| +def copy_directory(src, dst): |
| + """Copies |src| directory into |dst| directory. |
| + """ |
| + dir_name = os.path.basename(src) |
| + os.mkdir(os.path.join(dst, dir_name)) |
| + for item in os.listdir(src): |
|
mef
2016/05/11 12:55:02
Hrm, I still find it weird that we need a custom f
kapishnikov
2016/05/11 19:48:15
Done.
|
| + s = os.path.join(src, item) |
| + d = os.path.join(dst, dir_name, item) |
| + if os.path.isdir(s): |
| + shutil.copytree(s, d) |
| + else: |
| + shutil.copy2(s, d) |
| def build(out_dir, test_target, extra_options=''): |
| return run('ninja -C ' + out_dir + ' ' + test_target, |
| @@ -51,6 +66,31 @@ def package_ios(out_dir, build_dir, build_config): |
| "cronet/libcronet_standalone.a") |
| +def package_ios_framework(out_dir='out/Framework', extra_options=''): |
| + print 'Building Cronet Dynamic Framework...' |
| + |
| + # Use Ninja to build all possible combinations. |
| + build_dirs = ['Debug-iphonesimulator', |
| + 'Debug-iphoneos', |
| + 'Release-iphonesimulator', |
| + 'Release-iphoneos'] |
| + for build_dir in build_dirs: |
| + print 'Building ' + build_dir |
| + build_result = run('ninja -C out/' + build_dir + ' cronet_framework', |
| + extra_options) |
| + if build_result != 0: |
| + return build_result |
| + |
| + # Package all builds in the output directory |
| + os.makedirs(out_dir) |
| + for build_dir in build_dirs: |
| + os.makedirs(os.path.join(out_dir, build_dir)) |
| + copy_directory(os.path.join('out', build_dir, 'Cronet.framework'), |
| + os.path.join(out_dir, build_dir)) |
| + if 'Release' in build_dir: |
| + copy_directory(os.path.join('out', build_dir, 'Cronet.framework.dSYM'), |
| + os.path.join(out_dir, build_dir)) |
| + |
| def main(): |
| parser = argparse.ArgumentParser() |
| parser.add_argument('out_dir', nargs=1, help='path to output directory') |
| @@ -60,20 +100,33 @@ def main(): |
| help='use release configuration') |
| parser.add_argument('-r', '--release', action='store_true', |
| help='use release configuration') |
| + parser.add_argument('--framework', action='store_true', |
| + help='build Cronet dynamic framework') |
| options, extra_options_list = parser.parse_known_args() |
| print options |
| print extra_options_list |
| + out_dir = options.out_dir[0] |
| + |
| + # Make sure that the output directory does not exist |
| + if os.path.exists(out_dir): |
| + eprint('The output directory already exists: ' + out_dir) |
| + return 1 |
| + |
| gyp_defines = 'GYP_DEFINES="OS=ios enable_websockets=0 '+ \ |
| 'disable_file_support=1 disable_ftp_support=1 '+ \ |
| 'enable_errorprone=1 use_platform_icu_alternatives=1 ' + \ |
| - 'disable_brotli_filter=1 target_subarch=both"' |
| + 'disable_brotli_filter=1 chromium_ios_signing=0 ' + \ |
| + 'target_subarch=both"' |
| if not options.skip_gyp: |
| run (gyp_defines + ' gclient runhooks') |
| - return package_ios(options.out_dir[0], "out/Release", "opt") or \ |
| - package_ios(options.out_dir[0], "out/Debug", "dbg") |
| + if options.framework: |
| + return package_ios_framework(out_dir) |
| + |
| + return package_ios(out_dir, "out/Release", "opt") or \ |
| + package_ios(out_dir, "out/Debug", "dbg") |
| if __name__ == '__main__': |