| OLD | NEW |
| 1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 import glob | 5 import glob |
| 6 import hashlib | 6 import hashlib |
| 7 import logging | 7 import logging |
| 8 import os | 8 import os |
| 9 import platform | 9 import platform |
| 10 import re | 10 import re |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 | 34 |
| 35 def _ElfSectionMd5Sum(elf_file, section): | 35 def _ElfSectionMd5Sum(elf_file, section): |
| 36 result = subprocess.check_output( | 36 result = subprocess.check_output( |
| 37 'readelf -p%s "%s" | md5sum' % (section, elf_file), shell=True) | 37 'readelf -p%s "%s" | md5sum' % (section, elf_file), shell=True) |
| 38 return result.split(' ', 1)[0] | 38 return result.split(' ', 1)[0] |
| 39 | 39 |
| 40 | 40 |
| 41 def _FindMatchingUnstrippedLibraryOnHost(device, lib): | 41 def _FindMatchingUnstrippedLibraryOnHost(device, lib): |
| 42 lib_base = os.path.basename(lib) | 42 lib_base = os.path.basename(lib) |
| 43 | 43 |
| 44 device_md5 = device.RunShellCommand('md5 "%s"' % lib, root=True)[0] | 44 device_md5 = device.RunShellCommand('md5 "%s"' % lib, as_root=True)[0] |
| 45 device_md5 = device_md5.split(' ', 1)[0] | 45 device_md5 = device_md5.split(' ', 1)[0] |
| 46 | 46 |
| 47 def FindMatchingStrippedLibrary(out_path): | 47 def FindMatchingStrippedLibrary(out_path): |
| 48 # First find a matching stripped library on the host. This avoids the need | 48 # First find a matching stripped library on the host. This avoids the need |
| 49 # to pull the stripped library from the device, which can take tens of | 49 # to pull the stripped library from the device, which can take tens of |
| 50 # seconds. | 50 # seconds. |
| 51 host_lib_pattern = os.path.join(out_path, '*_apk', 'libs', '*', lib_base) | 51 host_lib_pattern = os.path.join(out_path, '*_apk', 'libs', '*', lib_base) |
| 52 for stripped_host_lib in glob.glob(host_lib_pattern): | 52 for stripped_host_lib in glob.glob(host_lib_pattern): |
| 53 with open(stripped_host_lib) as f: | 53 with open(stripped_host_lib) as f: |
| 54 host_md5 = hashlib.md5(f.read()).hexdigest() | 54 host_md5 = hashlib.md5(f.read()).hexdigest() |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 return None | 251 return None |
| 252 toolchain_version = toolchain_version.group(1) | 252 toolchain_version = toolchain_version.group(1) |
| 253 | 253 |
| 254 path = os.path.join(util.GetChromiumSrcDir(), 'third_party', 'android_tools', | 254 path = os.path.join(util.GetChromiumSrcDir(), 'third_party', 'android_tools', |
| 255 'ndk', 'toolchains', | 255 'ndk', 'toolchains', |
| 256 '%s-%s' % (toolchain_config, toolchain_version), | 256 '%s-%s' % (toolchain_config, toolchain_version), |
| 257 'prebuilt', '%s-%s' % (host_os, host_machine), 'bin', | 257 'prebuilt', '%s-%s' % (host_os, host_machine), 'bin', |
| 258 '%s-%s' % (toolchain_config, binary_name)) | 258 '%s-%s' % (toolchain_config, binary_name)) |
| 259 path = os.path.abspath(path) | 259 path = os.path.abspath(path) |
| 260 return path if os.path.exists(path) else None | 260 return path if os.path.exists(path) else None |
| OLD | NEW |