Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(64)

Side by Side Diff: components/cronet/tools/package_ios.py

Issue 2179543002: CrNet framework packaging script (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Changed -use_icu flag Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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_full_icu', action='store_true',
158 help='use full version of ICU instead of \
159 platform ICU alternative.')
147 160
148 options, extra_options_list = parser.parse_known_args() 161 options, extra_options_list = parser.parse_known_args()
149 print options 162 print options
150 print extra_options_list 163 print extra_options_list
151 164
152 out_dir = options.out_dir[0] 165 out_dir = options.out_dir[0]
153 166
154 # Make sure that the output directory does not exist 167 # Make sure that the output directory does not exist
155 if os.path.exists(out_dir): 168 if os.path.exists(out_dir):
156 print >>sys.stderr, 'The output directory already exists: ' + out_dir 169 print >>sys.stderr, 'The output directory already exists: ' + out_dir
157 return 1 170 return 1
158 171
172 use_platform_icu_alternatives = 'use_platform_icu_alternatives=0 ' \
mef 2016/07/22 20:30:00 nit: maybe rephrase it: use_platform_icu_alternat
173 if options.use_full_icu else 'use_platform_icu_alternatives=1 '
174
159 gyp_defines = 'GYP_DEFINES="OS=ios enable_websockets=0 '+ \ 175 gyp_defines = 'GYP_DEFINES="OS=ios enable_websockets=0 '+ \
160 'disable_file_support=1 disable_ftp_support=1 '+ \ 176 'disable_file_support=1 disable_ftp_support=1 '+ \
161 'enable_errorprone=1 use_platform_icu_alternatives=1 ' + \ 177 'enable_errorprone=1 disable_brotli_filter=1 chromium_ios_signing=0 ' + \
162 'disable_brotli_filter=1 chromium_ios_signing=0 ' + \ 178 'target_subarch=both ' + use_platform_icu_alternatives + '"'
163 'target_subarch=both"' 179
164 if not options.gn: 180 if not options.gn:
165 run (gyp_defines + ' gclient runhooks') 181 run (gyp_defines + ' gclient runhooks')
166 182
167 if options.framework: 183 if options.framework:
168 return package_ios_framework(out_dir, extra_options_list) 184 return package_ios_framework(out_dir, 'cronet_framework',
185 'Cronet.framework', extra_options_list)
186
187 if options.crnet:
188 return package_ios_framework(out_dir, 'crnet_framework',
189 'CrNet.framework', extra_options_list)
169 190
170 if options.gn: 191 if options.gn:
171 return package_ios_framework_using_gn(out_dir, extra_options_list) 192 return package_ios_framework_using_gn(out_dir, extra_options_list)
172 193
173 return package_ios(out_dir, "out/Release", "opt") or \ 194 return package_ios(out_dir, "out/Release", "opt") or \
174 package_ios(out_dir, "out/Debug", "dbg") 195 package_ios(out_dir, "out/Debug", "dbg")
175 196
176 197
177 if __name__ == '__main__': 198 if __name__ == '__main__':
178 sys.exit(main()) 199 sys.exit(main())
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698