gedeng/SConstruct

63 lines
2.0 KiB
Python

#!python
# General utility functions
def add_third_party_includes(env):
env.Append(CPPPATH=['cpp/', 'cpp/vendor/spdlog/include'])
def add_strict_compile_flags(env):
# TODO: Would be good to add "-Werror", but glad.c makes that break
env.Append(CCFLAGS=["-Wall", "-Wextra", "-pedantic", "-std=c++17"])
def add_debug_compile_flags(env):
env.Append(CCFLAGS=["-g"])
# Create the environment and create a Compilation Database for use in VSCodium
env = Environment(tools=['default', 'compilation_db'])
env.CompilationDatabase()
env.Append(CPPPATH=['cpp/', 'include/'])
env.Append(LIBS=['glfw', 'dl', 'freetype'])
add_third_party_includes(env)
add_strict_compile_flags(env)
# Build the library
gedeng = env.SharedLibrary('lib/gedeng', Glob('cpp/*.cpp') + ['cpp/vendor/glad.c'])
# Install the library to the test application's build directory
env.Install('test/bin/lib/', gedeng)
# -------------------------------------------------------------------------------
# Test environment setup
testEnv = Environment(tools=['default', 'compilation_db'])
# No need to call env.CompilationDatabase() on this one, it is now included automatically
testEnv.Append(CPPPATH=['include/', 'test/'])
# Link to the Gedeng library
testEnv.Append(LIBPATH=['lib/'])
testEnv.Append(LIBS=['gedeng'])
# Make the test executables search for the gedeng lib in their ./lib folder
testEnv.Append(LINKFLAGS=[
'-Wl,--disable-new-dtags,-rpath,\'$$ORIGIN/lib/\''
])
add_third_party_includes(testEnv)
add_strict_compile_flags(testEnv)
add_debug_compile_flags(testEnv)
# Build the test programs
catch_cpp = "test/catch_amalgamated.cpp"
testEnv.Program('test/bin/vector-test.out', [catch_cpp, 'test/vector/vector-test.cpp'])
testEnv.Program('test/bin/test-app.out', Glob('test/test-app/*.cpp'))
testEnv.Program('test/bin/parallax-demo.out', Glob('test/parallax-demo/*.cpp'))
testEnv.Program('test/bin/particle-demo.out', Glob('test/particle-demo/*.cpp'))
testEnv.Program('test/bin/shadow-demo.out', Glob('test/shadow-demo/*.cpp'))
testEnv.Program('test/bin/full-demo.out', Glob('test/full-demo/*.cpp'))