Minor SConstruct refactoring

This commit is contained in:
2022-11-14 22:34:16 -05:00
parent a87cab2452
commit f13d23c528

View File

@@ -6,7 +6,8 @@ from pathlib import Path
# File lists # File lists
# #
build_dir = "build/default/" build_dir = "build/"
variant_dir = build_dir + "default/"
src_dir = "src/" src_dir = "src/"
program_sources = ["src/main.c"] program_sources = ["src/main.c"]
@@ -37,10 +38,12 @@ test_lib_includes = ["third-party/unity/src/"]
# Construct Environments # Construct Environments
# #
VariantDir(build_dir, ".", duplicate=0) VariantDir(variant_dir, ".", duplicate=0)
# Minimization flags for later: ["-Oz", "-flto", "-ffunction-sections", "-fdata-sections", "-Wl,--gc-sections"] # Minimization flags for later:
# CCFLAGS = ["-Oz", "-flto", "-ffunction-sections", "-fdata-sections", "-Wl,--gc-sections", "-lreadline"]
CCFLAGS = ["-ggdb", "-O0"]
env = Environment( env = Environment(
CPPPATH=lib_includes, COMPILATIONDB_USE_ABSPATH=True, CCFLAGS=["-ggdb", "-O0"] CPPPATH=lib_includes, COMPILATIONDB_USE_ABSPATH=True, CCFLAGS=CCFLAGS
) )
env.Tool("compilation_db") env.Tool("compilation_db")
env.CompilationDatabase() env.CompilationDatabase()
@@ -48,6 +51,7 @@ env.CompilationDatabase()
test_env = env.Clone() test_env = env.Clone()
test_env.Append(CPPPATH=test_lib_includes) test_env.Append(CPPPATH=test_lib_includes)
# #
# Construct Environments # Construct Environments
# #
@@ -56,16 +60,16 @@ test_env.Append(CPPPATH=test_lib_includes)
lib_objs = [env.Object(p) for p in lib_srcs] lib_objs = [env.Object(p) for p in lib_srcs]
env.Program(build_dir + "uclisp", lib_objs + program_sources) env.Program(variant_dir + "uclisp", lib_objs + program_sources, LIBS=["readline"])
# Generate unit test executables # Generate unit test executables
test_lib_objs = [ test_lib_objs = [
test_env.Object(build_dir + p, CPPPATH=lib_includes + test_lib_includes) test_env.Object(variant_dir + p, CPPPATH=lib_includes + test_lib_includes)
for p in test_lib_srcs for p in test_lib_srcs
] ]
test_deps = test_lib_objs + lib_objs test_deps = test_lib_objs + lib_objs
tests = [test_env.Program(build_dir + p, [p] + test_deps) for p in test_srcs] tests = [test_env.Program(variant_dir + p, [p] + test_deps) for p in test_srcs]
# #
# Generate Test Runner script # Generate Test Runner script
@@ -78,8 +82,8 @@ env.Substfile(
}, },
) )
env.Command(build_dir + "run_tests", "run_tests.sh", Chmod("run_tests.sh", 0o755)) env.Command(variant_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 # Copy default build compile commands to root, which is where tools seem to want
# it. # it.
Copy("compile_commands.json", build_dir + "compile_commands.json") Copy("compile_commands.json", variant_dir + "compile_commands.json")