| Index: components/cronet/tools/package_ios.py
|
| diff --git a/components/cronet/tools/package_ios.py b/components/cronet/tools/package_ios.py
|
| index ec704143d3c7ed8942fa50f1ccdf33b66f80af0c..fa2529932989f7d80e490f74485255327e6e4f88 100755
|
| --- a/components/cronet/tools/package_ios.py
|
| +++ b/components/cronet/tools/package_ios.py
|
| @@ -83,11 +83,74 @@ def package_ios_framework(out_dir='out/Framework', extra_options=''):
|
| os.path.join(out_dir, 'Headers'))
|
|
|
|
|
| +def package_ios_framework_using_gn(out_dir='out/Framework', extra_options=''):
|
| + print 'Building Cronet Dynamic Framework using gn...'
|
| +
|
| + # Package all builds in the output directory
|
| + os.makedirs(out_dir)
|
| + build_dir = ''
|
| + for (build_config, is_debug) in [('Debug', 'true'),
|
| + ('Release', 'false')]:
|
| + for (target_device, target_cpus) in [('simulator', ['x86', 'x64']),
|
| + ('os', ['arm', 'arm64'])]:
|
| + build_dirs = []
|
| + # Build every architecture separately until gn supports fat builds.
|
| + for target_cpu in target_cpus:
|
| + build_dir = 'out/cronet_%s_%s' % (build_config, target_cpu)
|
| + build_dirs.append(build_dir)
|
| + gn_args = 'target_os="ios" enable_websockets=false ' \
|
| + 'disable_file_support=true disable_ftp_support=true ' \
|
| + 'use_platform_icu_alternatives=true ' \
|
| + 'disable_brotli_filter=true ' \
|
| + 'target_cpu="%s" is_debug=%s' % (target_cpu, is_debug)
|
| +
|
| + print 'Generating Ninja ' + gn_args
|
| + gn_result = run('gn gen %s --args=\'%s\'' % (build_dir, gn_args))
|
| + if gn_result != 0:
|
| + return gn_result
|
| +
|
| + print 'Building ' + build_dir
|
| + build_result = run('ninja -C %s cronet_package' % build_dir,
|
| + extra_options)
|
| + if build_result != 0:
|
| + return build_result
|
| +
|
| + # Copy first framework.
|
| + target_dir = '%s-iphone%s' % (build_config, target_device)
|
| + shutil.copytree(os.path.join(build_dirs[0], 'Cronet.framework'),
|
| + os.path.join(out_dir, target_dir, 'Cronet.framework'))
|
| + # Lipo first and second cpu.
|
| + lipo_result = run('lipo -create %s %s -output %s' %
|
| + (os.path.join(build_dirs[0], 'Cronet.framework/Cronet'),
|
| + os.path.join(build_dirs[1], 'Cronet.framework/Cronet'),
|
| + os.path.join(out_dir, target_dir, 'Cronet.framework/Cronet')))
|
| + if lipo_result != 0:
|
| + return lipo_result
|
| + # Extract and strip symbols from release binaries.
|
| + if 'Release' in build_config:
|
| + run('dsymutil -o=%s -minimize %s' %
|
| + (os.path.join(out_dir, target_dir, 'Cronet.framework.dSYM'),
|
| + os.path.join(out_dir, target_dir, 'Cronet.framework/Cronet')))
|
| + run('strip -x %s' %
|
| + os.path.join(out_dir, target_dir, 'Cronet.framework/Cronet'))
|
| +
|
| + # Copy common files from last built package.
|
| + package_dir = os.path.join(build_dir, 'cronet')
|
| + shutil.copy2(os.path.join(package_dir, 'AUTHORS'), out_dir)
|
| + shutil.copy2(os.path.join(package_dir, 'LICENSE'), out_dir)
|
| + shutil.copy2(os.path.join(package_dir, 'VERSION'), out_dir)
|
| + # Copy the headers
|
| + shutil.copytree(os.path.join(build_dir,
|
| + 'Cronet.framework', 'Headers'),
|
| + os.path.join(out_dir, 'Headers'))
|
| + print 'Cronet dynamic framework is packaged into %s' % out_dir
|
| +
|
| +
|
| def main():
|
| parser = argparse.ArgumentParser()
|
| parser.add_argument('out_dir', nargs=1, help='path to output directory')
|
| - parser.add_argument('-g', '--skip_gyp', action='store_true',
|
| - help='skip gyp')
|
| + parser.add_argument('-g', '--gn', action='store_true',
|
| + help='build using gn')
|
| parser.add_argument('-d', '--debug', action='store_true',
|
| help='use release configuration')
|
| parser.add_argument('-r', '--release', action='store_true',
|
| @@ -111,12 +174,15 @@ def main():
|
| 'enable_errorprone=1 use_platform_icu_alternatives=1 ' + \
|
| 'disable_brotli_filter=1 chromium_ios_signing=0 ' + \
|
| 'target_subarch=both"'
|
| - if not options.skip_gyp:
|
| + if not options.gn:
|
| run (gyp_defines + ' gclient runhooks')
|
|
|
| if options.framework:
|
| return package_ios_framework(out_dir, extra_options_list)
|
|
|
| + if options.gn:
|
| + return package_ios_framework_using_gn(out_dir, extra_options_list)
|
| +
|
| return package_ios(out_dir, "out/Release", "opt") or \
|
| package_ios(out_dir, "out/Debug", "dbg")
|
|
|
|
|