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 """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 os | 8 import os |
9 import subprocess | 9 import subprocess |
10 import sys | 10 import sys |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 try: | 125 try: |
126 return os.environ['BUILDTYPE'] | 126 return os.environ['BUILDTYPE'] |
127 except KeyError: | 127 except KeyError: |
128 raise Exception('The BUILDTYPE environment variable has not been set') | 128 raise Exception('The BUILDTYPE environment variable has not been set') |
129 | 129 |
130 | 130 |
131 def SetBuildType(build_type): | 131 def SetBuildType(build_type): |
132 os.environ['BUILDTYPE'] = build_type | 132 os.environ['BUILDTYPE'] = build_type |
133 | 133 |
134 | 134 |
| 135 def GetOutDirectory(build_type=None): |
| 136 """Returns the out directory where the output binaries are built. |
| 137 |
| 138 Args: |
| 139 build_type: Build type, generally 'Debug' or 'Release'. Defaults to the |
| 140 globally set build type environment variable BUILDTYPE. |
| 141 """ |
| 142 return os.path.abspath(os.path.join( |
| 143 DIR_SOURCE_ROOT, os.environ.get('CHROMIUM_OUT_DIR', 'out'), |
| 144 GetBuildType() if build_type is None else build_type)) |
| 145 |
| 146 |
135 def _GetADBPath(): | 147 def _GetADBPath(): |
136 if os.environ.get('ANDROID_SDK_ROOT'): | 148 if os.environ.get('ANDROID_SDK_ROOT'): |
137 return 'adb' | 149 return 'adb' |
138 # If envsetup.sh hasn't been sourced and there's no adb in the path, | 150 # If envsetup.sh hasn't been sourced and there's no adb in the path, |
139 # set it here. | 151 # set it here. |
140 try: | 152 try: |
141 with file(os.devnull, 'w') as devnull: | 153 with file(os.devnull, 'w') as devnull: |
142 subprocess.call(['adb', 'version'], stdout=devnull, stderr=devnull) | 154 subprocess.call(['adb', 'version'], stdout=devnull, stderr=devnull) |
143 return 'adb' | 155 return 'adb' |
144 except OSError: | 156 except OSError: |
145 print >> sys.stderr, 'No adb found in $PATH, fallback to checked in binary.' | 157 print >> sys.stderr, 'No adb found in $PATH, fallback to checked in binary.' |
146 return os.path.join(ANDROID_SDK_ROOT, 'platform-tools', 'adb') | 158 return os.path.join(ANDROID_SDK_ROOT, 'platform-tools', 'adb') |
147 | 159 |
148 | 160 |
149 ADB_PATH = _GetADBPath() | 161 ADB_PATH = _GetADBPath() |
150 | 162 |
151 # Exit codes | 163 # Exit codes |
152 ERROR_EXIT_CODE = 1 | 164 ERROR_EXIT_CODE = 1 |
153 WARNING_EXIT_CODE = 88 | 165 WARNING_EXIT_CODE = 88 |
OLD | NEW |