From f13d23c5285748ce7c29d8eea74562f5177dc6d0 Mon Sep 17 00:00:00 2001 From: Max Regan Date: Mon, 14 Nov 2022 22:34:16 -0500 Subject: [PATCH] Minor SConstruct refactoring --- SConstruct | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/SConstruct b/SConstruct index 7b4514d..21bb891 100644 --- a/SConstruct +++ b/SConstruct @@ -6,7 +6,8 @@ from pathlib import Path # File lists # -build_dir = "build/default/" +build_dir = "build/" +variant_dir = build_dir + "default/" src_dir = "src/" program_sources = ["src/main.c"] @@ -37,10 +38,12 @@ test_lib_includes = ["third-party/unity/src/"] # Construct Environments # -VariantDir(build_dir, ".", duplicate=0) -# Minimization flags for later: ["-Oz", "-flto", "-ffunction-sections", "-fdata-sections", "-Wl,--gc-sections"] +VariantDir(variant_dir, ".", duplicate=0) +# Minimization flags for later: +# CCFLAGS = ["-Oz", "-flto", "-ffunction-sections", "-fdata-sections", "-Wl,--gc-sections", "-lreadline"] +CCFLAGS = ["-ggdb", "-O0"] 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.CompilationDatabase() @@ -48,6 +51,7 @@ env.CompilationDatabase() test_env = env.Clone() test_env.Append(CPPPATH=test_lib_includes) + # # Construct Environments # @@ -56,16 +60,16 @@ test_env.Append(CPPPATH=test_lib_includes) 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 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 ] 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 @@ -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 # it. -Copy("compile_commands.json", build_dir + "compile_commands.json") +Copy("compile_commands.json", variant_dir + "compile_commands.json")