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

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: inline constant 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
« no previous file with comments | « build/android/pylib/android_commands.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/android/pylib/constants.py
diff --git a/build/android/pylib/constants.py b/build/android/pylib/constants.py
index f63414e2c859e8c9ffd84a49ed8212c91da5c6aa..dfafa711d4b7057b0d8afa5a267cb72fcea56e5c 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,20 @@ 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'
+
+
+def _GetADBPath():
+ if os.environ.get('ANDROID_SDK_ROOT'):
+ return '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)
+ return 'adb'
+ except OSError:
+ print 'No adb found in $PATH, fallback to checked in binary.'
+ return os.path.join(ANDROID_SDK_ROOT, 'platform-tools', 'adb')
+
+
+ADB_PATH = _GetADBPath()
« no previous file with comments | « build/android/pylib/android_commands.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698