diff --git a/.gitignore b/.gitignore index 6775093..637300e 100644 --- a/.gitignore +++ b/.gitignore @@ -75,4 +75,7 @@ bin/* *.translation !game/common/map/*.obj -/compile_commands.json \ No newline at end of file +/compile_commands.json + +# Out-of-source build directory +build/ \ No newline at end of file diff --git a/SConstruct b/SConstruct index 9374a28..f39d294 100644 --- a/SConstruct +++ b/SConstruct @@ -19,6 +19,26 @@ opts.Add(BoolVariable("build_lvdf_headless", "Build the lexy vdf headless execut env.FinalizeOptions() +suffix = ".{}.{}".format(env["platform"], env["target"]) +if env.dev_build: + suffix += ".dev" +if env["precision"] == "double": + suffix += ".double" +suffix += "." + env["arch"] +if env["platform"] == "windows": + if env.get("debug_crt", False): + suffix += ".mdd" + elif env.get("use_static_cpp", False): + suffix += ".mt" + else: + suffix += ".md" +if env.get("use_asan", False): + suffix += ".san" +env["suffix"] = suffix + +build_dir = env.Dir("build/" + suffix.lstrip(".")).abspath.replace("\\", "/") +env["build_dir"] = build_dir + SConscript("deps/SCsub", "env") env.lexy_vdf = {} @@ -34,20 +54,15 @@ env.lexy_vdf = {} # tweak this if you want to use different folders, or more folders, to store your source code in. source_path = "src/lexy-vdf" include_path = "include" -env.Append(CPPPATH=[[env.Dir(p) for p in [source_path, include_path]]]) -sources = env.GlobRecursive("*.cpp", [source_path]) +# Mirror the lexy-vdf source tree into the per-config build dir. +lexyvdf_variant = build_dir + "/" + source_path +env.VariantDir(lexyvdf_variant, source_path, duplicate=True) +# Variant-only CPPPATH for source_path; include_path stays source-side as the +# public API root. +env.Append(CPPPATH=[[env.Dir(p) for p in [include_path, lexyvdf_variant]]]) +sources = env.GlobRecursive("*.cpp", [lexyvdf_variant]) env.lexy_vdf_sources = sources -suffix = ".{}.{}".format(env["platform"], env["target"]) -if env.dev_build: - suffix += ".dev" -if env["precision"] == "double": - suffix += ".double" -suffix += "." + env["arch"] - -# Expose it when included from another project -env["suffix"] = suffix - library = None env["OBJSUFFIX"] = suffix + env["OBJSUFFIX"] library_name = "liblexy-vdf{}{}".format(suffix, env["LIBSUFFIX"]) @@ -71,10 +86,12 @@ env["PROGSUFFIX"] = suffix + env["PROGSUFFIX"] if env["build_lvdf_headless"]: headless_name = "lexy-vdf" headless_env = env.Clone() - headless_path = ["src/headless"] + headless_src = "src/headless" + headless_variant = build_dir + "/" + headless_src + headless_env.VariantDir(headless_variant, headless_src, duplicate=True) headless_env.Append(CPPDEFINES=["LEXY_VDF_HEADLESS"]) - headless_env.Append(CPPPATH=[headless_env.Dir(headless_path)]) - headless_env.headless_sources = env.GlobRecursive("*.cpp", headless_path) + headless_env.Append(CPPPATH=[headless_env.Dir(headless_variant)]) + headless_env.headless_sources = env.GlobRecursive("*.cpp", [headless_variant]) if not env["build_lvdf_library"]: headless_env.headless_sources += sources headless_program = headless_env.Program( diff --git a/deps/SCsub b/deps/SCsub index eb27dab..ac377c2 100644 --- a/deps/SCsub +++ b/deps/SCsub @@ -1,5 +1,7 @@ #!/usr/bin/env python +import os + Import("env") def build_lexy(env): @@ -26,10 +28,14 @@ def build_lexy(env): paths = ["lexy/include", "lexy/src"] lexy_env.Append(CPPPATH=[[lexy_env.Dir(p) for p in paths]]) - sources = env.GlobRecursive("*.cpp", paths) + # Mirror lexy's source tree into the per-config build dir. + build_root = (env.get("build_dir") or env.Dir("#").abspath).replace("\\", "/") + lexy_out = build_root + "/lexy/lexy/src" + lexy_env.VariantDir(lexy_out, "lexy/src", duplicate=True) + sources = env.GlobRecursive("*.cpp", [lexy_out]) env.lexy_sources = sources - library_name = "liblexy_file" + env["LIBSUFFIX"] - library = lexy_env.StaticLibrary(target="lexy/src/" + library_name, source=sources) + library_name = "liblexy_file" + env.get("suffix", "") + env["LIBSUFFIX"] + library = lexy_env.StaticLibrary(target=lexy_out + "/" + library_name, source=sources) Default(library) env.Append(CPPPATH=[lexy_env.Dir("lexy/include")]) @@ -38,7 +44,7 @@ def build_lexy(env): else: env.Append(CXXFLAGS=["-isystem", lexy_env.Dir("lexy/include")]) env.Append(CXXFLAGS=[""]) - env.Append(LIBPATH=[lexy_env.Dir("lexy/src")]) + env.Append(LIBPATH=[lexy_env.Dir(lexy_out)]) env.Prepend(LIBS=[library_name]) diff --git a/scripts b/scripts index 4ddc9a1..d8f908c 160000 --- a/scripts +++ b/scripts @@ -1 +1 @@ -Subproject commit 4ddc9a1b9b14fddab397325a1d016de56d465d75 +Subproject commit d8f908cb2d7b4a4564d12f71cbfe97bed241195f