-
Notifications
You must be signed in to change notification settings - Fork 0
/
lit.cfg
147 lines (110 loc) · 3.75 KB
/
lit.cfg
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
# vim:syntax=python
import os
import sys
#
# Basic information about this test suite.
#
config.name = 'TESLA'
config.suffixes = [ '.c', '.cpp', '.ll', '.tesla' ]
config.excludes = [ 'Inputs' ]
config.test_format = lit.formats.ShTest()
#
# Useful environment variables.
#
# This variables are optional when TESLA is installed to a standard location;
# if not, failure to set these variables will cause tests to fail building.
#
tesla_src = os.getenv('TESLA_SOURCE_DIR')
if not tesla_src:
if not 'source_dir' in lit.params:
raise Exception, ('Unable to find TESLA source directory;' +
' set TESLA_SOURCE_DIR or pass --source_dir to lit')
tesla_src = lit.params['source_dir']
tesla_build = os.getenv('TESLA_BUILD_DIR')
if not tesla_build:
if not 'build_dir' in lit.params:
raise Exception, ('Unable to find TESLA build directory;' +
' set TESLA_BUILD_DIR or pass --build_dir to lit')
tesla_build = lit.params['build_dir']
include_dirs = [ tesla_build + '/include' ]
extra_cflags = [ '-g' ] # always build tests with debug symbols
extra_cxxflags = [ '-g' ]
libdirs = []
extra_libs = []
if 'extra_include_dirs' in lit.params:
include_dirs += lit.params['extra_include_dirs'].split(os.path.pathsep)
if 'extra_cflags' in lit.params:
extra_cflags += lit.params['extra_cflags'].split(os.path.pathsep)
if 'extra_cxxflags' in lit.params:
extra_cxxflags += lit.params['extra_cxxflags'].split(os.path.pathsep)
if 'extra_libdirs' in lit.params:
libdirs += lit.params['extra_libdirs'].split(os.path.pathsep)
if 'extra_libs' in lit.params:
extra_libs += lit.params['extra_libs'].split(os.path.pathsep)
if 'output_dir' in lit.params:
config.test_exec_root = lit.params['output_dir']
#
# Site-specific configuration information (e.g. the host triple).
#
lit.load_config(config, tesla_build + '/lit.site.cfg')
#
# Find the 'test_support' module (which may not be in the current PYTHONPATH).
#
sys.path.append(os.curdir)
if tesla_src: sys.path.append(os.path.join(tesla_src, 'scripts'))
try:
import test_support as test
except ImportError, e:
print "Unable to find 'test_support' module!"
print "Try setting TESLA_SOURCE_DIR?"
sys.exit(1)
#
# Find LLVM tools (e.g. FileCheck).
#
llvm_obj_root = test.llvm_config['obj-root']
llvm_tools = os.path.join(llvm_obj_root, 'bin')
#
# Find TESLA includes and libraries.
#
for (header, subdir) in [
('libtesla.h', 'include'),
('tesla_internal.h', os.path.join('libtesla', 'src'))
]:
include_dirs.append(
test.find_include_dir(header, [ '%s/%s' % (tesla_src, subdir) ],
'Try setting TESLA_SOURCE_DIR'))
libtesla_dir = test.find_libdir('libtesla.*',
[ '%s/libtesla/src' % d for d in [ os.getcwd(), tesla_build ] ],
'Try setting TESLA_BUILD_DIR')
libdirs.append(libtesla_dir)
#
# Set tools paths, CFLAGS, LDFLAGS, PATH, etc.
#
clang = test.which([ 'clang33', 'clang' ])
clangpp = test.which([ 'clang++33', 'clang++' ])
llc = test.which([ 'llc33', 'llc' ])
config.substitutions += [
# Tools:
('%clang', clang),
('%llc', llc),
('%filecheck', test.which([ 'FileCheck33', 'FileCheck' ])),
# Flags:
('%cflags', test.cflags(include_dirs + [ '%p/Inputs' ],
extra = extra_cflags)),
('%cxxflags', test.cflags(include_dirs + [ '%p/Inputs' ],
extra = extra_cxxflags)),
('%ldflags', test.ldflags(libdirs, [ 'tesla' ], extra_libs)),
('%cpp_out', test.cpp_out()),
]
config.environment['PATH'] = os.path.pathsep.join([
llvm_tools,
os.path.join(tesla_src, 'scripts'),
config.environment['PATH']
])
config.environment['LD_LIBRARY_PATH'] = libtesla_dir
config.environment['TESLA_BUILD_DIR'] = tesla_build
config.environment['TESLA_SOURCE_DIR'] = tesla_src
config.environment['TESLA_DEBUG'] = '*'
config.environment['CC'] = clang
config.environment['CXX'] = clangpp
config.environment['LLC'] = llc