2022-08-27 23:00:34 -07:00
|
|
|
Import("env")
|
|
|
|
Import("env_modules")
|
2016-05-01 06:00:02 -07:00
|
|
|
|
2022-08-27 23:00:34 -07:00
|
|
|
# Note, support for FastNoise2 requires C++17, and only works on x86.
|
2022-03-30 15:17:27 -07:00
|
|
|
FAST_NOISE_2_SRC = env["voxel_fast_noise_2"]
|
2022-08-27 23:00:34 -07:00
|
|
|
if not env["arch"].startswith("x86"):
|
|
|
|
FAST_NOISE_2_SRC = False
|
2021-05-08 11:27:33 -07:00
|
|
|
|
2022-03-20 11:29:31 -07:00
|
|
|
RUN_TESTS = env["voxel_tests"]
|
2021-01-09 08:35:40 -08:00
|
|
|
|
2019-05-29 16:45:19 -07:00
|
|
|
env_voxel = env_modules.Clone()
|
2016-05-01 06:00:02 -07:00
|
|
|
|
2021-01-09 08:35:40 -08:00
|
|
|
voxel_files = [
|
2019-05-29 16:45:19 -07:00
|
|
|
"*.cpp",
|
2021-01-28 14:02:49 -08:00
|
|
|
|
2021-02-21 15:58:00 -08:00
|
|
|
"constants/*.cpp",
|
|
|
|
|
2019-05-29 16:45:19 -07:00
|
|
|
"meshers/blocky/*.cpp",
|
|
|
|
"meshers/transvoxel/*.cpp",
|
|
|
|
"meshers/dmc/*.cpp",
|
2020-09-10 16:36:23 -07:00
|
|
|
"meshers/cubes/*.cpp",
|
2019-05-29 16:45:19 -07:00
|
|
|
"meshers/*.cpp",
|
2021-01-28 14:02:49 -08:00
|
|
|
|
2019-05-29 16:45:19 -07:00
|
|
|
"streams/*.cpp",
|
2021-01-28 14:02:49 -08:00
|
|
|
"streams/sqlite/*.cpp",
|
2021-01-31 08:51:42 -08:00
|
|
|
"streams/region/*.cpp",
|
2022-07-17 11:15:32 -07:00
|
|
|
"streams/vox/*.cpp",
|
2021-01-28 14:02:49 -08:00
|
|
|
|
2020-09-14 11:33:02 -07:00
|
|
|
"storage/*.cpp",
|
2021-01-28 14:02:49 -08:00
|
|
|
|
2020-01-26 14:34:26 -08:00
|
|
|
"generators/*.cpp",
|
2020-02-19 11:26:14 -08:00
|
|
|
"generators/graph/*.cpp",
|
2020-12-18 13:19:02 -08:00
|
|
|
"generators/simple/*.cpp",
|
2021-01-09 08:35:40 -08:00
|
|
|
|
2021-01-28 14:02:49 -08:00
|
|
|
"util/*.cpp",
|
2022-02-05 08:14:57 -08:00
|
|
|
|
|
|
|
"util/math/*.cpp",
|
|
|
|
|
2021-02-17 12:34:35 -08:00
|
|
|
"util/godot/*.cpp",
|
2022-02-05 08:14:57 -08:00
|
|
|
|
2022-04-03 12:07:17 -07:00
|
|
|
"util/noise/fast_noise_lite/*.cpp",
|
|
|
|
"util/noise/gd_noise_range.cpp",
|
2022-02-05 08:14:57 -08:00
|
|
|
|
2022-04-18 16:32:37 -07:00
|
|
|
"util/thread/*.cpp",
|
|
|
|
|
2021-12-29 11:08:23 -08:00
|
|
|
"util/tasks/*.cpp",
|
2022-04-07 14:34:07 -07:00
|
|
|
"util/tasks/godot/*.cpp",
|
2021-01-09 08:35:40 -08:00
|
|
|
|
2019-05-29 16:45:19 -07:00
|
|
|
"terrain/*.cpp",
|
2021-02-07 13:40:55 -08:00
|
|
|
"terrain/instancing/*.cpp",
|
2022-03-20 15:57:53 -07:00
|
|
|
"terrain/fixed_lod/*.cpp",
|
|
|
|
"terrain/variable_lod/*.cpp",
|
2021-02-07 13:40:55 -08:00
|
|
|
|
2022-07-16 15:59:06 -07:00
|
|
|
"engine/*.cpp",
|
2020-01-26 12:29:44 -08:00
|
|
|
"edition/*.cpp",
|
2021-01-28 14:02:49 -08:00
|
|
|
|
|
|
|
"thirdparty/lz4/*.c",
|
2021-07-11 08:19:49 -07:00
|
|
|
"thirdparty/sqlite/*.c",
|
|
|
|
"thirdparty/meshoptimizer/*.cpp"
|
2019-05-29 16:45:19 -07:00
|
|
|
]
|
|
|
|
|
2020-12-04 14:01:41 -08:00
|
|
|
if env["tools"]:
|
|
|
|
# Editor-only stuff
|
2021-01-09 08:35:40 -08:00
|
|
|
voxel_editor_files = [
|
2020-12-04 14:01:41 -08:00
|
|
|
"editor/*.cpp",
|
|
|
|
"editor/graph/*.cpp",
|
|
|
|
"editor/terrain/*.cpp",
|
2021-01-01 16:59:12 -08:00
|
|
|
"editor/fast_noise_lite/*.cpp",
|
2021-12-30 14:20:30 -08:00
|
|
|
"editor/instancer/*.cpp",
|
2021-02-14 13:55:31 -08:00
|
|
|
"editor/instance_library/*.cpp",
|
2021-07-31 10:48:47 -07:00
|
|
|
"editor/vox/*.cpp",
|
2022-05-05 12:57:59 -07:00
|
|
|
"editor/mesh_sdf/*.cpp",
|
2020-12-04 14:01:41 -08:00
|
|
|
]
|
2021-01-09 08:35:40 -08:00
|
|
|
voxel_files += voxel_editor_files
|
2020-12-04 14:01:41 -08:00
|
|
|
|
2021-12-13 13:38:10 -08:00
|
|
|
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).
|
2022-04-10 12:10:33 -07:00
|
|
|
"MESHOPTIMIZER_ZYLANN_WRAP_LIBRARY_IN_NAMESPACE",
|
|
|
|
# Tell engine-agnostic code we are using Godot Engine
|
|
|
|
"ZN_GODOT"
|
2021-12-13 13:38:10 -08:00
|
|
|
])
|
2021-07-11 08:19:49 -07:00
|
|
|
|
2021-04-03 12:40:35 -07:00
|
|
|
if RUN_TESTS:
|
|
|
|
voxel_files += [
|
2021-06-19 10:34:50 -07:00
|
|
|
"tests/*.cpp"
|
2021-04-03 12:40:35 -07:00
|
|
|
]
|
|
|
|
env_voxel.Append(CPPDEFINES={"VOXEL_RUN_TESTS": 0})
|
|
|
|
|
2021-01-28 14:02:49 -08:00
|
|
|
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})
|
|
|
|
|
2021-02-20 19:02:32 -08:00
|
|
|
# ----------------------------------------------------------------------------------------------------------------------
|
|
|
|
# FastNoise 2
|
|
|
|
|
|
|
|
if FAST_NOISE_2_SRC:
|
2022-01-08 10:58:31 -08:00
|
|
|
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"])
|
|
|
|
|
2021-02-20 19:02:32 -08:00
|
|
|
# Build from source. Should be the simplest, but requires C++17
|
2022-08-27 23:00:34 -07:00
|
|
|
SConscript("thirdparty/fast_noise_2/SConscript", exports = ["env", "env_voxel"])
|
2022-01-08 10:58:31 -08:00
|
|
|
|
2021-12-30 21:06:00 -08:00
|
|
|
env_voxel.Append(CPPPATH=["thirdparty/fast_noise_2/include"])
|
|
|
|
|
2021-02-20 19:02:32 -08:00
|
|
|
voxel_files += [
|
|
|
|
"util/noise/fast_noise_2.cpp"
|
|
|
|
]
|
2019-05-29 16:45:19 -07:00
|
|
|
|
2021-12-30 21:06:00 -08:00
|
|
|
if env["tools"]:
|
|
|
|
voxel_files += [
|
|
|
|
"editor/fast_noise_2/*.cpp"
|
|
|
|
]
|
2021-01-09 08:35:40 -08:00
|
|
|
|
2021-02-20 19:02:32 -08:00
|
|
|
# ----------------------------------------------------------------------------------------------------------------------
|
2021-01-09 08:35:40 -08:00
|
|
|
|
2021-02-20 19:02:32 -08:00
|
|
|
for f in voxel_files:
|
|
|
|
env_voxel.add_source_files(env.modules_sources, f)
|
2021-01-09 08:35:40 -08:00
|
|
|
|
2021-02-20 19:02:32 -08:00
|
|
|
# TODO Check webassembly builds (`env["platform"] == "javascript"`)
|
2021-01-09 08:35:40 -08:00
|
|
|
|
2020-03-28 08:20:49 -07:00
|
|
|
# Ignored clang warnings because Godot's codebase is old and isn't using override yet
|
2022-08-27 23:00:34 -07:00
|
|
|
if env["platform"] in ["osx", "android"]:
|
|
|
|
env_voxel.Append(CXXFLAGS=["-Wno-inconsistent-missing-override"])
|
2020-03-28 08:20:49 -07:00
|
|
|
|
2022-01-08 10:56:06 -08:00
|
|
|
# Doesn't work, since the rest of Godot doesn't use this, linking fails.
|
2019-08-23 14:49:43 -07:00
|
|
|
# No safe STL boundary checks for you.
|
2022-08-27 23:00:34 -07:00
|
|
|
#if env["target"] == "debug":
|
2019-08-23 14:49:43 -07:00
|
|
|
# if env.msvc:
|
|
|
|
# # Enable STL bound checks, Godot's master environment doesn't do it
|
2022-08-27 23:00:34 -07:00
|
|
|
# env_voxel.Append(CXXFLAGS=["/D_DEBUG"])
|