5053e2c3952491f18a3de275fad0f0e96275428a
[oota-llvm.git] / test / Bindings / Go / lit.local.cfg
1 import distutils.spawn
2 import os
3 import pipes
4 import shlex
5
6 if not 'go' in config.root.llvm_bindings:
7     config.unsupported = True
8
9 # Resolve certain symlinks in the first word of compiler.
10 #
11 # This is a Go-specific hack. cgo and other Go tools check $CC and $CXX for the
12 # substring 'clang' to determine if the compiler is Clang. This won't work if
13 # $CC is cc and cc is a symlink pointing to clang, as it is on Darwin.
14 def fixup_compiler_path(compiler):
15     args = shlex.split(compiler)
16     path = distutils.spawn.find_executable(args[0])
17
18     try:
19         if path.endswith('/cc') and os.readlink(path) == 'clang':
20             args[0] = path[:len(path)-2] + 'clang'
21     except OSError:
22         skip
23
24     try:
25         if path.endswith('/c++') and os.readlink(path) == 'clang++':
26             args[0] = path[:len(path)-3] + 'clang++'
27     except OSError:
28         skip
29
30     return ' '.join([pipes.quote(arg) for arg in args])
31
32 config.environment['CC'] = fixup_compiler_path(config.host_cc)
33 config.environment['CXX'] = fixup_compiler_path(config.host_cxx)