Chromium Code Reviews| Index: build/android/pylib/constants.py |
| diff --git a/build/android/pylib/constants.py b/build/android/pylib/constants.py |
| index f63414e2c859e8c9ffd84a49ed8212c91da5c6aa..949250e67e12ffb4bd5ef3476467c8b55553b08a 100644 |
| --- a/build/android/pylib/constants.py |
| +++ b/build/android/pylib/constants.py |
| @@ -5,6 +5,8 @@ |
| """Defines a set of constants shared by test runners and other scripts.""" |
| import os |
| +import subprocess |
| +import sys |
| CHROME_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), |
| @@ -77,3 +79,27 @@ ANDROID_SDK_ROOT = os.path.join(CHROME_DIR, 'third_party/android_tools/sdk') |
| ANDROID_NDK_ROOT = os.path.join(CHROME_DIR, 'third_party/android_tools/ndk') |
| UPSTREAM_FLAKINESS_SERVER = 'test-results.appspot.com' |
| + |
| + |
| +_FULLY_QUALIFIED_ADB = None |
| + |
| + |
| +def GetADBPath(): |
|
frankf
2013/06/04 19:50:47
modules are imported once in python. Can't you jus
bulach
2013/06/05 08:18:27
good idea! inverted here, so the function is inter
|
| + global _FULLY_QUALIFIED_ADB |
| + if _FULLY_QUALIFIED_ADB: |
| + return _FULLY_QUALIFIED_ADB |
| + if os.environ.get('ANDROID_SDK_ROOT'): |
| + _FULLY_QUALIFIED_ADB = 'adb' |
| + return _FULLY_QUALIFIED_ADB |
| + # If envsetup.sh hasn't been sourced and there's no adb in the path, |
| + # set it here. |
| + try: |
| + with file(os.devnull, 'w') as devnull: |
| + subprocess.call(['adb', 'version'], stdout=devnull, stderr=devnull) |
| + _FULLY_QUALIFIED_ADB = 'adb' |
| + except OSError: |
| + print 'No adb found in $PATH, fallback to checked in binary.' |
| + _FULLY_QUALIFIED_ADB = os.path.join( |
| + CHROME_DIR, 'third_party', 'android_tools', 'sdk', 'platform-tools', |
| + 'adb') |
| + return _FULLY_QUALIFIED_ADB |