godot_voxel/SCsub

142 lines
4.0 KiB
Plaintext

Import("env")
Import("env_modules")
# Note, support for FastNoise2 requires C++17, and only works on x86.
FAST_NOISE_2_SRC = env["voxel_fast_noise_2"]
if not env["arch"].startswith("x86"):
FAST_NOISE_2_SRC = False
RUN_TESTS = env["voxel_tests"]
env_voxel = env_modules.Clone()
voxel_files = [
"*.cpp",
"constants/*.cpp",
"meshers/blocky/*.cpp",
"meshers/transvoxel/*.cpp",
"meshers/dmc/*.cpp",
"meshers/cubes/*.cpp",
"meshers/*.cpp",
"streams/*.cpp",
"streams/sqlite/*.cpp",
"streams/region/*.cpp",
"streams/vox/*.cpp",
"storage/*.cpp",
"generators/*.cpp",
"generators/graph/*.cpp",
"generators/simple/*.cpp",
"util/*.cpp",
"util/math/*.cpp",
"util/godot/*.cpp",
"util/noise/fast_noise_lite/*.cpp",
"util/noise/gd_noise_range.cpp",
"util/thread/*.cpp",
"util/tasks/*.cpp",
"util/tasks/godot/*.cpp",
"terrain/*.cpp",
"terrain/instancing/*.cpp",
"terrain/fixed_lod/*.cpp",
"terrain/variable_lod/*.cpp",
"engine/*.cpp",
"edition/*.cpp",
"thirdparty/lz4/*.c",
"thirdparty/sqlite/*.c",
"thirdparty/meshoptimizer/*.cpp"
]
if env["tools"]:
# Editor-only stuff
voxel_editor_files = [
"editor/*.cpp",
"editor/graph/*.cpp",
"editor/terrain/*.cpp",
"editor/fast_noise_lite/*.cpp",
"editor/instancer/*.cpp",
"editor/instance_library/*.cpp",
"editor/vox/*.cpp",
"editor/mesh_sdf/*.cpp",
]
voxel_files += voxel_editor_files
env_voxel.Append(CPPDEFINES=[
# See https://github.com/zeux/meshoptimizer/issues/311
"MESHOPTIMIZER_ZYLANN_NEVER_COLLAPSE_BORDERS",
# Because of the above, the MeshOptimizer library in this module is different to an official one.
# Godot 4 includes an official version, which means they would both conflict at linking time.
# To prevent this clash we wrap the entire library within an additional namespace.
# This should be solved either by solving issue #311 or by porting the module to a dynamic library (GDExtension).
"MESHOPTIMIZER_ZYLANN_WRAP_LIBRARY_IN_NAMESPACE",
# Tell engine-agnostic code we are using Godot Engine
"ZN_GODOT"
])
if RUN_TESTS:
voxel_files += [
"tests/*.cpp"
]
env_voxel.Append(CPPDEFINES={"VOXEL_RUN_TESTS": 0})
if env["platform"] == "windows":
# When compiling SQLite with Godot on Windows with MSVC, it produces the following warning:
# `sqlite3.c(42754): warning C4996: 'GetVersionExA': was declared deprecated `
# To fix it, let's indicate to SQLite it should not use this function, even if it is available.
# https://stackoverflow.com/questions/20031597/error-c4996-received-when-compiling-sqlite-c-in-visual-studio-2013
env_voxel.Append(CPPDEFINES={"SQLITE_WIN32_GETVERSIONEX": 0})
# ----------------------------------------------------------------------------------------------------------------------
# FastNoise 2
if FAST_NOISE_2_SRC:
if not env.msvc:
# TODO Workaround for https://github.com/Auburn/FastNoise2/issues/80
# FastNoise2 is using MSVC-specific compiler directives.
# Done before calling FastNoise2 SConscript, as FastNoise2 also includes the headers
env_voxel.Append(CXXFLAGS=["-Wno-unknown-pragmas"])
# Build from source. Should be the simplest, but requires C++17
SConscript("thirdparty/fast_noise_2/SConscript", exports = ["env", "env_voxel"])
env_voxel.Append(CPPPATH=["thirdparty/fast_noise_2/include"])
voxel_files += [
"util/noise/fast_noise_2.cpp"
]
if env["tools"]:
voxel_files += [
"editor/fast_noise_2/*.cpp"
]
# ----------------------------------------------------------------------------------------------------------------------
for f in voxel_files:
env_voxel.add_source_files(env.modules_sources, f)
# TODO Check webassembly builds (`env["platform"] == "javascript"`)
# Ignored clang warnings because Godot's codebase is old and isn't using override yet
if env["platform"] in ["osx", "android"]:
env_voxel.Append(CXXFLAGS=["-Wno-inconsistent-missing-override"])
# Doesn't work, since the rest of Godot doesn't use this, linking fails.
# No safe STL boundary checks for you.
#if env["target"] == "debug":
# if env.msvc:
# # Enable STL bound checks, Godot's master environment doesn't do it
# env_voxel.Append(CXXFLAGS=["/D_DEBUG"])