OLD | NEW |
---|---|
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 # Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 """ | 6 """ |
7 package_ios.py - Build and Package Release and Rebug fat libraries for iOS. | 7 package_ios.py - Build and Package Release and Rebug fat libraries for iOS. |
8 """ | 8 """ |
9 | 9 |
10 import argparse | 10 import argparse |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
45 build_target = 'cronet_package' | 45 build_target = 'cronet_package' |
46 target_dir = out_dir | 46 target_dir = out_dir |
47 return build(build_dir_sim, build_target) or \ | 47 return build(build_dir_sim, build_target) or \ |
48 build(build_dir_dev, build_target) or \ | 48 build(build_dir_dev, build_target) or \ |
49 copy_build_dir(target_dir, build_dir_dev + "/cronet") or \ | 49 copy_build_dir(target_dir, build_dir_dev + "/cronet") or \ |
50 lipo_libraries(target_dir, [build_dir_sim, build_dir_dev], \ | 50 lipo_libraries(target_dir, [build_dir_sim, build_dir_dev], \ |
51 "libcronet_" + build_config + ".a", \ | 51 "libcronet_" + build_config + ".a", \ |
52 "cronet/libcronet_standalone.a") | 52 "cronet/libcronet_standalone.a") |
53 | 53 |
54 | 54 |
55 def package_ios_framework(out_dir='out/Framework', extra_options=''): | 55 def package_ios_framework(out_dir, target, framework_name, extra_options=''): |
56 print 'Building Cronet Dynamic Framework...' | 56 print 'Building Cronet Dynamic Framework...' |
57 | 57 |
58 # Use Ninja to build all possible combinations. | 58 # Use Ninja to build all possible combinations. |
59 build_dirs = ['Debug-iphonesimulator', | 59 build_dirs = ['Debug-iphonesimulator', |
60 'Debug-iphoneos', | 60 'Debug-iphoneos', |
61 'Release-iphonesimulator', | 61 'Release-iphonesimulator', |
62 'Release-iphoneos'] | 62 'Release-iphoneos'] |
63 for build_dir in build_dirs: | 63 for build_dir in build_dirs: |
64 print 'Building ' + build_dir | 64 print 'Building ' + build_dir |
65 build_result = run('ninja -C out/' + build_dir + ' cronet_framework', | 65 build_result = run('ninja -C out/' + build_dir + ' ' + target, |
66 extra_options) | 66 extra_options) |
67 if build_result != 0: | 67 if build_result != 0: |
68 return build_result | 68 return build_result |
69 | 69 |
70 # Package all builds in the output directory | 70 # Package all builds in the output directory |
71 os.makedirs(out_dir) | 71 os.makedirs(out_dir) |
72 for build_dir in build_dirs: | 72 for build_dir in build_dirs: |
73 shutil.copytree(os.path.join('out', build_dir, 'Cronet.framework'), | 73 shutil.copytree(os.path.join('out', build_dir, framework_name), |
74 os.path.join(out_dir, build_dir, 'Cronet.framework')) | 74 os.path.join(out_dir, build_dir, framework_name)) |
75 if 'Release' in build_dir: | 75 if 'Release' in build_dir: |
76 shutil.copytree(os.path.join('out', build_dir, 'Cronet.framework.dSYM'), | 76 shutil.copytree(os.path.join('out', build_dir, framework_name + '.dSYM'), |
77 os.path.join(out_dir, build_dir, 'Cronet.framework.dSYM')) | 77 os.path.join(out_dir, build_dir, |
78 framework_name + '.dSYM')) | |
78 # Copy the version file | 79 # Copy the version file |
79 shutil.copy2('chrome/VERSION', out_dir) | 80 shutil.copy2('chrome/VERSION', out_dir) |
80 # Copy the headers | 81 # Copy the headers |
81 shutil.copytree(os.path.join(out_dir, build_dirs[0], | 82 shutil.copytree(os.path.join(out_dir, build_dirs[0], |
82 'Cronet.framework', 'Headers'), | 83 framework_name, 'Headers'), |
83 os.path.join(out_dir, 'Headers')) | 84 os.path.join(out_dir, 'Headers')) |
84 | 85 |
85 | 86 |
86 def package_ios_framework_using_gn(out_dir='out/Framework', extra_options=''): | 87 def package_ios_framework_using_gn(out_dir='out/Framework', extra_options=''): |
87 print 'Building Cronet Dynamic Framework using gn...' | 88 print 'Building Cronet Dynamic Framework using gn...' |
88 | 89 |
89 # Package all builds in the output directory | 90 # Package all builds in the output directory |
90 os.makedirs(out_dir) | 91 os.makedirs(out_dir) |
91 build_dir = '' | 92 build_dir = '' |
92 for (build_config, gn_extra_args) in [('Debug', 'is_debug=true'), | 93 for (build_config, gn_extra_args) in [('Debug', 'is_debug=true'), |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
127 shutil.copy2(os.path.join(package_dir, 'LICENSE'), out_dir) | 128 shutil.copy2(os.path.join(package_dir, 'LICENSE'), out_dir) |
128 shutil.copy2(os.path.join(package_dir, 'VERSION'), out_dir) | 129 shutil.copy2(os.path.join(package_dir, 'VERSION'), out_dir) |
129 # Copy the headers. | 130 # Copy the headers. |
130 shutil.copytree(os.path.join(build_dir, | 131 shutil.copytree(os.path.join(build_dir, |
131 'Cronet.framework', 'Headers'), | 132 'Cronet.framework', 'Headers'), |
132 os.path.join(out_dir, 'Headers')) | 133 os.path.join(out_dir, 'Headers')) |
133 print 'Cronet dynamic framework is packaged into %s' % out_dir | 134 print 'Cronet dynamic framework is packaged into %s' % out_dir |
134 | 135 |
135 | 136 |
136 def main(): | 137 def main(): |
137 parser = argparse.ArgumentParser() | 138 description = ( |
139 '1. To build Cronet.framework call:\n' | |
140 'package_ios.py --framework out/Frameworks\n' | |
141 '2. To build CrNet.framework call:\n' | |
142 'package_ios.py --crnet out/crnet\n' | |
143 ) | |
144 parser = argparse.ArgumentParser(description=description) | |
145 | |
138 parser.add_argument('out_dir', nargs=1, help='path to output directory') | 146 parser.add_argument('out_dir', nargs=1, help='path to output directory') |
139 parser.add_argument('-g', '--gn', action='store_true', | 147 parser.add_argument('-g', '--gn', action='store_true', |
140 help='build using gn') | 148 help='build using gn') |
141 parser.add_argument('-d', '--debug', action='store_true', | 149 parser.add_argument('-d', '--debug', action='store_true', |
142 help='use release configuration') | 150 help='use release configuration') |
143 parser.add_argument('-r', '--release', action='store_true', | 151 parser.add_argument('-r', '--release', action='store_true', |
144 help='use release configuration') | 152 help='use release configuration') |
145 parser.add_argument('--framework', action='store_true', | 153 parser.add_argument('--framework', action='store_true', |
146 help='build Cronet dynamic framework') | 154 help='build Cronet dynamic framework') |
155 parser.add_argument('--crnet', action='store_true', | |
156 help='build CrNet dynamic framework') | |
157 parser.add_argument('--use_icu', action='store_true', | |
mef
2016/07/22 19:47:06
nit: this is confusing. Option is called 'use_icu'
kapishnikov
2016/07/22 20:20:23
Changed the flag to 'use_full_icu" and changed the
| |
158 help='use platform ICU alternatives. The default is true') | |
147 | 159 |
148 options, extra_options_list = parser.parse_known_args() | 160 options, extra_options_list = parser.parse_known_args() |
149 print options | 161 print options |
150 print extra_options_list | 162 print extra_options_list |
151 | 163 |
152 out_dir = options.out_dir[0] | 164 out_dir = options.out_dir[0] |
153 | 165 |
154 # Make sure that the output directory does not exist | 166 # Make sure that the output directory does not exist |
155 if os.path.exists(out_dir): | 167 if os.path.exists(out_dir): |
156 print >>sys.stderr, 'The output directory already exists: ' + out_dir | 168 print >>sys.stderr, 'The output directory already exists: ' + out_dir |
157 return 1 | 169 return 1 |
158 | 170 |
171 use_platform_icu_alternatives = 'use_platform_icu_alternatives=0 ' \ | |
172 if options.use_icu else 'use_platform_icu_alternatives=1 ' | |
173 | |
159 gyp_defines = 'GYP_DEFINES="OS=ios enable_websockets=0 '+ \ | 174 gyp_defines = 'GYP_DEFINES="OS=ios enable_websockets=0 '+ \ |
160 'disable_file_support=1 disable_ftp_support=1 '+ \ | 175 'disable_file_support=1 disable_ftp_support=1 '+ \ |
161 'enable_errorprone=1 use_platform_icu_alternatives=1 ' + \ | 176 'enable_errorprone=1 disable_brotli_filter=1 chromium_ios_signing=0 ' + \ |
162 'disable_brotli_filter=1 chromium_ios_signing=0 ' + \ | 177 'target_subarch=both ' + use_platform_icu_alternatives + '"' |
163 'target_subarch=both"' | 178 |
164 if not options.gn: | 179 if not options.gn: |
165 run (gyp_defines + ' gclient runhooks') | 180 run (gyp_defines + ' gclient runhooks') |
166 | 181 |
167 if options.framework: | 182 if options.framework: |
168 return package_ios_framework(out_dir, extra_options_list) | 183 return package_ios_framework(out_dir, 'cronet_framework', |
184 'Cronet.framework', extra_options_list) | |
185 | |
186 if options.crnet: | |
187 return package_ios_framework(out_dir, 'crnet_framework', | |
188 'CrNet.framework', extra_options_list) | |
169 | 189 |
170 if options.gn: | 190 if options.gn: |
171 return package_ios_framework_using_gn(out_dir, extra_options_list) | 191 return package_ios_framework_using_gn(out_dir, extra_options_list) |
172 | 192 |
173 return package_ios(out_dir, "out/Release", "opt") or \ | 193 return package_ios(out_dir, "out/Release", "opt") or \ |
174 package_ios(out_dir, "out/Debug", "dbg") | 194 package_ios(out_dir, "out/Debug", "dbg") |
175 | 195 |
176 | 196 |
177 if __name__ == '__main__': | 197 if __name__ == '__main__': |
178 sys.exit(main()) | 198 sys.exit(main()) |
OLD | NEW |