Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,6 @@ tests/bin/*
!game/common/map/*.obj

compile_commands.json

# Out-of-source build directory
build/
45 changes: 30 additions & 15 deletions SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,26 @@ opts.Add(

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

env.exposed_includes = []

SConscript("deps/SCsub", "env")
Expand All @@ -45,20 +65,13 @@ env.openvic_dataloader = {}
# tweak this if you want to use different folders, or more folders, to store your source code in.
source_path = "src/openvic-dataloader"
include_path = "include"
env.Append(CPPPATH=[[env.Dir(p) for p in [source_path, include_path]]])
sources = env.GlobRecursive("*.cpp", [source_path])
# Mirror the dataloader source tree into the per-config build dir.
dataloader_variant = build_dir + "/" + source_path
env.VariantDir(dataloader_variant, source_path, duplicate=True)
env.Append(CPPPATH=[[env.Dir(p) for p in [include_path, dataloader_variant]]])
sources = env.GlobRecursive("*.cpp", [dataloader_variant])
env.dataloader_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 = "libopenvic-dataloader{}{}".format(suffix, env["LIBSUFFIX"])
Expand Down Expand Up @@ -94,10 +107,12 @@ env["PROGSUFFIX"] = suffix + env["PROGSUFFIX"]
if env["build_ovdl_headless"]:
headless_name = "openvic-dataloader"
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=["OPENVIC_DATALOADER_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_ovdl_library"]:
headless_env.headless_sources += sources
headless_program = headless_env.Program(
Expand Down
38 changes: 24 additions & 14 deletions deps/SCsub
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env python
import os

Import("env")

Expand Down Expand Up @@ -35,22 +34,25 @@ def build_lexy(env):
include_path = "lexy/include"
source_path = "lexy/src"
lexy_env.Append(CPPPATH=[[lexy_env.Dir(p) for p in [source_path, include_path]]])
sources = env.GlobRecursive("*.cpp", [source_path])
# 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/" + source_path
lexy_env.VariantDir(lexy_out, source_path, duplicate=True)
sources = env.GlobRecursive("*.cpp", [lexy_out])
env.lexy_sources = sources

library_name = "liblexy_file" + env["LIBSUFFIX"]
library = lexy_env.StaticLibrary(target=os.path.join(source_path, 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)

include_dir = lexy_env.Dir(include_path)
source_dir = lexy_env.Dir(source_path)
env.Append(CPPPATH=[include_dir])
if env.get("is_msvc", False):
env.Append(CXXFLAGS=["/external:I", include_dir, "/external:W0"])
else:
env.Append(CXXFLAGS=["-isystem", include_dir])
env.Append(CXXFLAGS=[""])
env.Append(LIBPATH=[source_dir])
env.Append(LIBPATH=[lexy_env.Dir(lexy_out)])
env.Prepend(LIBS=[library_name])


Expand Down Expand Up @@ -121,11 +123,15 @@ def build_fmt(env):
source_path = "fmt/src"
paths = [include_path, source_path]
fmt_env.Append(CPPPATH=[[fmt_env.Dir(p) for p in paths]])
sources = env.GlobRecursive("*.cc", paths, os.path.join(source_path, "fmt.cc"))
# Mirror fmt's source tree into the per-config build dir.
build_root = (env.get("build_dir") or env.Dir("#").abspath).replace("\\", "/")
fmt_out = build_root + "/fmt/" + source_path
fmt_env.VariantDir(fmt_out, source_path, duplicate=True)
sources = env.GlobRecursive("*.cc", [fmt_out], fmt_out + "/fmt.cc")
env.lexy_sources = sources

library_name = "libfmt" + env["LIBSUFFIX"]
library = fmt_env.StaticLibrary(target=os.path.join(source_path, library_name), source=sources)
library_name = "libfmt" + env.get("suffix", "") + env["LIBSUFFIX"]
library = fmt_env.StaticLibrary(target=fmt_out + "/" + library_name, source=sources)
Default(library)

include_dir = fmt_env.Dir(include_path)
Expand All @@ -139,7 +145,7 @@ def build_fmt(env):
else:
env.Append(CXXFLAGS=["-isystem", include_dir])
env.Append(CXXFLAGS=[""])
env.Append(LIBPATH=[fmt_env.Dir(source_path)])
env.Append(LIBPATH=[fmt_env.Dir(fmt_out)])
env.Prepend(LIBS=[library_name])

env.exposed_includes += env.fmt["INCPATH"]
Expand Down Expand Up @@ -171,11 +177,15 @@ def build_vmcontainer(env):
source_path = "vmcontainer/lib/src"
paths = [include_path, source_path]
vmcontainer_env.Append(CPPPATH=[[vmcontainer_env.Dir(p) for p in paths]])
sources = env.GlobRecursive("*.cpp", paths)
# Mirror vmcontainer's source tree into the per-config build dir.
build_root = (env.get("build_dir") or env.Dir("#").abspath).replace("\\", "/")
vmcontainer_out = build_root + "/vmcontainer/" + source_path
vmcontainer_env.VariantDir(vmcontainer_out, source_path, duplicate=True)
sources = env.GlobRecursive("*.cpp", [vmcontainer_out])
env.vmcontainer_sources = sources

library_name = "libvmcontainer" + env["LIBSUFFIX"]
library = vmcontainer_env.StaticLibrary(target=os.path.join(source_path, library_name), source=sources)
library_name = "libvmcontainer" + env.get("suffix", "") + env["LIBSUFFIX"]
library = vmcontainer_env.StaticLibrary(target=vmcontainer_out + "/" + library_name, source=sources)
Default(library)

include_dir = vmcontainer_env.Dir(include_path)
Expand All @@ -189,7 +199,7 @@ def build_vmcontainer(env):
else:
env.Append(CXXFLAGS=["-isystem", include_dir])
env.Append(CXXFLAGS=[""])
env.Append(LIBPATH=[vmcontainer_env.Dir(source_path)])
env.Append(LIBPATH=[vmcontainer_env.Dir(vmcontainer_out)])
env.Prepend(LIBS=[library_name])

env.exposed_includes += env.vmcontainer["INCPATH"]
Expand Down
2 changes: 1 addition & 1 deletion scripts
Loading