Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 #!/usr/bin/python | |
| 2 # Copyright 2017 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 Debug fat libraries for iOS. | |
|
Hiroshi Ichikawa
2017/06/14 06:31:58
Maybe it's better to say that this script is for C
michaeldo
2017/06/15 20:17:29
Good point, updated.
| |
| 8 """ | |
| 9 | |
| 10 import argparse | |
| 11 import os | |
| 12 import shutil | |
| 13 import sys | |
| 14 | |
| 15 def run(command, extra_options=''): | |
|
Eugene But (OOO till 7-30)
2017/06/14 03:38:55
Please add comments for every non-trivial function
michaeldo
2017/06/15 20:17:29
Done.
| |
| 16 command = command + ' ' + ' '.join(extra_options) | |
| 17 print command | |
| 18 return os.system(command) | |
| 19 | |
| 20 def package_ios_framework_using_gn(out_dir='out/Framework', extra_options=''): | |
| 21 print 'Building CronetChromeWebView Dynamic Framework...' | |
| 22 | |
| 23 # Package all builds in the output directory | |
| 24 os.makedirs(out_dir) | |
| 25 build_dir = '' | |
| 26 for (build_config, gn_extra_args) in [('Debug', 'is_debug=true use_xcode_clang =true'), | |
|
Eugene But (OOO till 7-30)
2017/06/14 03:38:55
This for loop has only 2 iterations and will unlik
Hiroshi Ichikawa
2017/06/14 06:31:58
Why do you specify use_xcode_clang=true only for d
michaeldo
2017/06/15 20:17:29
I pulled the options from cronet package_ios.py. I
michaeldo
2017/06/15 20:17:29
I agree, I reformatted this into method calls.
| |
| 27 ('Release', 'is_debug=false enable_stripping=true is_official_build=true ')]: | |
|
Hiroshi Ichikawa
2017/06/14 06:31:58
is_official_build should be false even for release
michaeldo
2017/06/15 20:17:29
Done.
| |
| 28 for (target_device, target_cpu, additional_cpu) in [('os', 'arm', 'arm64'), | |
|
Eugene But (OOO till 7-30)
2017/06/14 03:38:55
ditto
michaeldo
2017/06/15 20:17:29
Done.
| |
| 29 ('simulator', 'x86', 'x64')]: | |
| 30 target_dir = '%s-iphone%s' % (build_config, target_device) | |
| 31 build_dir = os.path.join("out", target_dir) | |
| 32 gn_args = 'target_os="ios" enable_websockets=false ' \ | |
|
Hiroshi Ichikawa
2017/06/14 06:31:58
How about providing an option to use Goma? Otherwi
michaeldo
2017/06/15 20:17:29
Great idea. Done.
| |
| 33 'is_component_build=false ' \ | |
| 34 'disable_file_support=true disable_ftp_support=true ' \ | |
| 35 'disable_brotli_filter=true enable_dsyms=true ' \ | |
|
Hiroshi Ichikawa
2017/06/14 06:31:58
Just curious, do you know if enable_dsyms affects
michaeldo
2017/06/15 20:17:29
Removing enable_dsyms or setting it to true or fal
| |
| 36 'target_cpu="%s" additional_target_cpus = ["%s"] %s' % \ | |
| 37 (target_cpu, additional_cpu, gn_extra_args) | |
| 38 | |
| 39 #is_cronet_build=true? | |
|
Eugene But (OOO till 7-30)
2017/06/14 03:38:55
Remove this?
Hiroshi Ichikawa
2017/06/14 06:31:58
Yeah I believe this should be set to false even fo
michaeldo
2017/06/15 20:17:29
Yes, it should be false, but I left this here as a
| |
| 40 print 'Generating Ninja ' + gn_args | |
| 41 gn_result = run('gn gen %s --args=\'%s\'' % (build_dir, gn_args)) | |
| 42 if gn_result != 0: | |
| 43 return gn_result | |
| 44 | |
| 45 print 'Building ' + build_dir | |
| 46 build_result = run('ninja -C %s ios/web_view:cronet_ios_web_view_package' % build_dir, | |
|
Eugene But (OOO till 7-30)
2017/06/14 03:38:55
Does it fit 80 symbols?
michaeldo
2017/06/15 20:17:29
Done.
| |
| 47 extra_options) | |
| 48 if build_result != 0: | |
| 49 return build_result | |
| 50 | |
| 51 # Copy framework. | |
| 52 shutil.copytree(os.path.join(build_dir, 'CronetChromeWebView.framework'), | |
| 53 os.path.join(out_dir, target_dir, 'CronetChromeWebView.framework')) | |
| 54 # Copy symbols. | |
| 55 shutil.copytree(os.path.join(build_dir, 'CronetChromeWebView.dSYM'), | |
| 56 os.path.join(out_dir, target_dir, 'CronetChromeWebView.framework.dSYM' )) | |
| 57 | |
| 58 # Copy common files from last built package. | |
| 59 package_dir = os.path.join(build_dir, 'cronet_ios_web_view') | |
| 60 shutil.copy2(os.path.join(package_dir, 'AUTHORS'), out_dir) | |
| 61 shutil.copy2(os.path.join(package_dir, 'LICENSE'), out_dir) | |
| 62 shutil.copy2(os.path.join(package_dir, 'VERSION'), out_dir) | |
| 63 # Copy the headers. | |
|
Hiroshi Ichikawa
2017/06/14 06:31:58
Maybe you don't need to do this? We only expect he
michaeldo
2017/06/15 20:17:29
Done. I agree, I used cronet script as a template,
| |
| 64 shutil.copytree(os.path.join(build_dir, | |
| 65 'CronetChromeWebView.framework', 'Headers'), | |
| 66 os.path.join(out_dir, 'Headers')) | |
| 67 print 'CronetChromeWebView framework is packaged into %s' % out_dir | |
| 68 | |
| 69 | |
| 70 def main(): | |
| 71 description = ( | |
| 72 'To build CronetChromeWebView.framework call:\n' | |
| 73 'package_ios.py out/Frameworks\n' | |
| 74 ) | |
| 75 parser = argparse.ArgumentParser(description=description) | |
| 76 | |
| 77 parser.add_argument('out_dir', nargs=1, help='path to output directory') | |
| 78 | |
| 79 options, extra_options_list = parser.parse_known_args() | |
| 80 print options | |
| 81 print extra_options_list | |
| 82 | |
| 83 out_dir = options.out_dir[0] | |
| 84 | |
| 85 # Make sure that the output directory does not exist | |
| 86 if os.path.exists(out_dir): | |
| 87 print >>sys.stderr, 'The output directory already exists: ' + out_dir | |
| 88 return 1 | |
| 89 | |
| 90 return package_ios_framework_using_gn(out_dir, extra_options_list) | |
| 91 | |
| 92 | |
| 93 if __name__ == '__main__': | |
| 94 sys.exit(main()) | |
| OLD | NEW |