-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSConstruct
More file actions
253 lines (206 loc) · 5.95 KB
/
SConstruct
File metadata and controls
253 lines (206 loc) · 5.95 KB
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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
########################################################################
#
# performance boosters
#
CacheDir('.scons-cache')
SetOption('implicit_cache', True)
SetOption('max_drift', 1)
########################################################################
#
# configurable paths to various supporting tools
#
from os import access, R_OK, X_OK
def pathIsExecutable(key, val, env):
found = env.WhereIs(val)
if found:
val = found
PathVariable.PathIsFile(key, val, env)
if not access(val, X_OK):
raise SCons.Errors.UserError('Path for option %s is not executable: %s' % (key, val))
def pathIsOptionalExecutable(key, val, env):
if val:
pathIsExecutable(key, val, env)
variables = Variables(['.scons-options'], ARGUMENTS)
variables.Add(BoolVariable('DEBUG', 'compile for debugging', False))
variables.Add(PathVariable('IIGLUE', 'Path to iiglue executable', '/p/polyglot/public/bin/iiglue', pathIsOptionalExecutable))
variables.Add(BoolVariable('VALGRIND', 'run tests under Valgrind', False))
llvmConfigDefault = WhereIs('llvm-config', (
'/p/polyglot/public/tools/llvm-3.6.1/install/bin',
'/usr/bin',
)) or '/usr/bin/llvm-config'
variables.Add(PathVariable('LLVM_CONFIG', 'Path to llvm-config executable', llvmConfigDefault, pathIsExecutable))
sageDefault = WhereIs('sage', (
'/p/polyglot/public/bin',
'/usr/bin',
)) or '/usr/bin/sage'
variables.Add(PathVariable('SAGE', 'Path to sage executable', sageDefault, pathIsExecutable))
########################################################################
#
# common basis for all build environments
#
env = Environment(
tools=(
'default', # load first, so others can override
'bitcode',
'clang-analyzer',
'expect',
'iiglue',
'plugin',
'textfile',
),
toolpath=(
'scons-tools',
),
variables=variables,
)
Help(variables.GenerateHelpText(env))
variables.Save('.scons-options', env)
########################################################################
#
# LLVM configuration
#
def llvm_version(context):
context.Message('checking LLVM version ... ')
succeeded, output = context.TryAction('$LLVM_CONFIG --version >$TARGET')
if succeeded:
result = output.rstrip('\n')
context.env['llvm_version'] = result
context.Result(result)
return result
else:
context.Result('failed')
context.env.Exit(1)
def llvm_bindir(context):
context.Message('checking LLVM executables ... ')
succeeded, output = context.TryAction('$LLVM_CONFIG --bindir >$TARGET')
if succeeded:
output = output.rstrip()
context.env['LLVM_BINDIR'] = output
context.env.PrependENVPath('PATH', output)
context.Result(output)
return output
else:
context.Result('failed')
context.env.Exit(1)
conf = Configure(env, custom_tests={
'LLVMVersion': llvm_version,
'LLVMBinDir': llvm_bindir,
})
conf.LLVMVersion()
conf.LLVMBinDir()
env = conf.Finish()
########################################################################
#
# build environment for compiling LLVM plugins
#
penv = env.Clone(
CPPPATH=(
'/unsup/boost/include',
),
INCPREFIX='-isystem ',
LIBS=('LLVM-$llvm_version',),
SHLIBPREFIX=None,
tools=(
'compilation-database',
'dir-locals-el',
),
)
penv.ParseConfig('$LLVM_CONFIG --cxxflags --ldflags')
penv.AppendUnique(
CCFLAGS=(
'-fexceptions',
'-frtti',
'-Wall',
'-Wextra',
'-Werror',
'${("", "-g")[DEBUG]}',
),
delete_existing=True
)
if penv['DEBUG']:
try:
penv['CPPDEFINES'].remove('NDEBUG')
except ValueError:
pass
penv.PrependENVPath('PATH', '/s/gcc-5.1.0/bin')
########################################################################
#
# specific plugins
#
python_plugin = penv.SharedLibrary(
'SRA/SAGE/Python/Python',
Glob('SRA/SAGE/Python/*.cpp'),
CCFLAGS=(
'$CCFLAGS',
'-Wno-cast-qual',
),
parse_flags='!python-config --libs',
)
sage_plugin = penv.SharedLibrary(
'SRA/SAGE/SAGE',
Glob('SRA/SAGE/*.cpp'),
CCFLAGS=(
'$CCFLAGS',
'-Wno-unused-parameter',
),
LIBS=python_plugin,
)
sra_plugin = penv.SharedLibrary(
'SRA/SRA',
Glob('SRA/*.cpp'),
CCFLAGS=(
'$CCFLAGS',
'-Wno-maybe-uninitialized',
'-Wno-unknown-warning-option',
'-Wno-unused-parameter',
),
LIBS=sage_plugin,
)
subst_dict = {
'@LLVM_BINDIR@': '$LLVM_BINDIR',
'@SAGE@': '$SAGE',
'@VALGRIND@': '${ "valgrind --error-exitcode=166 --leak-check=full --errors-for-leak-kinds=definite --suppressions=python.supp --suppressions=sage.supp" if VALGRIND else "" }'
}
run_script = penv.Substfile('run.in', SUBST_DICT=subst_dict)
expanded_dict = {key: env.subst(value) for key, value in subst_dict.iteritems()}
env.Depends(run_script, Value(expanded_dict))
AddPostAction(run_script, Chmod('$TARGET', 0750))
plugin, = penv.SharedLibrary(
'CArrayIntrospection',
(
'Annotator.cc',
'AnnotatorHelper.cc',
'BacktrackPhiNodes.cc',
'CheckGetElementPtrVisitor.cc',
'FindLengthChecks.cc',
'FindLengthLoops.cc',
'FindSentinelHelper.cc',
'FindStructElements.cc',
'IIGlueReader.cc',
'LengthInfo.cc',
'NameCompare.cc',
'NoPointerArithmetic.cc',
'NoPointerComparisons.cc',
'StructElement.cc',
'SymbolicRangeTest.cc',
'ValueReachesValue.cc',
'ValueSetSet.cc',
),
LIBS=sra_plugin,
)
env['plugin'] = plugin
Alias('plugin', plugin)
########################################################################
#
# IDE support files
#
penv.CompilationDatabase(plugin)
penv.DirLocalsEl()
########################################################################
#
# subdirectories
#
SConscript(dirs='tests', exports='env')
# Local variables:
# flycheck-flake8rc: "scons-flake8.ini"
# End: