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

Side by Side Diff: build/android/pylib/constants.py

Issue 117333008: Silence warning about falling back to checked-in adb binary (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « build/android/pylib/android_commands.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2012 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 """Defines a set of constants shared by test runners and other scripts.""" 5 """Defines a set of constants shared by test runners and other scripts."""
6 6
7 import collections 7 import collections
8 import logging
8 import os 9 import os
9 import subprocess 10 import subprocess
10 import sys 11 import sys
11 12
12 13
14 def _Memoize(func):
15 def Wrapper():
16 try:
17 return func._result
frankf 2013/12/18 18:30:27 just curious: why not use hasattr instead of try/e
18 except AttributeError:
19 func._result = func()
20 return func._result
21 return Wrapper
22
23
13 DIR_SOURCE_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), 24 DIR_SOURCE_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__),
14 os.pardir, os.pardir, os.pardir)) 25 os.pardir, os.pardir, os.pardir))
15 ISOLATE_DEPS_DIR = os.path.join(DIR_SOURCE_ROOT, 'isolate_deps_dir') 26 ISOLATE_DEPS_DIR = os.path.join(DIR_SOURCE_ROOT, 'isolate_deps_dir')
16 27
17 CHROMIUM_TEST_SHELL_HOST_DRIVEN_DIR = os.path.join( 28 CHROMIUM_TEST_SHELL_HOST_DRIVEN_DIR = os.path.join(
18 DIR_SOURCE_ROOT, 'chrome', 'android') 29 DIR_SOURCE_ROOT, 'chrome', 'android')
19 30
20 31
21 PackageInfo = collections.namedtuple('PackageInfo', 32 PackageInfo = collections.namedtuple('PackageInfo',
22 ['package', 'activity', 'cmdline_file', 'devtools_socket', 33 ['package', 'activity', 'cmdline_file', 'devtools_socket',
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 162
152 Args: 163 Args:
153 build_type: Build type, generally 'Debug' or 'Release'. Defaults to the 164 build_type: Build type, generally 'Debug' or 'Release'. Defaults to the
154 globally set build type environment variable BUILDTYPE. 165 globally set build type environment variable BUILDTYPE.
155 """ 166 """
156 return os.path.abspath(os.path.join( 167 return os.path.abspath(os.path.join(
157 DIR_SOURCE_ROOT, os.environ.get('CHROMIUM_OUT_DIR', 'out'), 168 DIR_SOURCE_ROOT, os.environ.get('CHROMIUM_OUT_DIR', 'out'),
158 GetBuildType() if build_type is None else build_type)) 169 GetBuildType() if build_type is None else build_type))
159 170
160 171
161 def _GetADBPath(): 172 @_Memoize
173 def GetAdbPath():
162 if os.environ.get('ANDROID_SDK_ROOT'): 174 if os.environ.get('ANDROID_SDK_ROOT'):
163 return 'adb' 175 return 'adb'
164 # If envsetup.sh hasn't been sourced and there's no adb in the path, 176 # If envsetup.sh hasn't been sourced and there's no adb in the path,
165 # set it here. 177 # set it here.
166 try: 178 try:
167 with file(os.devnull, 'w') as devnull: 179 with file(os.devnull, 'w') as devnull:
168 subprocess.call(['adb', 'version'], stdout=devnull, stderr=devnull) 180 subprocess.call(['adb', 'version'], stdout=devnull, stderr=devnull)
169 return 'adb' 181 return 'adb'
170 except OSError: 182 except OSError:
171 print >> sys.stderr, 'No adb found in $PATH, fallback to checked in binary.' 183 logging.debug('No adb found in $PATH, fallback to checked in binary.')
172 return os.path.join(ANDROID_SDK_ROOT, 'platform-tools', 'adb') 184 return os.path.join(ANDROID_SDK_ROOT, 'platform-tools', 'adb')
173 185
174 186
175 ADB_PATH = _GetADBPath()
176
177 # Exit codes 187 # Exit codes
178 ERROR_EXIT_CODE = 1 188 ERROR_EXIT_CODE = 1
179 WARNING_EXIT_CODE = 88 189 WARNING_EXIT_CODE = 88
OLDNEW
« 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