| 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 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 | 206 |
| 207 | 207 |
| 208 # Mapping table between OS and build output location. | 208 # Mapping table between OS and build output location. |
| 209 BUILD_ROOT = { | 209 BUILD_ROOT = { |
| 210 'win32': os.path.join('build'), | 210 'win32': os.path.join('build'), |
| 211 'linux': os.path.join('out'), | 211 'linux': os.path.join('out'), |
| 212 'freebsd': os.path.join('out'), | 212 'freebsd': os.path.join('out'), |
| 213 'macos': os.path.join('xcodebuild'), | 213 'macos': os.path.join('xcodebuild'), |
| 214 } | 214 } |
| 215 | 215 |
| 216 ARCH_FAMILY = { |
| 217 'ia32': 'ia32', |
| 218 'x64': 'ia32', |
| 219 'arm': 'arm', |
| 220 'mips': 'mips', |
| 221 'simarm': 'ia32', |
| 222 'simmips': 'ia32', |
| 223 } |
| 224 |
| 216 ARCH_GUESS = GuessArchitecture() | 225 ARCH_GUESS = GuessArchitecture() |
| 217 BASE_DIR = os.path.abspath(os.path.join(os.curdir, '..')) | 226 BASE_DIR = os.path.abspath(os.path.join(os.curdir, '..')) |
| 218 DART_DIR = os.path.abspath(os.path.join(__file__, '..', '..')) | 227 DART_DIR = os.path.abspath(os.path.join(__file__, '..', '..')) |
| 219 | 228 |
| 220 def GetBuildbotGSUtilPath(): | 229 def GetBuildbotGSUtilPath(): |
| 221 gsutil = '/b/build/scripts/slave/gsutil' | 230 gsutil = '/b/build/scripts/slave/gsutil' |
| 222 if platform.system() == 'Windows': | 231 if platform.system() == 'Windows': |
| 223 gsutil = 'e:\\\\b\\build\\scripts\\slave\\gsutil' | 232 gsutil = 'e:\\\\b\\build\\scripts\\slave\\gsutil' |
| 224 return gsutil | 233 return gsutil |
| 225 | 234 |
| 226 def GetBuildMode(mode): | 235 def GetBuildMode(mode): |
| 227 return BUILD_MODES[mode] | 236 return BUILD_MODES[mode] |
| 228 | 237 |
| 238 def GetArchFamily(arch): |
| 239 return ARCH_FAMILY[arch] |
| 240 |
| 229 def GetBuildConf(mode, arch, conf_os=None): | 241 def GetBuildConf(mode, arch, conf_os=None): |
| 230 if conf_os == 'android': | 242 if conf_os == 'android': |
| 231 return '%s%s%s' % (GetBuildMode(mode), conf_os.title(), arch.upper()) | 243 return '%s%s%s' % (GetBuildMode(mode), conf_os.title(), arch.upper()) |
| 232 else: | 244 else: |
| 233 # Ask for a cross build if the host and target architectures don't match. | 245 # Ask for a cross build if the host and target architectures don't match. |
| 234 host_arch = ARCH_GUESS | 246 host_arch = ARCH_GUESS |
| 235 target_arch = arch | |
| 236 if target_arch == 'x64': | |
| 237 target_arch = 'ia32' | |
| 238 print "GetBuildConf: Rewritten %s to %s\n" % (arch, target_arch) | |
| 239 if host_arch == 'x64': | |
| 240 host_arch = 'ia32' | |
| 241 print "GetBuildConf: Rewritten %s to %s\n" % (arch, host_arch) | |
| 242 cross_build = '' | 247 cross_build = '' |
| 243 if host_arch != target_arch: | 248 if GetArchFamily(host_arch) != GetArchFamily(arch): |
| 244 print "GetBuildConf: Cross-build of %s on %s\n" % (arch, host_arch) | 249 print "GetBuildConf: Cross-build of %s on %s\n" % (arch, host_arch) |
| 245 cross_build = 'X' | 250 cross_build = 'X' |
| 246 return '%s%s%s' % (GetBuildMode(mode), cross_build, arch.upper()) | 251 return '%s%s%s' % (GetBuildMode(mode), cross_build, arch.upper()) |
| 247 | 252 |
| 248 def GetBuildDir(host_os, target_os): | 253 def GetBuildDir(host_os, target_os): |
| 249 return BUILD_ROOT[host_os] | 254 return BUILD_ROOT[host_os] |
| 250 | 255 |
| 251 def GetBuildRoot(host_os, mode=None, arch=None, target_os=None): | 256 def GetBuildRoot(host_os, mode=None, arch=None, target_os=None): |
| 252 build_root = GetBuildDir(host_os, target_os) | 257 build_root = GetBuildDir(host_os, target_os) |
| 253 if mode: | 258 if mode: |
| (...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 554 os.chdir(self._working_directory) | 559 os.chdir(self._working_directory) |
| 555 | 560 |
| 556 def __exit__(self, *_): | 561 def __exit__(self, *_): |
| 557 print "Enter directory = ", self._old_cwd | 562 print "Enter directory = ", self._old_cwd |
| 558 os.chdir(self._old_cwd) | 563 os.chdir(self._old_cwd) |
| 559 | 564 |
| 560 | 565 |
| 561 if __name__ == "__main__": | 566 if __name__ == "__main__": |
| 562 import sys | 567 import sys |
| 563 Main(sys.argv) | 568 Main(sys.argv) |
| OLD | NEW |