| 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 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 | 154 |
| 155 | 155 |
| 156 def _CreateAssetsList(path_tuples): | 156 def _CreateAssetsList(path_tuples): |
| 157 """Returns a newline-separated list of asset paths for the given paths.""" | 157 """Returns a newline-separated list of asset paths for the given paths.""" |
| 158 dests = sorted(t[1] for t in path_tuples) | 158 dests = sorted(t[1] for t in path_tuples) |
| 159 return '\n'.join(dests) + '\n' | 159 return '\n'.join(dests) + '\n' |
| 160 | 160 |
| 161 | 161 |
| 162 def _AddNativeLibraries(out_apk, native_libs, android_abi, uncompress): | 162 def _AddNativeLibraries(out_apk, native_libs, android_abi, uncompress): |
| 163 """Add native libraries to APK.""" | 163 """Add native libraries to APK.""" |
| 164 has_crazy_linker = any('android_linker' in os.path.basename(p) | |
| 165 for p in native_libs) | |
| 166 for path in native_libs: | 164 for path in native_libs: |
| 167 basename = os.path.basename(path) | 165 basename = os.path.basename(path) |
| 166 apk_path = 'lib/%s/%s' % (android_abi, basename) |
| 168 | 167 |
| 169 compress = None | 168 compress = None |
| 170 if (uncompress and os.path.splitext(basename)[1] == '.so' | 169 if (uncompress and os.path.splitext(basename)[1] == '.so'): |
| 171 and 'android_linker' not in basename): | |
| 172 compress = False | 170 compress = False |
| 173 # Add prefix to prevent android install from extracting upon install. | |
| 174 if has_crazy_linker: | |
| 175 basename = 'crazy.' + basename | |
| 176 | 171 |
| 177 apk_path = 'lib/%s/%s' % (android_abi, basename) | |
| 178 build_utils.AddToZipHermetic(out_apk, | 172 build_utils.AddToZipHermetic(out_apk, |
| 179 apk_path, | 173 apk_path, |
| 180 src_path=path, | 174 src_path=path, |
| 181 compress=compress) | 175 compress=compress) |
| 182 | 176 |
| 183 | 177 |
| 184 def main(args): | 178 def main(args): |
| 185 args = build_utils.ExpandFileArgs(args) | 179 args = build_utils.ExpandFileArgs(args) |
| 186 options = _ParseArgs(args) | 180 options = _ParseArgs(args) |
| 187 | 181 |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 264 options.android_abi, | 258 options.android_abi, |
| 265 options.uncompress_shared_libraries) | 259 options.uncompress_shared_libraries) |
| 266 | 260 |
| 267 if options.secondary_android_abi: | 261 if options.secondary_android_abi: |
| 268 _AddNativeLibraries(out_apk, | 262 _AddNativeLibraries(out_apk, |
| 269 secondary_native_libs, | 263 secondary_native_libs, |
| 270 options.secondary_android_abi, | 264 options.secondary_android_abi, |
| 271 options.uncompress_shared_libraries) | 265 options.uncompress_shared_libraries) |
| 272 | 266 |
| 273 for name in sorted(options.native_lib_placeholders): | 267 for name in sorted(options.native_lib_placeholders): |
| 274 # Note: Empty libs files are ignored by md5check (can cause issues | 268 # Empty libs files are ignored by md5check, but rezip requires them |
| 275 # with stale builds when the only change is adding/removing | 269 # to be empty in order to identify them as placeholders. |
| 276 # placeholders). | |
| 277 apk_path = 'lib/%s/%s' % (options.android_abi, name) | 270 apk_path = 'lib/%s/%s' % (options.android_abi, name) |
| 278 build_utils.AddToZipHermetic(out_apk, apk_path, data='') | 271 build_utils.AddToZipHermetic(out_apk, apk_path, data='') |
| 279 | 272 |
| 280 # 5. Resources | 273 # 5. Resources |
| 281 for info in resource_infos[1:]: | 274 for info in resource_infos[1:]: |
| 282 copy_resource(info) | 275 copy_resource(info) |
| 283 | 276 |
| 284 # 6. Java resources. Used only when coverage is enabled, so order | 277 # 6. Java resources. Used only when coverage is enabled, so order |
| 285 # doesn't matter). | 278 # doesn't matter). |
| 286 if options.emma_device_jar: | 279 if options.emma_device_jar: |
| (...skipping 22 matching lines...) Expand all Loading... |
| 309 on_stale_md5, | 302 on_stale_md5, |
| 310 options, | 303 options, |
| 311 input_paths=input_paths, | 304 input_paths=input_paths, |
| 312 input_strings=input_strings, | 305 input_strings=input_strings, |
| 313 output_paths=[options.output_apk], | 306 output_paths=[options.output_apk], |
| 314 depfile_deps=depfile_deps) | 307 depfile_deps=depfile_deps) |
| 315 | 308 |
| 316 | 309 |
| 317 if __name__ == '__main__': | 310 if __name__ == '__main__': |
| 318 main(sys.argv[1:]) | 311 main(sys.argv[1:]) |
| OLD | NEW |