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 os | 5 import os |
6 import stat | 6 import stat |
7 | 7 |
8 from telemetry import decorators | 8 from telemetry import decorators |
9 from telemetry.util import cloud_storage | 9 from telemetry.util import cloud_storage |
10 from telemetry.util import path | 10 from telemetry.util import path |
11 | 11 |
12 | 12 |
13 def _GetBinPath(binary_name, arch_name, platform_name): | 13 def _GetBinPath(binary_name, arch_name, platform_name): |
14 return os.path.join( | 14 return os.path.join( |
15 path.GetTelemetryDir(), 'bin', platform_name, arch_name, binary_name) | 15 path.GetTelemetryDir(), 'bin', platform_name, arch_name, binary_name) |
16 | 16 |
17 | 17 |
18 def _IsInCloudStorage(binary_name, arch_name, platform_name): | 18 def _IsInCloudStorage(binary_name, arch_name, platform_name): |
19 return os.path.exists( | 19 return os.path.exists( |
20 _GetBinPath(binary_name, arch_name, platform_name) + '.sha1') | 20 _GetBinPath(binary_name, arch_name, platform_name) + '.sha1') |
21 | 21 |
22 | 22 |
23 @decorators.Cache | 23 @decorators.Cache |
24 def FindLocallyBuiltPath(binary_name): | 24 def FindLocallyBuiltPath(binary_name): |
25 """Finds the most recently built |binary_name|.""" | 25 """Finds the most recently built |binary_name|.""" |
26 command = None | 26 command = None |
27 command_mtime = 0 | 27 command_mtime = 0 |
28 chrome_root = path.GetChromiumSrcDir() | 28 chrome_root = path.GetChromiumSrcDir() |
29 required_mode = os.X_OK | 29 required_mode = os.X_OK |
30 if binary_name.endswith('.apk'): | 30 if binary_name.endswith('.apk') or binary_name.endswith('.so'): |
31 required_mode = os.R_OK | 31 required_mode = os.R_OK |
32 for build_dir, build_type in path.GetBuildDirectories(): | 32 for build_dir, build_type in path.GetBuildDirectories(): |
33 candidate = os.path.join(chrome_root, build_dir, build_type, binary_name) | 33 candidate = os.path.join(chrome_root, build_dir, build_type, binary_name) |
34 if os.path.isfile(candidate) and os.access(candidate, required_mode): | 34 if os.path.isfile(candidate) and os.access(candidate, required_mode): |
35 candidate_mtime = os.stat(candidate).st_mtime | 35 candidate_mtime = os.stat(candidate).st_mtime |
36 if candidate_mtime > command_mtime: | 36 if candidate_mtime > command_mtime: |
37 command = candidate | 37 command = candidate |
38 command_mtime = candidate_mtime | 38 command_mtime = candidate_mtime |
39 return command | 39 return command |
40 | 40 |
(...skipping 12 matching lines...) Expand all Loading... |
53 | 53 |
54 # Ensure the downloaded file is actually executable. | 54 # Ensure the downloaded file is actually executable. |
55 if command and os.path.exists(command): | 55 if command and os.path.exists(command): |
56 os.chmod(command, | 56 os.chmod(command, |
57 stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR | stat.S_IRGRP) | 57 stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR | stat.S_IRGRP) |
58 | 58 |
59 # Return an absolute path consistently. | 59 # Return an absolute path consistently. |
60 if command: | 60 if command: |
61 command = os.path.abspath(command) | 61 command = os.path.abspath(command) |
62 return command | 62 return command |
OLD | NEW |