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 os | 7 import os |
8 import subprocess | 8 import subprocess |
9 import sys | 9 import sys |
10 | 10 |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
87 try: | 87 try: |
88 return os.environ['BUILDTYPE'] | 88 return os.environ['BUILDTYPE'] |
89 except KeyError: | 89 except KeyError: |
90 raise Exception('The BUILDTYPE environment variable has not been set') | 90 raise Exception('The BUILDTYPE environment variable has not been set') |
91 | 91 |
92 | 92 |
93 def SetBuildType(build_type): | 93 def SetBuildType(build_type): |
94 os.environ['BUILDTYPE'] = build_type | 94 os.environ['BUILDTYPE'] = build_type |
95 | 95 |
96 | 96 |
97 def GetBuildDirectory(build_type=None): | |
bulach
2013/09/02 09:11:18
hmm... "BuildDirectory" is a bit ambiguous, there'
craigdh
2013/09/03 18:36:09
Done.
| |
98 """Returns the build directory. | |
99 | |
100 Args: | |
101 build_type: Build type, generally 'Debug' or 'Release'. Defaults to the | |
102 globally set build type environment variable BUILDTYPE. | |
103 """ | |
104 return os.path.abspath(os.path.join( | |
105 DIR_SOURCE_ROOT, os.environ.get('CHROMIUM_OUT_DIR', 'out'), | |
frankf
2013/08/27 00:44:57
who sets this?
craigdh
2013/08/27 16:57:17
I'm not sure who overrides the out directory (took
bulach
2013/09/02 09:11:18
yeah, the idea behind this is that we'd eventually
| |
106 GetBuildType() if build_type is None else build_type)) | |
107 | |
108 | |
97 def _GetADBPath(): | 109 def _GetADBPath(): |
98 if os.environ.get('ANDROID_SDK_ROOT'): | 110 if os.environ.get('ANDROID_SDK_ROOT'): |
99 return 'adb' | 111 return 'adb' |
100 # If envsetup.sh hasn't been sourced and there's no adb in the path, | 112 # If envsetup.sh hasn't been sourced and there's no adb in the path, |
101 # set it here. | 113 # set it here. |
102 try: | 114 try: |
103 with file(os.devnull, 'w') as devnull: | 115 with file(os.devnull, 'w') as devnull: |
104 subprocess.call(['adb', 'version'], stdout=devnull, stderr=devnull) | 116 subprocess.call(['adb', 'version'], stdout=devnull, stderr=devnull) |
105 return 'adb' | 117 return 'adb' |
106 except OSError: | 118 except OSError: |
107 print >> sys.stderr, 'No adb found in $PATH, fallback to checked in binary.' | 119 print >> sys.stderr, 'No adb found in $PATH, fallback to checked in binary.' |
108 return os.path.join(ANDROID_SDK_ROOT, 'platform-tools', 'adb') | 120 return os.path.join(ANDROID_SDK_ROOT, 'platform-tools', 'adb') |
109 | 121 |
110 | 122 |
111 ADB_PATH = _GetADBPath() | 123 ADB_PATH = _GetADBPath() |
112 | 124 |
113 # Exit codes | 125 # Exit codes |
114 ERROR_EXIT_CODE = 1 | 126 ERROR_EXIT_CODE = 1 |
115 WARNING_EXIT_CODE = 88 | 127 WARNING_EXIT_CODE = 88 |
OLD | NEW |