Chromium Code Reviews| 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 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 139 _AddAssets(apk, options.assets, disable_compression=False) | 139 _AddAssets(apk, options.assets, disable_compression=False) |
| 140 _AddAssets(apk, options.uncompressed_assets, disable_compression=True) | 140 _AddAssets(apk, options.uncompressed_assets, disable_compression=True) |
| 141 for path in native_libs: | 141 for path in native_libs: |
| 142 basename = os.path.basename(path) | 142 basename = os.path.basename(path) |
| 143 apk.write(path, 'lib/%s/%s' % (options.android_abi, basename)) | 143 apk.write(path, 'lib/%s/%s' % (options.android_abi, basename)) |
| 144 if options.create_placeholder_lib: | 144 if options.create_placeholder_lib: |
| 145 # Make it non-empty so that its checksum is non-zero and is not | 145 # Make it non-empty so that its checksum is non-zero and is not |
| 146 # ignored by md5_check. | 146 # ignored by md5_check. |
| 147 apk.writestr('lib/%s/libplaceholder.so' % options.android_abi, ':-)') | 147 apk.writestr('lib/%s/libplaceholder.so' % options.android_abi, ':-)') |
| 148 if options.dex_file: | 148 if options.dex_file: |
| 149 apk.write(options.dex_file, 'classes.dex') | 149 if (options.dex_file.endswith('.zip') |
| 150 and zipfile.is_zipfile(options.dex_file)): | |
|
agrieve
2015/11/16 19:02:33
nit: stands out a bit to me. Probably checking the
jbudorick
2015/11/16 20:45:56
Done.
| |
| 151 with zipfile.ZipFile(options.dex_file, 'r') as dex_zip: | |
| 152 for dex in (d for d in dex_zip.namelist() if d.endswith('.dex')): | |
| 153 apk.writestr(dex, dex_zip.read(dex)) | |
| 154 else: | |
| 155 apk.write(options.dex_file, 'classes.dex') | |
| 150 | 156 |
| 151 shutil.move(tmp_apk, options.output_apk) | 157 shutil.move(tmp_apk, options.output_apk) |
| 152 finally: | 158 finally: |
| 153 if os.path.exists(tmp_apk): | 159 if os.path.exists(tmp_apk): |
| 154 os.unlink(tmp_apk) | 160 os.unlink(tmp_apk) |
| 155 | 161 |
| 156 build_utils.CallAndWriteDepfileIfStale( | 162 build_utils.CallAndWriteDepfileIfStale( |
| 157 on_stale_md5, | 163 on_stale_md5, |
| 158 options, | 164 options, |
| 159 input_paths=input_paths, | 165 input_paths=input_paths, |
| 160 input_strings=input_strings, | 166 input_strings=input_strings, |
| 161 output_paths=[options.output_apk]) | 167 output_paths=[options.output_apk]) |
| 162 | 168 |
| 163 | 169 |
| 164 if __name__ == '__main__': | 170 if __name__ == '__main__': |
| 165 main(sys.argv[1:]) | 171 main(sys.argv[1:]) |
| OLD | NEW |