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 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 for path in native_libs: | 164 for path in native_libs: |
| 165 basename = os.path.basename(path) | 165 basename = os.path.basename(path) |
| 166 apk_path = 'lib/%s/%s' % (android_abi, basename) | |
| 167 | 166 |
| 168 compress = None | 167 compress = None |
| 169 if (uncompress and os.path.splitext(basename)[1] == '.so'): | 168 if (uncompress and os.path.splitext(basename)[1] == '.so' |
| 169 and 'android_linker' not in basename): | |
|
jbudorick
2016/12/20 21:29:50
This will mean that compress will be None (rather
agrieve
2016/12/21 15:41:40
Yeah, this is the ugly part of the code, but it wa
| |
| 170 compress = False | 170 compress = False |
| 171 # Add prefix to prevent android install from extracting upon install. | |
| 172 basename = 'crazy.' + basename | |
| 171 | 173 |
| 174 apk_path = 'lib/%s/%s' % (android_abi, basename) | |
| 172 build_utils.AddToZipHermetic(out_apk, | 175 build_utils.AddToZipHermetic(out_apk, |
| 173 apk_path, | 176 apk_path, |
| 174 src_path=path, | 177 src_path=path, |
| 175 compress=compress) | 178 compress=compress) |
| 176 | 179 |
| 177 | 180 |
| 178 def main(args): | 181 def main(args): |
| 179 args = build_utils.ExpandFileArgs(args) | 182 args = build_utils.ExpandFileArgs(args) |
| 180 options = _ParseArgs(args) | 183 options = _ParseArgs(args) |
| 181 | 184 |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 258 options.android_abi, | 261 options.android_abi, |
| 259 options.uncompress_shared_libraries) | 262 options.uncompress_shared_libraries) |
| 260 | 263 |
| 261 if options.secondary_android_abi: | 264 if options.secondary_android_abi: |
| 262 _AddNativeLibraries(out_apk, | 265 _AddNativeLibraries(out_apk, |
| 263 secondary_native_libs, | 266 secondary_native_libs, |
| 264 options.secondary_android_abi, | 267 options.secondary_android_abi, |
| 265 options.uncompress_shared_libraries) | 268 options.uncompress_shared_libraries) |
| 266 | 269 |
| 267 for name in sorted(options.native_lib_placeholders): | 270 for name in sorted(options.native_lib_placeholders): |
| 268 # Empty libs files are ignored by md5check, but rezip requires them | 271 # Note: Empty libs files are ignored by md5check (can cause issues |
| 269 # to be empty in order to identify them as placeholders. | 272 # with stale builds when the only change is adding/removing |
| 273 # placeholders). | |
| 270 apk_path = 'lib/%s/%s' % (options.android_abi, name) | 274 apk_path = 'lib/%s/%s' % (options.android_abi, name) |
| 271 build_utils.AddToZipHermetic(out_apk, apk_path, data='') | 275 build_utils.AddToZipHermetic(out_apk, apk_path, data='') |
| 272 | 276 |
| 273 # 5. Resources | 277 # 5. Resources |
| 274 for info in resource_infos[1:]: | 278 for info in resource_infos[1:]: |
| 275 copy_resource(info) | 279 copy_resource(info) |
| 276 | 280 |
| 277 # 6. Java resources. Used only when coverage is enabled, so order | 281 # 6. Java resources. Used only when coverage is enabled, so order |
| 278 # doesn't matter). | 282 # doesn't matter). |
| 279 if options.emma_device_jar: | 283 if options.emma_device_jar: |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 302 on_stale_md5, | 306 on_stale_md5, |
| 303 options, | 307 options, |
| 304 input_paths=input_paths, | 308 input_paths=input_paths, |
| 305 input_strings=input_strings, | 309 input_strings=input_strings, |
| 306 output_paths=[options.output_apk], | 310 output_paths=[options.output_apk], |
| 307 depfile_deps=depfile_deps) | 311 depfile_deps=depfile_deps) |
| 308 | 312 |
| 309 | 313 |
| 310 if __name__ == '__main__': | 314 if __name__ == '__main__': |
| 311 main(sys.argv[1:]) | 315 main(sys.argv[1:]) |
| OLD | NEW |