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

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

Issue 2170643002: [Cronet] Better GN for Cronet on iOS. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove spurious period. 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 | « components/cronet/tools/cr_cronet.py ('k') | 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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 'Cronet.framework', 'Headers'), 82 'Cronet.framework', 'Headers'),
83 os.path.join(out_dir, 'Headers')) 83 os.path.join(out_dir, 'Headers'))
84 84
85 85
86 def package_ios_framework_using_gn(out_dir='out/Framework', extra_options=''): 86 def package_ios_framework_using_gn(out_dir='out/Framework', extra_options=''):
87 print 'Building Cronet Dynamic Framework using gn...' 87 print 'Building Cronet Dynamic Framework using gn...'
88 88
89 # Package all builds in the output directory 89 # Package all builds in the output directory
90 os.makedirs(out_dir) 90 os.makedirs(out_dir)
91 build_dir = '' 91 build_dir = ''
92 for (build_config, is_debug) in [('Debug', 'true'), 92 for (build_config, gn_extra_args) in [('Debug', 'is_debug=true'),
93 ('Release', 'false')]: 93 ('Release', 'is_debug=false enable_dsyms=true enable_stripping=true')]:
94 for (target_device, target_cpus) in [('simulator', ['x86', 'x64']), 94 for (target_device, target_cpu, additional_cpu) in [('os', 'arm', 'arm64'),
95 ('os', ['arm', 'arm64'])]: 95 ('simulator', 'x86', 'x64')]:
96 build_dirs = [] 96 target_dir = '%s-iphone%s' % (build_config, target_device)
97 # Build every architecture separately until gn supports fat builds. 97 build_dir = os.path.join("out", target_dir)
98 for target_cpu in target_cpus: 98 gn_args = 'target_os="ios" enable_websockets=false ' \
99 build_dir = 'out/cronet_%s_%s' % (build_config, target_cpu) 99 'disable_file_support=true disable_ftp_support=true ' \
100 build_dirs.append(build_dir) 100 'use_platform_icu_alternatives=true ' \
101 gn_args = 'target_os="ios" enable_websockets=false ' \ 101 'disable_brotli_filter=true ' \
102 'disable_file_support=true disable_ftp_support=true ' \ 102 'target_cpu="%s" additional_target_cpus = ["%s"] %s' % \
103 'use_platform_icu_alternatives=true ' \ 103 (target_cpu, additional_cpu, gn_extra_args)
104 'disable_brotli_filter=true ' \
105 'target_cpu="%s" is_debug=%s' % (target_cpu, is_debug)
106 104
107 print 'Generating Ninja ' + gn_args 105 print 'Generating Ninja ' + gn_args
108 gn_result = run('gn gen %s --args=\'%s\'' % (build_dir, gn_args)) 106 gn_result = run('gn gen %s --args=\'%s\'' % (build_dir, gn_args))
109 if gn_result != 0: 107 if gn_result != 0:
110 return gn_result 108 return gn_result
111 109
112 print 'Building ' + build_dir 110 print 'Building ' + build_dir
113 build_result = run('ninja -C %s cronet_package' % build_dir, 111 build_result = run('ninja -C %s cronet_package' % build_dir,
114 extra_options) 112 extra_options)
115 if build_result != 0: 113 if build_result != 0:
116 return build_result 114 return build_result
117 115
118 # Copy first framework. 116 # Copy framework.
119 target_dir = '%s-iphone%s' % (build_config, target_device) 117 shutil.copytree(os.path.join(build_dir, 'Cronet.framework'),
120 shutil.copytree(os.path.join(build_dirs[0], 'Cronet.framework'),
121 os.path.join(out_dir, target_dir, 'Cronet.framework')) 118 os.path.join(out_dir, target_dir, 'Cronet.framework'))
122 # Lipo first and second cpu. 119 # Copy symbols from release binaries.
123 lipo_result = run('lipo -create %s %s -output %s' %
124 (os.path.join(build_dirs[0], 'Cronet.framework/Cronet'),
125 os.path.join(build_dirs[1], 'Cronet.framework/Cronet'),
126 os.path.join(out_dir, target_dir, 'Cronet.framework/Cronet')))
127 if lipo_result != 0:
128 return lipo_result
129 # Extract and strip symbols from release binaries.
130 if 'Release' in build_config: 120 if 'Release' in build_config:
131 run('dsymutil -o=%s -minimize %s' % 121 shutil.copytree(os.path.join(build_dir, 'Cronet.dSYM'),
132 (os.path.join(out_dir, target_dir, 'Cronet.framework.dSYM'), 122 os.path.join(out_dir, target_dir, 'Cronet.framework.dSYM'))
133 os.path.join(out_dir, target_dir, 'Cronet.framework/Cronet')))
134 run('strip -x %s' %
135 os.path.join(out_dir, target_dir, 'Cronet.framework/Cronet'))
136 123
137 # Copy common files from last built package. 124 # Copy common files from last built package.
138 package_dir = os.path.join(build_dir, 'cronet') 125 package_dir = os.path.join(build_dir, 'cronet')
139 shutil.copy2(os.path.join(package_dir, 'AUTHORS'), out_dir) 126 shutil.copy2(os.path.join(package_dir, 'AUTHORS'), out_dir)
140 shutil.copy2(os.path.join(package_dir, 'LICENSE'), out_dir) 127 shutil.copy2(os.path.join(package_dir, 'LICENSE'), out_dir)
141 shutil.copy2(os.path.join(package_dir, 'VERSION'), out_dir) 128 shutil.copy2(os.path.join(package_dir, 'VERSION'), out_dir)
142 # Copy the headers 129 # Copy the headers.
143 shutil.copytree(os.path.join(build_dir, 130 shutil.copytree(os.path.join(build_dir,
144 'Cronet.framework', 'Headers'), 131 'Cronet.framework', 'Headers'),
145 os.path.join(out_dir, 'Headers')) 132 os.path.join(out_dir, 'Headers'))
146 print 'Cronet dynamic framework is packaged into %s' % out_dir 133 print 'Cronet dynamic framework is packaged into %s' % out_dir
147 134
148 135
149 def main(): 136 def main():
150 parser = argparse.ArgumentParser() 137 parser = argparse.ArgumentParser()
151 parser.add_argument('out_dir', nargs=1, help='path to output directory') 138 parser.add_argument('out_dir', nargs=1, help='path to output directory')
152 parser.add_argument('-g', '--gn', action='store_true', 139 parser.add_argument('-g', '--gn', action='store_true',
(...skipping 29 matching lines...) Expand all
182 169
183 if options.gn: 170 if options.gn:
184 return package_ios_framework_using_gn(out_dir, extra_options_list) 171 return package_ios_framework_using_gn(out_dir, extra_options_list)
185 172
186 return package_ios(out_dir, "out/Release", "opt") or \ 173 return package_ios(out_dir, "out/Release", "opt") or \
187 package_ios(out_dir, "out/Debug", "dbg") 174 package_ios(out_dir, "out/Debug", "dbg")
188 175
189 176
190 if __name__ == '__main__': 177 if __name__ == '__main__':
191 sys.exit(main()) 178 sys.exit(main())
OLDNEW
« no previous file with comments | « components/cronet/tools/cr_cronet.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698