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 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
200 ] | 200 ] |
201 }, | 201 }, |
202 } | 202 } |
203 | 203 |
204 LOCAL_MACHINE_TESTS = ['junit', 'python'] | 204 LOCAL_MACHINE_TESTS = ['junit', 'python'] |
205 VALID_ENVIRONMENTS = ['local', 'remote_device'] | 205 VALID_ENVIRONMENTS = ['local', 'remote_device'] |
206 VALID_TEST_TYPES = ['gtest', 'instrumentation', 'junit', 'linker', 'monkey', | 206 VALID_TEST_TYPES = ['gtest', 'instrumentation', 'junit', 'linker', 'monkey', |
207 'perf', 'python', 'uirobot'] | 207 'perf', 'python', 'uirobot'] |
208 VALID_DEVICE_TYPES = ['Android', 'iOS'] | 208 VALID_DEVICE_TYPES = ['Android', 'iOS'] |
209 | 209 |
210 # Whether CHROMIUM_OUT_DIR or CHROMIUM_OUTPUT_DIR must be set when calling | |
211 # GetOutDirectory(). Scripts that are called directly by devs are encouraged to | |
212 # enable this in order to eliminate confusion by having the wrong output | |
213 # directory used (http://crbug.com/573345) | |
214 require_explicit_output_dir = False | |
215 | |
210 | 216 |
211 def GetBuildType(): | 217 def GetBuildType(): |
212 try: | 218 try: |
213 return os.environ['BUILDTYPE'] | 219 return os.environ['BUILDTYPE'] |
214 except KeyError: | 220 except KeyError: |
215 raise EnvironmentError( | 221 raise EnvironmentError( |
216 'The BUILDTYPE environment variable has not been set') | 222 'The BUILDTYPE environment variable has not been set') |
217 | 223 |
218 | 224 |
219 def SetBuildType(build_type): | 225 def SetBuildType(build_type): |
220 os.environ['BUILDTYPE'] = build_type | 226 os.environ['BUILDTYPE'] = build_type |
221 | 227 |
222 | 228 |
223 def SetBuildDirectory(build_directory): | 229 def SetBuildDirectory(build_directory): |
224 os.environ['CHROMIUM_OUT_DIR'] = build_directory | 230 os.environ['CHROMIUM_OUT_DIR'] = build_directory |
225 | 231 |
226 | 232 |
227 def SetOutputDirectory(output_directory): | 233 def SetOutputDirectory(output_directory): |
228 os.environ['CHROMIUM_OUTPUT_DIR'] = output_directory | 234 os.environ['CHROMIUM_OUTPUT_DIR'] = output_directory |
229 | 235 |
230 | 236 |
231 def GetOutDirectory(build_type=None): | 237 def GetOutDirectory(build_type=None): |
jbudorick
2016/02/03 14:22:27
I don't think this is the right place to do this v
agrieve
2016/02/03 20:27:17
Done (and I think it looks much nicer now!)
| |
232 """Returns the out directory where the output binaries are built. | 238 """Returns the out directory where the output binaries are built. |
233 | 239 |
234 Args: | 240 Args: |
235 build_type: Build type, generally 'Debug' or 'Release'. Defaults to the | 241 build_type: Build type, generally 'Debug' or 'Release'. Defaults to the |
236 globally set build type environment variable BUILDTYPE. | 242 globally set build type environment variable BUILDTYPE. |
237 """ | 243 """ |
238 if 'CHROMIUM_OUTPUT_DIR' in os.environ: | 244 output_dir = os.environ.get('CHROMIUM_OUTPUT_DIR') |
245 out_dir = os.environ.get('CHROMIUM_OUT_DIR') | |
246 if not output_dir and not out_dir: | |
247 # If CWD is an output directory, then assume it's the desired one. | |
248 if os.path.exists('build.ninja'): | |
249 output_dir = os.getcwd() | |
250 SetOutputDirectory(output_dir) | |
251 | |
252 if output_dir: | |
239 return os.path.abspath(os.path.join( | 253 return os.path.abspath(os.path.join( |
240 DIR_SOURCE_ROOT, os.environ.get('CHROMIUM_OUTPUT_DIR'))) | 254 DIR_SOURCE_ROOT, os.environ.get('CHROMIUM_OUTPUT_DIR'))) |
241 | 255 |
242 return os.path.abspath(os.path.join( | 256 if not out_dir: |
243 DIR_SOURCE_ROOT, os.environ.get('CHROMIUM_OUT_DIR', 'out'), | 257 if require_explicit_output_dir: |
258 raise EnvironmentError('Neither CHROMIUM_OUTPUT_DIR nor CHROMIUM_OUT_DIR ' | |
259 'has been set') | |
260 out_dir = 'out' | |
261 | |
262 return os.path.abspath(os.path.join(DIR_SOURCE_ROOT, out_dir, | |
244 GetBuildType() if build_type is None else build_type)) | 263 GetBuildType() if build_type is None else build_type)) |
245 | 264 |
246 | 265 |
247 # TODO(jbudorick): Convert existing callers to AdbWrapper.GetAdbPath() and | 266 # TODO(jbudorick): Convert existing callers to AdbWrapper.GetAdbPath() and |
248 # remove this. | 267 # remove this. |
249 def GetAdbPath(): | 268 def GetAdbPath(): |
250 from devil.android.sdk import adb_wrapper | 269 from devil.android.sdk import adb_wrapper |
251 return adb_wrapper.AdbWrapper.GetAdbPath() | 270 return adb_wrapper.AdbWrapper.GetAdbPath() |
252 | 271 |
253 | 272 |
254 # Exit codes | 273 # Exit codes |
255 ERROR_EXIT_CODE = exit_codes.ERROR | 274 ERROR_EXIT_CODE = exit_codes.ERROR |
256 INFRA_EXIT_CODE = exit_codes.INFRA | 275 INFRA_EXIT_CODE = exit_codes.INFRA |
257 WARNING_EXIT_CODE = exit_codes.WARNING | 276 WARNING_EXIT_CODE = exit_codes.WARNING |
OLD | NEW |