Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 # Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 # for details. All rights reserved. Use of this source code is governed by a | 2 # for details. All rights reserved. Use of this source code is governed by a |
| 3 # BSD-style license that can be found in the LICENSE file. | 3 # BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 # This file contains a set of utilities functions used by other Python-based | 5 # This file contains a set of utilities functions used by other Python-based |
| 6 # scripts. | 6 # scripts. |
| 7 | 7 |
| 8 import commands | 8 import commands |
| 9 import os | 9 import os |
| 10 import platform | 10 import platform |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 198 'macos': os.path.join('xcodebuild'), | 198 'macos': os.path.join('xcodebuild'), |
| 199 } | 199 } |
| 200 | 200 |
| 201 def GetBuildbotGSUtilPath(): | 201 def GetBuildbotGSUtilPath(): |
| 202 gsutil = '/b/build/scripts/slave/gsutil' | 202 gsutil = '/b/build/scripts/slave/gsutil' |
| 203 if platform.system() == 'Windows': | 203 if platform.system() == 'Windows': |
| 204 gsutil = 'e:\\\\b\\build\\scripts\\slave\\gsutil' | 204 gsutil = 'e:\\\\b\\build\\scripts\\slave\\gsutil' |
| 205 return gsutil | 205 return gsutil |
| 206 | 206 |
| 207 def GetBuildMode(mode): | 207 def GetBuildMode(mode): |
| 208 global BUILD_MODES | |
| 209 return BUILD_MODES[mode] | 208 return BUILD_MODES[mode] |
| 210 | 209 |
| 211 | 210 |
| 212 def GetBuildConf(mode, arch): | 211 def GetBuildConf(mode, arch): |
| 213 return '%s%s' % (GetBuildMode(mode), arch.upper()) | 212 return '%s%s' % (GetBuildMode(mode), arch.upper()) |
| 214 | 213 |
| 215 ARCH_GUESS = GuessArchitecture() | 214 ARCH_GUESS = GuessArchitecture() |
| 216 BASE_DIR = os.path.abspath(os.path.join(os.curdir, '..')) | 215 BASE_DIR = os.path.abspath(os.path.join(os.curdir, '..')) |
| 216 DART_DIR = os.path.abspath(os.path.join(__file__, '..', '..')) | |
| 217 | 217 |
| 218 | 218 |
| 219 def GetBuildDir(host_os, target_os): | 219 def GetBuildDir(host_os, target_os): |
| 220 global BUILD_ROOT | |
| 221 build_dir = BUILD_ROOT[host_os] | 220 build_dir = BUILD_ROOT[host_os] |
| 222 if target_os and target_os != host_os: | 221 if target_os and target_os != host_os: |
| 223 build_dir = os.path.join(build_dir, target_os) | 222 build_dir = os.path.join(build_dir, target_os) |
| 224 return build_dir | 223 return build_dir |
| 225 | 224 |
| 226 def GetBuildRoot(host_os, mode=None, arch=None, target_os=None): | 225 def GetBuildRoot(host_os, mode=None, arch=None, target_os=None): |
| 227 build_root = GetBuildDir(host_os, target_os) | 226 build_root = GetBuildDir(host_os, target_os) |
| 228 if mode: | 227 if mode: |
| 229 build_root = os.path.join(build_root, GetBuildConf(mode, arch)) | 228 build_root = os.path.join(build_root, GetBuildConf(mode, arch)) |
| 230 return build_root | 229 return build_root |
| 231 | 230 |
| 232 def GetBaseDir(): | 231 def GetBaseDir(): |
| 233 return BASE_DIR | 232 return BASE_DIR |
| 234 | 233 |
| 235 def GetVersion(): | 234 def GetVersion(): |
| 236 dartbin = DartBinary() | 235 version_tuple = ReadVersionFile() |
| 237 version_script = VersionScript() | 236 if not version_tuple: |
| 238 p = subprocess.Popen([dartbin, version_script], stdout = subprocess.PIPE, | 237 return None |
| 239 stderr = subprocess.STDOUT, shell=IsWindows()) | 238 |
| 240 output, not_used = p.communicate() | 239 (major, minor, build, patch) = version_tuple |
| 241 return output.strip() | 240 revision = GetSVNRevision() |
| 241 user = GetUserName() | |
| 242 if user == 'chrome-bot': | |
|
ricow1
2013/08/06 10:49:12
add comment:
# We don't add username to release bu
kustermann
2013/08/06 10:52:44
Done.
| |
| 243 user = '' | |
| 244 | |
| 245 user_string = '' | |
| 246 revision_string = '' | |
| 247 if user: | |
| 248 user_string = '_%s' % user | |
| 249 if revision: | |
| 250 revision_string = '_r%s' % revision | |
| 251 | |
| 252 return ("%s.%s.%s.%s%s%s" % | |
| 253 (major, minor, build, patch, revision_string, user_string)) | |
| 254 | |
| 255 def GetUserName(): | |
| 256 key = 'USER' | |
| 257 if sys.platform == 'win32': | |
| 258 key = 'USERNAME' | |
| 259 return os.environ.get(key, '') | |
| 260 | |
| 261 def ReadVersionFile(): | |
| 262 version_file = os.path.join(DART_DIR, 'tools', 'VERSION') | |
| 263 try: | |
| 264 fd = open(version_file) | |
| 265 content = fd.read() | |
| 266 fd.close() | |
| 267 except: | |
| 268 print "Warning: Couldn't read VERSION file (%s)" % version_file | |
| 269 return None | |
| 270 major_match = re.search('MAJOR (\d+)', content) | |
| 271 minor_match = re.search('MINOR (\d+)', content) | |
| 272 build_match = re.search('BUILD (\d+)', content) | |
| 273 patch_match = re.search('PATCH (\d+)', content) | |
| 274 if major_match and minor_match and build_match and patch_match: | |
| 275 return (major_match.group(1), minor_match.group(1), build_match.group(1), | |
| 276 patch_match.group(1)) | |
| 277 else: | |
| 278 print "Warning: VERSION file (%s) has wrong format" % version_file | |
| 279 return None | |
| 242 | 280 |
| 243 def GetSVNRevision(): | 281 def GetSVNRevision(): |
| 282 # FIXME(kustermann): Make this work for newer SVN versions as well (where | |
| 283 # we've got only one '.svn' directory) | |
| 244 custom_env = dict(os.environ) | 284 custom_env = dict(os.environ) |
| 245 custom_env['LC_MESSAGES'] = 'en_GB' | 285 custom_env['LC_MESSAGES'] = 'en_GB' |
| 246 p = subprocess.Popen(['svn', 'info'], stdout = subprocess.PIPE, | 286 p = subprocess.Popen(['svn', 'info'], stdout = subprocess.PIPE, |
| 247 stderr = subprocess.STDOUT, shell=IsWindows(), | 287 stderr = subprocess.STDOUT, shell=IsWindows(), |
| 248 env = custom_env) | 288 env = custom_env, |
| 249 output, not_used = p.communicate() | 289 cwd = DART_DIR) |
| 290 output, _ = p.communicate() | |
| 250 revision = ParseSvnInfoOutput(output) | 291 revision = ParseSvnInfoOutput(output) |
| 251 if revision: | 292 if revision: |
| 252 return revision | 293 return revision |
| 253 | 294 |
| 254 # maybe the builder is using git-svn, try that | 295 # maybe the builder is using git-svn, try that |
| 255 p = subprocess.Popen(['git', 'svn', 'info'], stdout = subprocess.PIPE, | 296 p = subprocess.Popen(['git', 'svn', 'info'], stdout = subprocess.PIPE, |
| 256 stderr = subprocess.STDOUT, shell=IsWindows()) | 297 stderr = subprocess.STDOUT, shell=IsWindows(), cwd = DART_DIR) |
| 257 output, not_used = p.communicate() | 298 output, _ = p.communicate() |
| 258 revision = ParseSvnInfoOutput(output) | 299 revision = ParseSvnInfoOutput(output) |
| 259 if revision: | 300 if revision: |
| 260 return revision | 301 return revision |
| 261 | 302 |
| 262 return None | 303 return None |
| 263 | 304 |
| 264 def ParseSvnInfoOutput(output): | 305 def ParseSvnInfoOutput(output): |
| 265 for line in output.split('\n'): | 306 revision_match = re.search('Last Changed Rev: (\d+)', output) |
| 266 if 'Revision' in line: | 307 if revision_match: |
| 267 return (line.strip().split())[1] | 308 return revision_match.group(1) |
| 268 return None | 309 return None |
| 269 | 310 |
| 270 def RewritePathSeparator(path, workspace): | 311 def RewritePathSeparator(path, workspace): |
| 271 # Paths in test files are always specified using '/' | 312 # Paths in test files are always specified using '/' |
| 272 # as the path separator. Replace with the actual | 313 # as the path separator. Replace with the actual |
| 273 # path separator before use. | 314 # path separator before use. |
| 274 if ('/' in path): | 315 if ('/' in path): |
| 275 split_path = path.split('/') | 316 split_path = path.split('/') |
| 276 path = os.sep.join(split_path) | 317 path = os.sep.join(split_path) |
| 277 path = os.path.join(workspace, path) | 318 path = os.path.join(workspace, path) |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 382 if IsCrashExitCode(exit_code): | 423 if IsCrashExitCode(exit_code): |
| 383 sys.stderr.write('Command: %s\nCRASHED with exit code %d (0x%x)\n' % ( | 424 sys.stderr.write('Command: %s\nCRASHED with exit code %d (0x%x)\n' % ( |
| 384 ' '.join(command), exit_code, exit_code & 0xffffffff)) | 425 ' '.join(command), exit_code, exit_code & 0xffffffff)) |
| 385 | 426 |
| 386 | 427 |
| 387 def Touch(name): | 428 def Touch(name): |
| 388 with file(name, 'a'): | 429 with file(name, 'a'): |
| 389 os.utime(name, None) | 430 os.utime(name, None) |
| 390 | 431 |
| 391 | 432 |
| 392 def VersionScript(): | |
| 393 tools_dir = os.path.dirname(os.path.realpath(__file__)) | |
| 394 return os.path.join(tools_dir, 'version.dart') | |
| 395 | |
| 396 | |
| 397 def DartBinary(): | 433 def DartBinary(): |
| 398 tools_dir = os.path.dirname(os.path.realpath(__file__)) | 434 tools_dir = os.path.dirname(os.path.realpath(__file__)) |
| 399 dart_binary_prefix = os.path.join(tools_dir, 'testing', 'bin') | 435 dart_binary_prefix = os.path.join(tools_dir, 'testing', 'bin') |
| 400 if IsWindows(): | 436 if IsWindows(): |
| 401 return os.path.join(dart_binary_prefix, 'windows', 'dart.exe') | 437 return os.path.join(dart_binary_prefix, 'windows', 'dart.exe') |
| 402 else: | 438 else: |
| 403 return os.path.join(dart_binary_prefix, GuessOS(), 'dart') | 439 return os.path.join(dart_binary_prefix, GuessOS(), 'dart') |
| 404 | 440 |
| 405 | 441 |
| 406 def DartSdkBinary(): | 442 def DartSdkBinary(): |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 417 self._temp_dir = tempfile.mkdtemp(self._prefix) | 453 self._temp_dir = tempfile.mkdtemp(self._prefix) |
| 418 return self._temp_dir | 454 return self._temp_dir |
| 419 | 455 |
| 420 def __exit__(self, *_): | 456 def __exit__(self, *_): |
| 421 shutil.rmtree(self._temp_dir, ignore_errors=True) | 457 shutil.rmtree(self._temp_dir, ignore_errors=True) |
| 422 | 458 |
| 423 | 459 |
| 424 if __name__ == "__main__": | 460 if __name__ == "__main__": |
| 425 import sys | 461 import sys |
| 426 Main(sys.argv) | 462 Main(sys.argv) |
| OLD | NEW |