Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 # Copyright (c) 2011, 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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 100 | 100 |
| 101 for arg in parser.rargs: | 101 for arg in parser.rargs: |
| 102 if arg[:2].startswith('--') or arg[0] != '-': | 102 if arg[:2].startswith('--') or arg[0] != '-': |
| 103 break | 103 break |
| 104 value.append(arg) | 104 value.append(arg) |
| 105 | 105 |
| 106 del parser.rargs[:len(value)] | 106 del parser.rargs[:len(value)] |
| 107 setattr(parser.values, option.dest, value) | 107 setattr(parser.values, option.dest, value) |
| 108 | 108 |
| 109 | 109 |
| 110 # Returns the path to the Dart test runner (executes the .dart file). | |
| 111 def GetDart(mode, arch, component): | |
|
ahe
2011/11/03 11:18:38
Please use proper python doc strings.
Also, consi
ngeoffray
2011/11/03 11:53:00
I followed the style in this script.
| |
| 112 build_root = GetBuildRoot(GuessOS(), mode, arch) | |
| 113 if component == 'dartc': | |
| 114 return os.path.join(build_root, 'compiler', 'bin', 'dartc_test') | |
| 115 elif component == 'frog': | |
| 116 return os.path.join(build_root, 'frog', 'bin', 'frog') | |
| 117 elif component == 'frogsh': | |
| 118 return os.path.join(build_root, 'frog', 'bin', 'frogsh') | |
| 119 else: | |
| 120 return os.path.join(build_root, 'dart_bin') | |
| 121 | |
| 122 | |
| 110 # Mapping table between build mode and build configuration. | 123 # Mapping table between build mode and build configuration. |
| 111 BUILD_MODES = { | 124 BUILD_MODES = { |
| 112 'debug': 'Debug', | 125 'debug': 'Debug', |
| 113 'release': 'Release', | 126 'release': 'Release', |
| 114 } | 127 } |
| 115 | 128 |
| 116 | 129 |
| 117 # Mapping table between OS and build output location. | 130 # Mapping table between OS and build output location. |
| 118 BUILD_ROOT = { | 131 BUILD_ROOT = { |
| 119 'win32': os.path.join(''), | 132 'win32': os.path.join(''), |
| 120 'linux': os.path.join('out'), | 133 'linux': os.path.join('out'), |
| 121 'freebsd': os.path.join('out'), | 134 'freebsd': os.path.join('out'), |
| 122 'macos': os.path.join('xcodebuild'), | 135 'macos': os.path.join('xcodebuild'), |
| 123 } | 136 } |
| 124 | 137 |
| 125 def GetBuildMode(mode): | 138 def GetBuildMode(mode): |
| 126 global BUILD_MODES | 139 global BUILD_MODES |
| 127 return BUILD_MODES[mode] | 140 return BUILD_MODES[mode] |
| 128 | 141 |
| 129 | 142 |
| 130 def GetBuildConf(mode, arch): | 143 def GetBuildConf(mode, arch): |
| 131 return GetBuildMode(mode) + "_" + arch | 144 return GetBuildMode(mode) + "_" + arch |
| 132 | 145 |
| 133 ARCH_GUESS = GuessArchitecture() | 146 ARCH_GUESS = GuessArchitecture() |
| 134 BASE_DIR = os.path.abspath(os.path.join(os.curdir, '..')) | 147 BASE_DIR = os.path.abspath(os.path.join(os.curdir, '..')) |
| 135 | 148 |
| 136 def GetBuildRoot(target_os, mode=None, arch=None): | 149 def GetBuildRoot(target_os, mode=None, arch=None): |
| 137 global BUILD_ROOT | 150 global BUILD_ROOT |
| 138 if mode: | 151 if mode: |
| 139 # TODO(ngeoffray): Remove this test once the testing infrastructure does not | |
| 140 # treat 'dartc' as an arch. | |
| 141 if arch == 'dartc': arch = ARCH_GUESS | |
| 142 return os.path.join(BUILD_ROOT[target_os], GetBuildConf(mode, arch)) | 152 return os.path.join(BUILD_ROOT[target_os], GetBuildConf(mode, arch)) |
| 143 else: | 153 else: |
| 144 return BUILD_ROOT[target_os] | 154 return BUILD_ROOT[target_os] |
| 145 | 155 |
| 146 def GetBaseDir(): | 156 def GetBaseDir(): |
| 147 return BASE_DIR | 157 return BASE_DIR |
| 148 | 158 |
| 149 def RewritePathSeparator(path, workspace): | 159 def RewritePathSeparator(path, workspace): |
| 150 # Paths in test files are always specified using '/' | 160 # Paths in test files are always specified using '/' |
| 151 # as the path separator. Replace with the actual | 161 # as the path separator. Replace with the actual |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 245 def __init__(self, value): | 255 def __init__(self, value): |
| 246 self.value = value | 256 self.value = value |
| 247 | 257 |
| 248 def __str__(self): | 258 def __str__(self): |
| 249 return repr(self.value) | 259 return repr(self.value) |
| 250 | 260 |
| 251 | 261 |
| 252 if __name__ == "__main__": | 262 if __name__ == "__main__": |
| 253 import sys | 263 import sys |
| 254 Main(sys.argv) | 264 Main(sys.argv) |
| OLD | NEW |