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

Side by Side Diff: build/android/gyp/apkbuilder.py

Issue 1607153002: Fix order of files within APK when built using GN (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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/env python 1 #!/usr/bin/env python
2 # 2 #
3 # Copyright (c) 2015 The Chromium Authors. All rights reserved. 3 # Copyright (c) 2015 The Chromium Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be 4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file. 5 # found in the LICENSE file.
6 6
7 """Adds the code parts to a resource APK.""" 7 """Adds the code parts to a resource APK."""
8 8
9 import argparse 9 import argparse
10 import itertools 10 import itertools
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 186
187 # 2. Assets 187 # 2. Assets
188 if options.write_asset_list: 188 if options.write_asset_list:
189 data = _CreateAssetsList( 189 data = _CreateAssetsList(
190 itertools.chain(_assets, _uncompressed_assets)) 190 itertools.chain(_assets, _uncompressed_assets))
191 build_utils.AddToZipHermetic(out_apk, 'assets/assets_list', data=data) 191 build_utils.AddToZipHermetic(out_apk, 'assets/assets_list', data=data)
192 192
193 _AddAssets(out_apk, _assets, disable_compression=False) 193 _AddAssets(out_apk, _assets, disable_compression=False)
194 _AddAssets(out_apk, _uncompressed_assets, disable_compression=True) 194 _AddAssets(out_apk, _uncompressed_assets, disable_compression=True)
195 195
196 # 3. Resources 196 # 3. Dex files
197 for info in resource_infos[1:]:
198 copy_resource(info)
199
200 # 4. Dex files
201 if options.dex_file and options.dex_file.endswith('.zip'): 197 if options.dex_file and options.dex_file.endswith('.zip'):
202 with zipfile.ZipFile(options.dex_file, 'r') as dex_zip: 198 with zipfile.ZipFile(options.dex_file, 'r') as dex_zip:
203 for dex in (d for d in dex_zip.namelist() if d.endswith('.dex')): 199 for dex in (d for d in dex_zip.namelist() if d.endswith('.dex')):
204 build_utils.AddToZipHermetic(out_apk, dex, data=dex_zip.read(dex)) 200 build_utils.AddToZipHermetic(out_apk, dex, data=dex_zip.read(dex))
205 elif options.dex_file: 201 elif options.dex_file:
206 build_utils.AddToZipHermetic(out_apk, 'classes.dex', 202 build_utils.AddToZipHermetic(out_apk, 'classes.dex',
207 src_path=options.dex_file) 203 src_path=options.dex_file)
208 204
209 # 5. Native libraries. 205 # 4. Native libraries.
210 for path in native_libs: 206 for path in native_libs:
211 basename = os.path.basename(path) 207 basename = os.path.basename(path)
212 apk_path = 'lib/%s/%s' % (options.android_abi, basename) 208 apk_path = 'lib/%s/%s' % (options.android_abi, basename)
213 build_utils.AddToZipHermetic(out_apk, apk_path, src_path=path) 209 build_utils.AddToZipHermetic(out_apk, apk_path, src_path=path)
214 210
215 for name in sorted(options.native_lib_placeholders): 211 for name in sorted(options.native_lib_placeholders):
216 # Empty libs files are ignored by md5check, but rezip requires them 212 # Empty libs files are ignored by md5check, but rezip requires them
217 # to be empty in order to identify them as placeholders. 213 # to be empty in order to identify them as placeholders.
218 apk_path = 'lib/%s/%s' % (options.android_abi, name) 214 apk_path = 'lib/%s/%s' % (options.android_abi, name)
219 build_utils.AddToZipHermetic(out_apk, apk_path, data='') 215 build_utils.AddToZipHermetic(out_apk, apk_path, data='')
220 216
217 # 5. Resources
218 for info in resource_infos[1:]:
219 copy_resource(info)
220
221 # 6. Java resources. Used only when coverage is enabled, so order 221 # 6. Java resources. Used only when coverage is enabled, so order
222 # doesn't matter). 222 # doesn't matter).
223 if options.emma_device_jar: 223 if options.emma_device_jar:
224 # Add EMMA Java resources to APK. 224 # Add EMMA Java resources to APK.
225 with zipfile.ZipFile(options.emma_device_jar, 'r') as emma_device_jar: 225 with zipfile.ZipFile(options.emma_device_jar, 'r') as emma_device_jar:
226 for apk_path in emma_device_jar.namelist(): 226 for apk_path in emma_device_jar.namelist():
227 apk_path_lower = apk_path.lower() 227 apk_path_lower = apk_path.lower()
228 if apk_path_lower.startswith('meta-inf/'): 228 if apk_path_lower.startswith('meta-inf/'):
229 continue 229 continue
230 230
(...skipping 14 matching lines...) Expand all
245 build_utils.CallAndWriteDepfileIfStale( 245 build_utils.CallAndWriteDepfileIfStale(
246 on_stale_md5, 246 on_stale_md5,
247 options, 247 options,
248 input_paths=input_paths, 248 input_paths=input_paths,
249 input_strings=input_strings, 249 input_strings=input_strings,
250 output_paths=[options.output_apk]) 250 output_paths=[options.output_apk])
251 251
252 252
253 if __name__ == '__main__': 253 if __name__ == '__main__':
254 main(sys.argv[1:]) 254 main(sys.argv[1:])
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