-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSConstruct
More file actions
65 lines (56 loc) · 1.79 KB
/
SConstruct
File metadata and controls
65 lines (56 loc) · 1.79 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
import os
####### UTILS
def collect_sources(path_list, exclude_sources):
sources = []
for path in path_list:
for root, dirs, files in os.walk(path):
sources.extend([os.path.join(root, f) for f in files if f.endswith(".cpp") and os.path.join(root, f) not in exclude_sources])
return sources
def do_all(name, cxxflags, linkflags, libs, source_dirs, target, exclude_sources):
target = os.path.join('build', name, target)
source = collect_sources(source_dirs, exclude_sources)
env = Environment(CXX='clang++', CXXFLAGS=cxxflags, LINKFLAGS=linkflags, LIBS=libs, CPPPATH=['include', 'test/include'])
env['ENV']['TERM'] = os.environ.get('TERM')
objs = []
for s in source:
# Remove file suffix
t = os.path.join('build', name, s[: s.rfind('.')])
objs.append(env.Object(target=t, source=s))
program = env.Program(target=target, source=objs)
env.Alias(name, target)
return env
#######
CXXFLAGS_COMMON = ['-Wall', "--std=c++17"]
CXX_DEBUG_FLAGS = ['-g', '-ggdb', '-O0']
CXX_RELEASE_FLAGS = ['-O3']
LINKFLAGS_COMMON = []
LIBS_COMMON = []
LIBS_GTEST = ['pthread', 'gtest', 'gtest_main']
configs = {
'debug': {
'cxxflags': CXXFLAGS_COMMON + CXX_DEBUG_FLAGS,
'linkflags': LINKFLAGS_COMMON,
'libs': LIBS_COMMON,
'source_dirs': ['src'],
'target': 'dane',
'exclude_sources': []
},
'release': {
'cxxflags': CXXFLAGS_COMMON + CXX_RELEASE_FLAGS,
'linkflags': LINKFLAGS_COMMON,
'libs': LIBS_COMMON,
'source_dirs': ['src'],
'target': 'dane',
'exclude_sources': []
},
'test': {
'cxxflags': CXXFLAGS_COMMON + CXX_DEBUG_FLAGS,
'linkflags': LINKFLAGS_COMMON,
'libs': LIBS_COMMON + LIBS_GTEST,
'source_dirs': ['src', 'test'],
'target': 'gtest',
'exclude_sources': ['src/main.cpp']
}
}
envs = [do_all(name, **value) for name, value in configs.items()]
# Default(configs['debug']['program'])