Move to scons, add more infra
This commit is contained in:
63
SConstruct
Normal file
63
SConstruct
Normal file
@@ -0,0 +1,63 @@
|
||||
from pathlib import Path
|
||||
|
||||
#
|
||||
# File lists
|
||||
#
|
||||
|
||||
build_dir = "build/default/"
|
||||
src_dir = "src/"
|
||||
|
||||
program_sources = ["src/main.c"]
|
||||
lib_srcs = []
|
||||
lib_includes = ["src/"]
|
||||
|
||||
test_srcs = [""]
|
||||
test_lib_srcs = ["third-party/unity/src/unity.c"]
|
||||
test_lib_includes = ["third-party/unity/src/"]
|
||||
|
||||
#
|
||||
# Construct Environments
|
||||
#
|
||||
|
||||
VariantDir(build_dir, ".", duplicate=0)
|
||||
env = Environment(CPPPATH=lib_includes, COMPILATIONDB_USE_ABSPATH=True)
|
||||
env.Tool('compilation_db')
|
||||
env.CompilationDatabase()
|
||||
|
||||
test_env = env.Clone()
|
||||
test_env.Append(CPPPATH=test_lib_includes)
|
||||
|
||||
#
|
||||
# Construct Environments
|
||||
#
|
||||
|
||||
# Generate REPL
|
||||
|
||||
|
||||
lib_objs = [env.Object(p) for p in lib_srcs]
|
||||
env.Program(build_dir + "nihilispm", lib_objs + program_sources)
|
||||
|
||||
# Generate unit test executables
|
||||
|
||||
test_lib_objs = [
|
||||
test_env.Object(build_dir + p, CPPPATH=lib_includes + test_lib_includes) for p in test_lib_srcs
|
||||
]
|
||||
test_deps = test_lib_objs + lib_objs
|
||||
tests = [test_env.Program(build_dir + p, [p] + test_deps) for p in test_srcs]
|
||||
|
||||
#
|
||||
# Generate Test Runner script
|
||||
#
|
||||
|
||||
env.Substfile(
|
||||
"run_tests.sh.in",
|
||||
SUBST_DICT={
|
||||
"@tests@": " ".join(str(Path(str(test[0])).resolve()) for test in tests)
|
||||
},
|
||||
)
|
||||
|
||||
env.Command(build_dir + "run_tests", "run_tests.sh", Chmod("run_tests.sh", 0o755))
|
||||
|
||||
# Copy default build compile commands to root, which is where tools seem to want
|
||||
# it.
|
||||
Copy("compile_commands.json", build_dir + "compile_commands.json")
|
||||
Reference in New Issue
Block a user