-
Notifications
You must be signed in to change notification settings - Fork 4
/
SConstruct
75 lines (61 loc) · 2.91 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/bin/env python3
import os
import subprocess
import sys
# envDict: { key: value }
def findEnviornment(scriptname, envDict):
if not os.path.isfile(scriptname):
print ("[Error] Can't find script:"+scriptname)
command = ['env', '-i', 'bash', '-c', 'source '+scriptname+' && env']
proc = subprocess.Popen(command, stdout = subprocess.PIPE, shell=True)
for line in proc.stdout:
if '{' in line.decode('utf-8'): continue
if '}' in line.decode('utf-8'): continue
t_array= line.decode('utf-8').split("=",1)
key=t_array[0]
value=t_array[1].rstrip('\n')
envDict[key] = value
proc.communicate()
def returnEnviornment(scriptname):
envDict = {}
findEnviornment(scriptname, envDict)
return envDict
def addRootEnv(_env):
_env.Append (CCFLAGS = '-isystem `root-config --incdir`' )
#_env.Append (CCFLAGS = '-g' )
_env.Append (CCFLAGS = '`root-config --cflags`' )
_env.Append (LINKFLAGS = '`root-config --glibs`')
_env.Append (LINKFLAGS = '`root-config --ldflags`')
_env.Append (LINKFLAGS = ['-lRooFit', '-lGenVector', '-lRooStats', '-lRooFitCore'])
def addWarningEnv(_env):
_env.Append (CCFLAGS = ['-pedantic',
'-Wall', '-Wextra', '-Werror', '-Wold-style-cast',
'-Wcast-align', '-Wcast-qual', '-Wdisabled-optimization',
'-Wformat=2', '-Wformat-nonliteral', '-Wformat-security',
'-Wformat-y2k', '-Winit-self', '-Winvalid-pch', '-Wlong-long',
'-Wmissing-format-attribute', '-Wmissing-include-dirs',
'-Wpacked', '-Wpointer-arith', '-Wredundant-decls', '-Wstack-protector',
'-Wundef', '-Wvariadic-macros', '-Wmissing-noreturn',
'-Wwrite-strings', '-Wctor-dtor-privacy', '-Wnon-virtual-dtor', '-Wsign-promo', '-Wsign-compare',
'-Wunreachable-code',
'-Woverloaded-virtual', '-Wshadow', '-Wswitch-default', '-Wswitch-enum', '-Wunused',
#'-Wsign-conversion', '-Wfloat-equal', '-Wunsafe-loop-optimizations',
])
def addExternalEnv(_env):
_env.Append (CCFLAGS = '-isystem external_inc -std=c++17' )
def addBasicEnv(_env):
_env.Append (CCFLAGS = '-O2')
def addKernelEnv(_env):
_env['kernel'] = getKernel()
def getKernel():
return subprocess.check_output("uname -r | cut -d '-' -f1", shell=True, universal_newlines=True).rstrip()
SConsignFile('kernel/'+getKernel()+'/sconsign.dblite')
# [Requried] Export SET_ENV_PATH to script that sets root and scons environment
analysisEnv = Environment(ENV = returnEnviornment(os.environ['SET_ENV_PATH']))
addBasicEnv(analysisEnv)
addKernelEnv(analysisEnv)
addRootEnv(analysisEnv)
addExternalEnv(analysisEnv)
addWarningEnv(analysisEnv)
exportEnv = analysisEnv
SConscript('SConscript', variant_dir='build/'+analysisEnv['kernel'], duplicate=0, exports="exportEnv")