Chromium Code Reviews| 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 logging | 8 import logging |
| 9 import os | 9 import os |
| 10 import subprocess | 10 import subprocess |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 142 try: | 142 try: |
| 143 return os.environ['BUILDTYPE'] | 143 return os.environ['BUILDTYPE'] |
| 144 except KeyError: | 144 except KeyError: |
| 145 raise Exception('The BUILDTYPE environment variable has not been set') | 145 raise Exception('The BUILDTYPE environment variable has not been set') |
| 146 | 146 |
| 147 | 147 |
| 148 def SetBuildType(build_type): | 148 def SetBuildType(build_type): |
| 149 os.environ['BUILDTYPE'] = build_type | 149 os.environ['BUILDTYPE'] = build_type |
| 150 | 150 |
| 151 | 151 |
| 152 def GetOutDirectory(build_type=None): | 152 def GetOutDirectory(build_type=None): |
|
frankf
2014/01/23 00:54:36
Craig changed this recently.
It doesn't make sens
jbudorick
2014/01/24 17:52:51
Would our goal be to have the out directory & buil
| |
| 153 """Returns the out directory where the output binaries are built. | 153 """Returns the out directory where the output binaries are built. |
| 154 | 154 |
| 155 Args: | 155 Args: |
| 156 build_type: Build type, generally 'Debug' or 'Release'. Defaults to the | 156 build_type: Build type, generally 'Debug' or 'Release'. Defaults to the |
| 157 globally set build type environment variable BUILDTYPE. | 157 globally set build type environment variable BUILDTYPE. |
| 158 """ | 158 """ |
| 159 return os.path.abspath(os.path.join( | 159 return os.path.abspath(os.path.join( |
| 160 DIR_SOURCE_ROOT, os.environ.get('CHROMIUM_OUT_DIR', 'out'), | 160 DIR_SOURCE_ROOT, os.environ.get('CHROMIUM_OUT_DIR', 'out'), |
| 161 GetBuildType() if build_type is None else build_type)) | 161 GetBuildType() if build_type is None else build_type)) |
| 162 | 162 |
| 163 | 163 |
| 164 def SetOutDirectory(out_directory): | |
| 165 os.environ['CHROMIUM_OUT_DIR'] = out_directory | |
| 166 | |
| 167 | |
| 164 def _Memoize(func): | 168 def _Memoize(func): |
| 165 def Wrapper(): | 169 def Wrapper(): |
| 166 try: | 170 try: |
| 167 return func._result | 171 return func._result |
| 168 except AttributeError: | 172 except AttributeError: |
| 169 func._result = func() | 173 func._result = func() |
| 170 return func._result | 174 return func._result |
| 171 return Wrapper | 175 return Wrapper |
| 172 | 176 |
| 173 | 177 |
| 174 @_Memoize | 178 @_Memoize |
| 175 def GetAdbPath(): | 179 def GetAdbPath(): |
| 176 if os.environ.get('ANDROID_SDK_ROOT'): | 180 if os.environ.get('ANDROID_SDK_ROOT'): |
| 177 return 'adb' | 181 return 'adb' |
| 178 # If envsetup.sh hasn't been sourced and there's no adb in the path, | 182 # If envsetup.sh hasn't been sourced and there's no adb in the path, |
| 179 # set it here. | 183 # set it here. |
| 180 try: | 184 try: |
| 181 with file(os.devnull, 'w') as devnull: | 185 with file(os.devnull, 'w') as devnull: |
| 182 subprocess.call(['adb', 'version'], stdout=devnull, stderr=devnull) | 186 subprocess.call(['adb', 'version'], stdout=devnull, stderr=devnull) |
| 183 return 'adb' | 187 return 'adb' |
| 184 except OSError: | 188 except OSError: |
| 185 logging.debug('No adb found in $PATH, fallback to checked in binary.') | 189 logging.debug('No adb found in $PATH, fallback to checked in binary.') |
| 186 return os.path.join(ANDROID_SDK_ROOT, 'platform-tools', 'adb') | 190 return os.path.join(ANDROID_SDK_ROOT, 'platform-tools', 'adb') |
| 187 | 191 |
| 188 | 192 |
| 189 # Exit codes | 193 # Exit codes |
| 190 ERROR_EXIT_CODE = 1 | 194 ERROR_EXIT_CODE = 1 |
| 191 WARNING_EXIT_CODE = 88 | 195 WARNING_EXIT_CODE = 88 |
| OLD | NEW |