-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSConstruct
52 lines (37 loc) · 1.94 KB
/
SConstruct
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
import os, subprocess, SCons.Util
def filterAndStripPrefix(list, prefix):
return [i[len(prefix):] for i in filter(lambda s: s.startswith(prefix), list)]
def filterNotPrefix(list, prefix):
return filter(lambda s: not s.startswith(prefix), list)
cppflagscall = subprocess.Popen('llvm-config --cppflags', shell=True, stdout=subprocess.PIPE)
llvmcppflags = cppflagscall.communicate()[0].rstrip('\n').split(' ')
ldflagscall = subprocess.Popen('llvm-config --ldflags', shell=True, stdout=subprocess.PIPE)
llvmldflags = ldflagscall.communicate()[0].rstrip('\n').split(' ')
env = Environment(CPPPATH = [ 'include' ] + filterAndStripPrefix(llvmcppflags, '-I'),
CXXFLAGS = filterNotPrefix(llvmcppflags, '-I'),
LIBPATHS = filterAndStripPrefix(llvmldflags, '-L'),
LIBS = filterAndStripPrefix(llvmldflags, '-l'))
if os.environ.has_key('CC'):
env['CC'] = os.environ['CC']
if os.environ.has_key('CFLAGS'):
env['CCFLAGS'] += SCons.Util.CLVar(os.environ['CFLAGS'])
if os.environ.has_key('CXX'):
env['CXX'] = os.environ['CXX']
if os.environ.has_key('CXXFLAGS'):
env['CXXFLAGS'] += SCons.Util.CLVar(os.environ['CXXFLAGS'])
if os.environ.has_key('LDFLAGS'):
env['LINKFLAGS'] += SCons.Util.CLVar(os.environ['LDFLAGS'])
conf = Configure(env)
# Checks for libraries, header files, etc. go here!
env = conf.Finish()
env['CXXFLAGS'] += ["-O0","-g"]
def isCPPFile(f):
return f.endswith('.cpp')
libfiles = filter(isCPPFile, ["lib/" + i for i in os.listdir('lib/')])
env.StaticLibrary('lib/RslLLVM', libfiles)
corelinkcall = subprocess.Popen('llvm-config --libs core', shell=True, stdout=subprocess.PIPE)
corelinkflags = corelinkcall.communicate()[0].rstrip('\n').split(' ')
rslcfiles = filter(isCPPFile, ["tools/rslc/" + i for i in os.listdir('tools/rslc')])
env.Program('rslc', rslcfiles,
LIBS=env['LIBS'] + ['RslLLVM'] + filterAndStripPrefix(corelinkflags, '-l'),
LIBPATH=env['LIBPATHS'] + ['lib'])