| OLD | NEW |
| 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 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 _AddAssets(apk, options.uncompressed_assets, disable_compression=True) | 148 _AddAssets(apk, options.uncompressed_assets, disable_compression=True) |
| 149 for path in native_libs: | 149 for path in native_libs: |
| 150 basename = os.path.basename(path) | 150 basename = os.path.basename(path) |
| 151 apk.write(path, 'lib/%s/%s' % (options.android_abi, basename)) | 151 apk.write(path, 'lib/%s/%s' % (options.android_abi, basename)) |
| 152 for name in options.native_lib_placeholders: | 152 for name in options.native_lib_placeholders: |
| 153 # Make it non-empty so that its checksum is non-zero and is not | 153 # Make it non-empty so that its checksum is non-zero and is not |
| 154 # ignored by md5_check. | 154 # ignored by md5_check. |
| 155 apk.writestr('lib/%s/%s' % (options.android_abi, name), ':)', | 155 apk.writestr('lib/%s/%s' % (options.android_abi, name), ':)', |
| 156 zipfile.ZIP_STORED) | 156 zipfile.ZIP_STORED) |
| 157 if options.dex_file: | 157 if options.dex_file: |
| 158 apk.write(options.dex_file, 'classes.dex') | 158 if options.dex_file.endswith('.zip'): |
| 159 with zipfile.ZipFile(options.dex_file, 'r') as dex_zip: |
| 160 for dex in (d for d in dex_zip.namelist() if d.endswith('.dex')): |
| 161 apk.writestr(dex, dex_zip.read(dex)) |
| 162 else: |
| 163 apk.write(options.dex_file, 'classes.dex') |
| 159 | 164 |
| 160 if options.emma_device_jar: | 165 if options.emma_device_jar: |
| 161 # Add EMMA Java resources to APK. | 166 # Add EMMA Java resources to APK. |
| 162 with zipfile.ZipFile(options.emma_device_jar, 'r') as emma_device_jar: | 167 with zipfile.ZipFile(options.emma_device_jar, 'r') as emma_device_jar: |
| 163 for emma_device_jar_entry in emma_device_jar.namelist(): | 168 for emma_device_jar_entry in emma_device_jar.namelist(): |
| 164 entry_name_lower = emma_device_jar_entry.lower() | 169 entry_name_lower = emma_device_jar_entry.lower() |
| 165 if entry_name_lower.startswith('meta-inf/'): | 170 if entry_name_lower.startswith('meta-inf/'): |
| 166 continue | 171 continue |
| 167 | 172 |
| 168 if entry_name_lower.endswith('/'): | 173 if entry_name_lower.endswith('/'): |
| (...skipping 13 matching lines...) Expand all Loading... |
| 182 build_utils.CallAndWriteDepfileIfStale( | 187 build_utils.CallAndWriteDepfileIfStale( |
| 183 on_stale_md5, | 188 on_stale_md5, |
| 184 options, | 189 options, |
| 185 input_paths=input_paths, | 190 input_paths=input_paths, |
| 186 input_strings=input_strings, | 191 input_strings=input_strings, |
| 187 output_paths=[options.output_apk]) | 192 output_paths=[options.output_apk]) |
| 188 | 193 |
| 189 | 194 |
| 190 if __name__ == '__main__': | 195 if __name__ == '__main__': |
| 191 main(sys.argv[1:]) | 196 main(sys.argv[1:]) |
| OLD | NEW |