Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1218)

Unified Diff: build/android/pylib/constants.py

Issue 16360003: Android: allows using adb from a chromium checkout without envsetup.sh (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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():
+ 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
« build/android/pylib/android_commands.py ('K') | « build/android/pylib/android_commands.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698