-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSConstruct
52 lines (46 loc) · 1.8 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 multiprocessing
import sys
AddOption('--clang', action='store_true', help='Force using Clang.')
if GetOption('clang'):
env = Environment(TOOLS=['clang', 'clang++', 'gnulink'])
else:
env = Environment() # default toolchain
AddOption('--dbg', action='store_true', help='Debug build. (add debug info and turn off optimization)')
if GetOption('dbg'):
if 'msvc' in env['TOOLS']:
env.Append(CCFLAGS=['/Zi'])
env.Append(LINKERFLAGS=['/DEBUG'])
else:
env.Append(CCFLAGS=['-g3'])
env.Append(CPPDEFINES=['NO_DEFAULT_PROGRESS'])
else:
if 'msvc' in env['TOOLS']:
env.Append(CCFLAGS=['/O2'])
else:
env.Append(CCFLAGS=['-O3'])
if 'msvc' in env['TOOLS']:
env.Append(CCFLAGS=['/W4', '/std:c++17', '/FS', '/EHsc'])
env.Append(CPPDEFINES=['_CRT_SECURE_NO_WARNINGS'])
else:
env.Append(CCFLAGS=['-Wall', '-Wextra', '-pedantic', '-std=c++17'])
if 'g++' in env['TOOLS'] or 'clang++' in env['TOOLS']:
env.Append(CCFLAGS=['-fdiagnostics-color=always'])
if 'clang++' in env['TOOLS']:
# Clang doesn't conform to the standard by default. This fixes it.
env.Append(CCFLAGS=['-frelaxed-template-template-args'])
AddOption('--dev', action='store_true', help='Development build. (assertions and warnings as errors)')
if GetOption('dev'):
if 'msvc' in env['TOOLS']:
env.Append(CCFLAGS=['/WX'])
else:
env.Append(CCFLAGS=['-Werror'])
else:
# Turn off assertions.
env.Append(CPPDEFINES=['NDEBUG'])
# Set multithreaded build as default.
SetOption('num_jobs', multiprocessing.cpu_count())
program = env.Program('karnaugh', env.Glob('./src/*.cc'))
env.Alias('build', program)
env.Replace(PYTHON_EXECUTABLE=sys.executable)
test = env.Alias('test', program, '${ESCAPE(PYTHON_EXECUTABLE)} tests/run.py --diff $SOURCE')
env.AlwaysBuild(test)