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 # TODO(jbudorick): Split these constants into coherent modules. | 7 # TODO(jbudorick): Split these constants into coherent modules. |
8 | 8 |
9 # pylint: disable=W0212 | 9 # pylint: disable=W0212 |
10 | 10 |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 """ | 237 """ |
238 if 'CHROMIUM_OUTPUT_DIR' in os.environ: | 238 if 'CHROMIUM_OUTPUT_DIR' in os.environ: |
239 return os.path.abspath(os.path.join( | 239 return os.path.abspath(os.path.join( |
240 DIR_SOURCE_ROOT, os.environ.get('CHROMIUM_OUTPUT_DIR'))) | 240 DIR_SOURCE_ROOT, os.environ.get('CHROMIUM_OUTPUT_DIR'))) |
241 | 241 |
242 return os.path.abspath(os.path.join( | 242 return os.path.abspath(os.path.join( |
243 DIR_SOURCE_ROOT, os.environ.get('CHROMIUM_OUT_DIR', 'out'), | 243 DIR_SOURCE_ROOT, os.environ.get('CHROMIUM_OUT_DIR', 'out'), |
244 GetBuildType() if build_type is None else build_type)) | 244 GetBuildType() if build_type is None else build_type)) |
245 | 245 |
246 | 246 |
| 247 def CheckOutputDirectory(): |
| 248 """Checks that CHROMIUM_OUT_DIR or CHROMIUM_OUTPUT_DIR is set. |
| 249 |
| 250 If neither are set, but the current working directory is a build directory, |
| 251 then CHROMIUM_OUTPUT_DIR is set to the current working directory. |
| 252 |
| 253 Raises: |
| 254 Exception: If no output directory is detected. |
| 255 """ |
| 256 output_dir = os.environ.get('CHROMIUM_OUTPUT_DIR') |
| 257 out_dir = os.environ.get('CHROMIUM_OUT_DIR') |
| 258 if not output_dir and not out_dir: |
| 259 # If CWD is an output directory, then assume it's the desired one. |
| 260 if os.path.exists('build.ninja'): |
| 261 output_dir = os.getcwd() |
| 262 SetOutputDirectory(output_dir) |
| 263 else: |
| 264 raise Exception('Neither CHROMIUM_OUTPUT_DIR nor CHROMIUM_OUT_DIR ' |
| 265 'has been set') |
| 266 |
| 267 |
247 # TODO(jbudorick): Convert existing callers to AdbWrapper.GetAdbPath() and | 268 # TODO(jbudorick): Convert existing callers to AdbWrapper.GetAdbPath() and |
248 # remove this. | 269 # remove this. |
249 def GetAdbPath(): | 270 def GetAdbPath(): |
250 from devil.android.sdk import adb_wrapper | 271 from devil.android.sdk import adb_wrapper |
251 return adb_wrapper.AdbWrapper.GetAdbPath() | 272 return adb_wrapper.AdbWrapper.GetAdbPath() |
252 | 273 |
253 | 274 |
254 # Exit codes | 275 # Exit codes |
255 ERROR_EXIT_CODE = exit_codes.ERROR | 276 ERROR_EXIT_CODE = exit_codes.ERROR |
256 INFRA_EXIT_CODE = exit_codes.INFRA | 277 INFRA_EXIT_CODE = exit_codes.INFRA |
257 WARNING_EXIT_CODE = exit_codes.WARNING | 278 WARNING_EXIT_CODE = exit_codes.WARNING |
OLD | NEW |