blob: 49e2742739bfc46776e7d90d798afc47873006ae (
plain) (
blame)
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
|
#!/usr/bin/env python
import os
import subprocess
import platform
import sys
import SCons
from SCons.Script.SConscript import SConsEnvironment
def UnitTestPostAction(target=None, source=None, env=None):
print()
return subprocess.run([target[0].path]).returncode
def UnitTest(env, **kwargs):
test = env.Program(**kwargs)
unit_test_action = env.Action(UnitTestPostAction, None)
test_post_action = env.AddPostAction(test, unit_test_action)
env.NoCache(test)
env.AlwaysBuild(test_post_action)
return test
SConsEnvironment.UnitTest = UnitTest
Import("env")
BINDIR = "bin"
env.openvic_dataloader_tests = {}
# For the reference:
# - CCFLAGS are compilation flags shared between C and C++
# - CFLAGS are for C-specific compilation flags
# - CXXFLAGS are for C++-specific compilation flags
# - CPPFLAGS are for pre-processor flags
# - CPPDEFINES are for pre-processor defines
# - LINKFLAGS are for linking flags
# tweak this if you want to use different folders, or more folders, to store your source code in.
source_path = "src"
tests_name = "openvic-dataloader"
tests_env = env.Clone()
tests_env.Append(CPPDEFINES=["OPENVIC_DATALOADER_TESTS"])
tests_env.Append(CPPPATH=[tests_env.Dir(source_path)])
tests_env.tests_sources = env.GlobRecursive("*.cpp", [source_path])
SConscript("deps/SCsub", {"env": tests_env })
# Blame Ubuntu 22's GCC-12 distribution for this crap
# Compiler bug hangs if it can see if there is any reference to \x8F in a character
if env["ubuntu_gcc_invalid_char_hang_bug"]:
tests_env.Append(CPPDEFINES=["_OVDL_TEST_UBUNTU_GCC_12_BUG_"])
tests_program = tests_env.UnitTest(
source=tests_env.tests_sources,
target=os.path.join(BINDIR, tests_name),
PROGSUFFIX=".tests" + env["PROGSUFFIX"]
)
Default(tests_program)
|