-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsconstruct.py
More file actions
41 lines (35 loc) · 1.46 KB
/
sconstruct.py
File metadata and controls
41 lines (35 loc) · 1.46 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
import glob
import os
cwd = GetLaunchDir()
root = os.getcwd()
testexe = os.path.join(cwd, 'tests')
testcpp = os.path.join(cwd, 'test.cpp')
with open(testcpp, 'w') as file:
includes = [
*glob.glob(os.path.join(cwd, '**/*_specialization.hpp'), recursive=True),
*glob.glob(os.path.join(cwd, '**/*_test.cpp'), recursive=True),
]
for include in includes:
localized = include.replace(cwd, '.')
file.write(f'#include "{localized}"\n')
print(
f'''
Building executable, "tests", under "{cwd}"
from newly created test.cpp file under "{cwd}"
that includes only *_test.cpp files under "{cwd}"
using sconstruct.py under "{root}".
''')
test = Environment()
# GLM_FORCE_SWIZZLE support swizzling in glm
# GLM_FORCE_PURE disable anonymous structs so we can build with ISO C++
# GLM_ENABLE_EXPERIMENTAL disable anonymous structs so we can build with ISO C++
environment = Environment(
CCFLAGS=(
"/std:c++20 /D GLM_FORCE_SWIZZLE /D GLM_FORCE_PURE /D GLM_ENABLE_EXPERIMENTAL" if test['CC']=='cl' else
"-std=c++20 -Wall -Werror -pedantic-errors -rdynamic -g -D GLM_FORCE_SWIZZLE -D GLM_FORCE_PURE -D GLM_ENABLE_EXPERIMENTAL"),
CPPPATH=[os.path.join(root,path) for path in 'inc lib src sketch'.split()],
# LIBS='glfw GL GLEW'.split(),
)
executable = environment.Program(target=testexe, source=testcpp)
# works on some linux distros, but doesn't work on Ubuntu
# environment.AddPostAction(executable, testexe.replace(cwd,'.'))