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

Unified Diff: build/android/gyp/apkbuilder.py

Issue 1452843002: Use hermetic timestamps in apkbuilder.py and refactor helper function (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 5 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | build/android/gyp/java_cpp_enum.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/android/gyp/apkbuilder.py
diff --git a/build/android/gyp/apkbuilder.py b/build/android/gyp/apkbuilder.py
index 7e0ce2303dc31f6b7ac3677a325aab3a3ef1b9b5..1837fd615f04df69d604e6604c48e6f33843d48b 100755
--- a/build/android/gyp/apkbuilder.py
+++ b/build/android/gyp/apkbuilder.py
@@ -92,16 +92,13 @@ def _AddAssets(apk, paths, disable_compression=False):
"""
# Group all uncompressed assets together in the hope that it will increase
# locality of mmap'ed files.
- for target_compress_type in (zipfile.ZIP_STORED, zipfile.ZIP_DEFLATED):
+ for target_compress in (False, True):
for path in paths:
src_path, dest_path = _SplitAssetPath(path)
- compress_type = zipfile.ZIP_DEFLATED
- if disable_compression or (
- os.path.splitext(src_path)[1] in _NO_COMPRESS_EXTENSIONS):
- compress_type = zipfile.ZIP_STORED
-
- if target_compress_type == compress_type:
+ compress = not disable_compression and (
+ os.path.splitext(src_path)[1] not in _NO_COMPRESS_EXTENSIONS)
+ if target_compress == compress:
apk_path = 'assets/' + dest_path
try:
apk.getinfo(apk_path)
@@ -109,7 +106,8 @@ def _AddAssets(apk, paths, disable_compression=False):
raise Exception('Multiple targets specified the asset path: %s' %
apk_path)
except KeyError:
- apk.write(src_path, apk_path, compress_type)
+ build_utils.AddToZipHermetic(apk, apk_path, src_path=src_path,
+ compress=compress)
def main(args):
@@ -148,36 +146,39 @@ def main(args):
_AddAssets(apk, options.uncompressed_assets, disable_compression=True)
for path in native_libs:
basename = os.path.basename(path)
- apk.write(path, 'lib/%s/%s' % (options.android_abi, basename))
+ apk_path = 'lib/%s/%s' % (options.android_abi, basename)
+ build_utils.AddToZipHermetic(apk, apk_path, src_path=path)
+
for name in options.native_lib_placeholders:
# Make it non-empty so that its checksum is non-zero and is not
# ignored by md5_check.
- apk.writestr('lib/%s/%s' % (options.android_abi, name), ':)',
- zipfile.ZIP_STORED)
- if options.dex_file:
- if options.dex_file.endswith('.zip'):
- with zipfile.ZipFile(options.dex_file, 'r') as dex_zip:
- for dex in (d for d in dex_zip.namelist() if d.endswith('.dex')):
- apk.writestr(dex, dex_zip.read(dex))
- else:
- apk.write(options.dex_file, 'classes.dex')
+ apk_path = 'lib/%s/%s.so' % (options.android_abi, name)
+ build_utils.AddToZipHermetic(apk, apk_path, data=':)')
+
+ if options.dex_file and options.dex_file.endswith('.zip'):
+ with zipfile.ZipFile(options.dex_file, 'r') as dex_zip:
+ for dex in (d for d in dex_zip.namelist() if d.endswith('.dex')):
+ build_utils.AddToZipHermetic(apk, dex, data=dex_zip.read(dex))
+ elif options.dex_file:
+ build_utils.AddToZipHermetic(apk, 'classes.dex',
+ src_path=options.dex_file)
if options.emma_device_jar:
# Add EMMA Java resources to APK.
with zipfile.ZipFile(options.emma_device_jar, 'r') as emma_device_jar:
- for emma_device_jar_entry in emma_device_jar.namelist():
- entry_name_lower = emma_device_jar_entry.lower()
- if entry_name_lower.startswith('meta-inf/'):
+ for apk_path in emma_device_jar.namelist():
+ apk_path_lower = apk_path.lower()
+ if apk_path_lower.startswith('meta-inf/'):
continue
- if entry_name_lower.endswith('/'):
+ if apk_path_lower.endswith('/'):
continue
- if entry_name_lower.endswith('.class'):
+ if apk_path_lower.endswith('.class'):
continue
- apk.writestr(emma_device_jar_entry,
- emma_device_jar.read(emma_device_jar_entry))
+ build_utils.AddToZipHermetic(apk, apk_path,
+ data=emma_device_jar.read(apk_path))
shutil.move(tmp_apk, options.output_apk)
finally:
« no previous file with comments | « no previous file | build/android/gyp/java_cpp_enum.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698