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

Side by Side Diff: android_webview/tools/apk_merger.py

Issue 2595233003: Revert of Android: Delete rezip in favor of zipalign -p (Closed)
Patch Set: Created 3 years, 12 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 | « BUILD.gn ('k') | build/android/gyp/apkbuilder.py » ('j') | 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 2014 The Chromium Authors. All rights reserved. 2 # Copyright 2014 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 """ Merges a 64-bit and a 32-bit APK into a single APK 6 """ Merges a 64-bit and a 32-bit APK into a single APK
7 7
8 This script is used to merge two APKs which have only 32-bit or 64-bit 8 This script is used to merge two APKs which have only 32-bit or 64-bit
9 binaries respectively into a APK that has both 32-bit and 64-bit binaries 9 binaries respectively into a APK that has both 32-bit and 64-bit binaries
10 for 64-bit Android platform. 10 for 64-bit Android platform.
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 compress = not uncompress_shared_libraries 128 compress = not uncompress_shared_libraries
129 else: 129 else:
130 compress = expected_files[os.path.basename(diff_file)] 130 compress = expected_files[os.path.basename(diff_file)]
131 build_utils.AddToZipHermetic(out_zip, 131 build_utils.AddToZipHermetic(out_zip,
132 diff_file, 132 diff_file,
133 os.path.join(tmp_dir_32, diff_file), 133 os.path.join(tmp_dir_32, diff_file),
134 compress=compress) 134 compress=compress)
135 135
136 136
137 def SignAndAlignApk(tmp_apk, signed_tmp_apk, new_apk, zipalign_path, 137 def SignAndAlignApk(tmp_apk, signed_tmp_apk, new_apk, zipalign_path,
138 keystore_path, key_name, key_password): 138 keystore_path, key_name, key_password,
139 page_align_shared_libraries):
139 try: 140 try:
140 finalize_apk.JarSigner( 141 finalize_apk.JarSigner(
141 keystore_path, 142 keystore_path,
142 key_name, 143 key_name,
143 key_password, 144 key_password,
144 tmp_apk, 145 tmp_apk,
145 signed_tmp_apk) 146 signed_tmp_apk)
146 except build_utils.CalledProcessError as e: 147 except build_utils.CalledProcessError as e:
147 raise ApkMergeFailure('Failed to sign APK: ' + e.output) 148 raise ApkMergeFailure('Failed to sign APK: ' + e.output)
148 149
149 try: 150 try:
150 finalize_apk.AlignApk(zipalign_path, 151 finalize_apk.AlignApk(zipalign_path,
152 page_align_shared_libraries,
151 signed_tmp_apk, 153 signed_tmp_apk,
152 new_apk) 154 new_apk)
153 except build_utils.CalledProcessError as e: 155 except build_utils.CalledProcessError as e:
154 raise ApkMergeFailure('Failed to align APK: ' + e.output) 156 raise ApkMergeFailure('Failed to align APK: ' + e.output)
155 157
156 def GetSecondaryAbi(apk_zipfile, shared_library): 158 def GetSecondaryAbi(apk_zipfile, shared_library):
157 ret = '' 159 ret = ''
158 for name in apk_zipfile.namelist(): 160 for name in apk_zipfile.namelist():
159 if os.path.basename(name) == shared_library: 161 if os.path.basename(name) == shared_library:
160 abi = re.search('(^lib/)(.+)(/' + shared_library + '$)', name).group(2) 162 abi = re.search('(^lib/)(.+)(/' + shared_library + '$)', name).group(2)
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 # Using type=os.path.abspath converts file paths to absolute paths so that 217 # Using type=os.path.abspath converts file paths to absolute paths so that
216 # we can change working directory without affecting these paths 218 # we can change working directory without affecting these paths
217 parser.add_argument('--apk_32bit', required=True, type=os.path.abspath) 219 parser.add_argument('--apk_32bit', required=True, type=os.path.abspath)
218 parser.add_argument('--apk_64bit', required=True, type=os.path.abspath) 220 parser.add_argument('--apk_64bit', required=True, type=os.path.abspath)
219 parser.add_argument('--out_apk', required=True, type=os.path.abspath) 221 parser.add_argument('--out_apk', required=True, type=os.path.abspath)
220 parser.add_argument('--zipalign_path', required=True, type=os.path.abspath) 222 parser.add_argument('--zipalign_path', required=True, type=os.path.abspath)
221 parser.add_argument('--keystore_path', required=True, type=os.path.abspath) 223 parser.add_argument('--keystore_path', required=True, type=os.path.abspath)
222 parser.add_argument('--key_name', required=True) 224 parser.add_argument('--key_name', required=True)
223 parser.add_argument('--key_password', required=True) 225 parser.add_argument('--key_password', required=True)
224 parser.add_argument('--shared_library') 226 parser.add_argument('--shared_library')
225 parser.add_argument('--page-align-shared-libraries', action='store_true', 227 parser.add_argument('--page-align-shared-libraries', action='store_true')
226 help='Obsolete, but remains for backwards compatibility')
227 parser.add_argument('--uncompress-shared-libraries', action='store_true') 228 parser.add_argument('--uncompress-shared-libraries', action='store_true')
228 parser.add_argument('--debug', action='store_true') 229 parser.add_argument('--debug', action='store_true')
229 # This option shall only used in debug build, see http://crbug.com/631494. 230 # This option shall only used in debug build, see http://crbug.com/631494.
230 parser.add_argument('--ignore-classes-dex', action='store_true') 231 parser.add_argument('--ignore-classes-dex', action='store_true')
231 parser.add_argument('--component-build', action='store_true') 232 parser.add_argument('--component-build', action='store_true')
232 args = parser.parse_args() 233 args = parser.parse_args()
233 234
234 tmp_dir = tempfile.mkdtemp() 235 tmp_dir = tempfile.mkdtemp()
235 tmp_dir_64 = os.path.join(tmp_dir, '64_bit') 236 tmp_dir_64 = os.path.join(tmp_dir, '64_bit')
236 tmp_dir_32 = os.path.join(tmp_dir, '32_bit') 237 tmp_dir_32 = os.path.join(tmp_dir, '32_bit')
237 tmp_apk = os.path.join(tmp_dir, 'tmp.apk') 238 tmp_apk = os.path.join(tmp_dir, 'tmp.apk')
238 signed_tmp_apk = os.path.join(tmp_dir, 'signed.apk') 239 signed_tmp_apk = os.path.join(tmp_dir, 'signed.apk')
239 new_apk = args.out_apk 240 new_apk = args.out_apk
240 241
241 try: 242 try:
242 if args.component_build and args.shared_library: 243 if args.component_build and args.shared_library:
243 raise ApkMergeFailure('--component-build and shared-library shouldn\'t' 244 raise ApkMergeFailure('--component-build and shared-library shouldn\'t'
244 ' be specified at same time.') 245 ' be specified at same time.')
245 if not args.component_build and not args.shared_library: 246 if not args.component_build and not args.shared_library:
246 raise ApkMergeFailure('Either --component-build or shared-library should' 247 raise ApkMergeFailure('Either --component-build or shared-library should'
247 ' be specified.') 248 ' be specified.')
248 249
249 MergeApk(args, tmp_apk, tmp_dir_32, tmp_dir_64) 250 MergeApk(args, tmp_apk, tmp_dir_32, tmp_dir_64)
250 251
251 SignAndAlignApk(tmp_apk, signed_tmp_apk, new_apk, args.zipalign_path, 252 SignAndAlignApk(tmp_apk, signed_tmp_apk, new_apk, args.zipalign_path,
252 args.keystore_path, args.key_name, args.key_password) 253 args.keystore_path, args.key_name, args.key_password,
254 args.page_align_shared_libraries)
253 255
254 except ApkMergeFailure as e: 256 except ApkMergeFailure as e:
255 print e 257 print e
256 return 1 258 return 1
257 finally: 259 finally:
258 shutil.rmtree(tmp_dir) 260 shutil.rmtree(tmp_dir)
259 return 0 261 return 0
260 262
261 263
262 if __name__ == '__main__': 264 if __name__ == '__main__':
263 sys.exit(main()) 265 sys.exit(main())
OLDNEW
« no previous file with comments | « BUILD.gn ('k') | build/android/gyp/apkbuilder.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698