OLD | NEW |
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 import os | 5 import os |
6 import subprocess | 6 import subprocess |
| 7 import sys |
7 | 8 |
8 | 9 |
9 if not os.environ.get('ANDROID_SDK_ROOT'): | 10 if sys.platform == 'linux2' and not os.environ.get('ANDROID_SDK_ROOT'): |
10 # If envsetup.sh hasn't been sourced and there's no adb in the path, | 11 # If envsetup.sh hasn't been sourced and there's no adb in the path, |
11 # set it here. | 12 # set it here. |
12 with file(os.devnull, 'w') as devnull: | 13 try: |
13 ret = subprocess.call(['which', 'adb'], stdout=devnull, stderr=devnull) | 14 with file(os.devnull, 'w') as devnull: |
14 if ret: | 15 subprocess.call(['adb', 'version'], stdout=devnull, stderr=devnull) |
| 16 except OSError: |
15 print 'No adb found in $PATH, fallback to checked in binary.' | 17 print 'No adb found in $PATH, fallback to checked in binary.' |
16 os.environ['PATH'] += os.pathsep + os.path.abspath(os.path.join( | 18 os.environ['PATH'] += os.pathsep + os.path.abspath(os.path.join( |
17 os.path.dirname(__file__), | 19 os.path.dirname(__file__), |
18 '..', '..', '..', | 20 '..', '..', '..', |
19 'third_party', 'android_tools', 'sdk', 'platform-tools')) | 21 'third_party', 'android_tools', 'sdk', 'platform-tools')) |
OLD | NEW |