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