-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSConstruct
50 lines (38 loc) · 972 Bytes
/
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
import multiprocessing
TEST_SUITE = "test_suite"
CFLAGS = [
"-Wall",
"-Wextra",
"-pedantic",
"-g",
"-O0",
]
def PhonyTargets(
target,
action,
depends,
env=None,
):
# Creates a Phony target
if not env:
env = DefaultEnvironment()
t = env.Alias(target, depends, action)
env.AlwaysBuild(t)
def main():
num_cpu = multiprocessing.cpu_count()
SetOption("num_jobs", num_cpu)
print("Running with -j {}".format(GetOption("num_jobs")))
env_options = {
"CPPPATH": ["."],
"CPPDEFINES": [],
"CCFLAGS": CFLAGS,
"LIBS": ["-lcmocka"],
}
env = Environment(**env_options)
env.Tool("compilation_db")
sources = Glob(f"test/*.c")
tests = env.Program(f"test/{TEST_SUITE}", sources)
compileDB = env.CompilationDatabase('compile_commands.json')
env.Depends(tests, compileDB)
PhonyTargets("test", f"cd test && ./{TEST_SUITE}", tests, env)
main()