189 lines
6.1 KiB
Plaintext
189 lines
6.1 KiB
Plaintext
Import('env')
|
|
Import('env_modules')
|
|
|
|
# TODO Support is turned off for now because Godot 3 doesn't compile with C++17.
|
|
# FastNoise2 use C++17 features and STL in its headers as well.
|
|
# SIMD noise support would have to wait for Godot 4...
|
|
FAST_NOISE_2 = False
|
|
|
|
env_voxel = env_modules.Clone()
|
|
|
|
voxel_files = [
|
|
"*.cpp",
|
|
|
|
"meshers/blocky/*.cpp",
|
|
"meshers/transvoxel/*.cpp",
|
|
"meshers/dmc/*.cpp",
|
|
"meshers/cubes/*.cpp",
|
|
"meshers/*.cpp",
|
|
|
|
"streams/*.cpp",
|
|
"streams/sqlite/*.cpp",
|
|
"streams/region/*.cpp",
|
|
|
|
"storage/*.cpp",
|
|
|
|
"generators/*.cpp",
|
|
"generators/graph/*.cpp",
|
|
"generators/simple/*.cpp",
|
|
|
|
"util/*.cpp",
|
|
#"util/noise/*.cpp",
|
|
"util/noise/fast_noise_lite.cpp",
|
|
"util/noise/fast_noise_lite_gradient.cpp",
|
|
|
|
"terrain/*.cpp",
|
|
"server/*.cpp",
|
|
"math/*.cpp",
|
|
"edition/*.cpp",
|
|
|
|
"thirdparty/lz4/*.c",
|
|
"thirdparty/sqlite/*.c"
|
|
]
|
|
|
|
if env["tools"]:
|
|
# Editor-only stuff
|
|
voxel_editor_files = [
|
|
"editor/*.cpp",
|
|
"editor/graph/*.cpp",
|
|
"editor/terrain/*.cpp",
|
|
"editor/fast_noise_lite/*.cpp",
|
|
]
|
|
voxel_files += voxel_editor_files
|
|
|
|
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})
|
|
|
|
for f in voxel_files:
|
|
env_voxel.add_source_files(env.modules_sources, f)
|
|
|
|
if FAST_NOISE_2:
|
|
if env["use_lto"]:
|
|
# TODO Auburn warned about issues with LTO and static builds of FastNoise2
|
|
# Need to either produce an error, fallback on Scalar, or turn off support entirely?
|
|
pass
|
|
|
|
env_voxel.Append(CPPPATH=["thirdparty/fast_noise_2/include"])
|
|
#env_voxel.Append(CPPDEFINES=["VOXEL_SUPPORT_FAST_NOISE_2"])
|
|
|
|
fn2_sources_common = [
|
|
"thirdparty/fast_noise_2/src/FastNoise/FastNoiseMetadata.cpp"
|
|
"thirdparty/fast_noise_2/src/FastSIMD/FastSIMD.cpp"
|
|
]
|
|
fn2_sources_scalar = [
|
|
"thirdparty/fast_noise_2/src/FastSIMD/FastSIMD_Level_Scalar.cpp"
|
|
]
|
|
fn2_sources_sse3 = [
|
|
"thirdparty/fast_noise_2/src/FastSIMD/FastSIMD_Level_SSE3.cpp"
|
|
]
|
|
fn2_sources_ssse3 = [
|
|
"thirdparty/fast_noise_2/src/FastSIMD/FastSIMD_Level_SSSE3.cpp"
|
|
]
|
|
fn2_sources_sse2 = [
|
|
"thirdparty/fast_noise_2/src/FastSIMD/FastSIMD_Level_SSE2.cpp"
|
|
]
|
|
fn2_sources_sse41 = [
|
|
"thirdparty/fast_noise_2/src/FastSIMD/FastSIMD_Level_SSE41.cpp"
|
|
]
|
|
fn2_sources_sse42 = [
|
|
"thirdparty/fast_noise_2/src/FastSIMD/FastSIMD_Level_SSE42.cpp"
|
|
]
|
|
fn2_sources_avx2 = [
|
|
"thirdparty/fast_noise_2/src/FastSIMD/FastSIMD_Level_AVX2.cpp"
|
|
]
|
|
fn2_sources_avx512 = [
|
|
"thirdparty/fast_noise_2/src/FastSIMD/FastSIMD_Level_AVX512.cpp"
|
|
]
|
|
fn2_sources_arm = [
|
|
"thirdparty/fast_noise_2/src/FastSIMD/FastSIMD_Level_NEON.cpp"
|
|
]
|
|
|
|
env_fn2 = env_voxel.Clone()
|
|
# In case we need common options for FastNoise2 we can add them here
|
|
|
|
env_fn2_scalar = env_fn2.Clone()
|
|
env_fn2_sse2 = env_fn2.Clone()
|
|
env_fn2_sse3 = env_fn2.Clone()
|
|
env_fn2_ssse3 = env_fn2.Clone()
|
|
env_fn2_sse41 = env_fn2.Clone()
|
|
env_fn2_sse42 = env_fn2.Clone()
|
|
env_fn2_avx2 = env_fn2.Clone()
|
|
env_fn2_avx512 = env_fn2.Clone()
|
|
env_fn2_arm = env_fn2.Clone()
|
|
|
|
if env.msvc:
|
|
if env["bits"] == "32":
|
|
# MSVC/64 warns:
|
|
# ignoring unknown option "/arch:SSE2" as 64 bit already has SSE2 built in
|
|
env_fn2_scalar.Append(CCFLAGS=["/arch:SSE"])
|
|
env_fn2_sse2.Append(CCFLAGS=["/arch:SSE2"])
|
|
env_fn2_sse3.Append(CCFLAGS=["/arch:SSE2"])
|
|
env_fn2_ssse3.Append(CCFLAGS=["/arch:SSE2"])
|
|
env_fn2_sse41.Append(CCFLAGS=["/arch:SSE2"])
|
|
env_fn2_sse42.Append(CCFLAGS=["/arch:SSE2"])
|
|
|
|
env_fn2_avx2.Append(CCFLAGS=["/arch:AVX2"])
|
|
env_fn2_avx512.Append(CCFLAGS=["/arch:AVX512"])
|
|
|
|
else: # Clang, GCC, AppleClang
|
|
# TODO The Cmake build script still has a big `if(MSVC)` in that section.
|
|
# what does it mean?
|
|
|
|
if env["bits"] == "32":
|
|
env_fn2_scalar.Append(CCFLAGS=["-msse"])
|
|
env_fn2_sse2.Append(CCFLAGS=["-msse2"])
|
|
|
|
env_fn2_sse3.Append(CCFLAGS=["-msse3"])
|
|
env_fn2_ssse3.Append(CCFLAGS=["-mssse3"])
|
|
env_fn2_sse41.Append(CCFLAGS=["-msse4.1"])
|
|
env_fn2_sse42.Append(CCFLAGS=["-msse4.2"])
|
|
env_fn2_avx2.Append(CCFLAGS=["-mavx2", "-mfma"])
|
|
env_fn2_avx512.Append(CCFLAGS=["-mavx512f", "-mavx512dq", "-mfma"])
|
|
|
|
# TODO This was in the old FastNoiseSIMD repo from Tinmanjuggernaut. Is it still needed?
|
|
# if (env["target"] == "release"):
|
|
# # gcc 9.2.1 won"t compile x64 with -O3
|
|
# env_thirdparty_avx512.Append(CCFLAGS=["-mavx512f", "-O2"])
|
|
# else:
|
|
# env_thirdparty_avx512.Append(CCFLAGS=["-mavx512f"])
|
|
|
|
env_fn2.add_source_files(env.modules_sources, fn2_sources_common)
|
|
env_fn2_scalar.add_source_files(env.modules_sources, fn2_sources_scalar)
|
|
env_fn2_sse2.add_source_files(env.modules_sources, fn2_sources_sse2)
|
|
env_fn2_sse3.add_source_files(env.modules_sources, fn2_sources_sse3)
|
|
env_fn2_ssse3.add_source_files(env.modules_sources, fn2_sources_ssse3)
|
|
env_fn2_sse41.add_source_files(env.modules_sources, fn2_sources_sse41)
|
|
env_fn2_sse42.add_source_files(env.modules_sources, fn2_sources_sse42)
|
|
|
|
if env["platform"] == "android":
|
|
# Both Android and IOS have ARM chips, but only android build tools have necessary headers
|
|
env_fn2_arm.add_source_files(env.modules_sources, fn2_sources_arm)
|
|
|
|
elif env["platform"] in ["windows", "x11", "osx"]:
|
|
# AVX is supported on desktop only
|
|
env_fn2_avx2.add_source_files(env.modules_sources, fn2_sources_avx2)
|
|
env_fn2_avx512.add_source_files(env.modules_sources, fn2_sources_avx512)
|
|
|
|
# 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, because reasons
|
|
#if env.msvc:
|
|
# env_voxel.Append(CXXFLAGS=['/std:c++17'])
|
|
#else:
|
|
# env_voxel.Append(CXXFLAGS=['-std=c++17'])
|
|
|
|
# This also 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'])
|