2019-06-08 00:07:57 +08:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
2020-03-30 14:28:32 +08:00
|
|
|
Import("env")
|
2019-06-08 00:07:57 +08:00
|
|
|
|
2020-12-17 23:01:36 +08:00
|
|
|
thirdparty_obj = []
|
2019-06-08 00:07:57 +08:00
|
|
|
|
2020-07-26 19:20:08 +08:00
|
|
|
# FIXME: Refactor all this to reduce code duplication.
|
2020-03-06 02:00:28 +08:00
|
|
|
if env["platform"] == "android":
|
|
|
|
# Use NDK Vulkan headers
|
|
|
|
thirdparty_dir = env["ANDROID_NDK_ROOT"] + "/sources/third_party/vulkan/src"
|
2020-03-28 00:30:18 +08:00
|
|
|
thirdparty_includes = [
|
|
|
|
thirdparty_dir,
|
|
|
|
thirdparty_dir + "/include",
|
|
|
|
thirdparty_dir + "/layers",
|
|
|
|
thirdparty_dir + "/layers/generated",
|
|
|
|
]
|
2020-03-06 02:00:28 +08:00
|
|
|
env.Prepend(CPPPATH=thirdparty_includes)
|
2020-04-10 16:32:11 +08:00
|
|
|
|
|
|
|
# Build Vulkan memory allocator
|
|
|
|
env_thirdparty = env.Clone()
|
|
|
|
env_thirdparty.disable_warnings()
|
|
|
|
|
|
|
|
thirdparty_dir = "#thirdparty/vulkan"
|
|
|
|
vma_sources = [thirdparty_dir + "/android/vk_mem_alloc.cpp"]
|
2020-12-17 23:01:36 +08:00
|
|
|
env_thirdparty.add_source_files(thirdparty_obj, vma_sources)
|
|
|
|
|
2020-07-17 01:04:09 +08:00
|
|
|
elif env["platform"] == "iphone":
|
|
|
|
# Use bundled Vulkan headers
|
|
|
|
thirdparty_dir = "#thirdparty/vulkan"
|
|
|
|
env.Prepend(CPPPATH=[thirdparty_dir, thirdparty_dir + "/include", thirdparty_dir + "/loader"])
|
|
|
|
|
|
|
|
# Build Vulkan memory allocator
|
|
|
|
env_thirdparty = env.Clone()
|
|
|
|
env_thirdparty.disable_warnings()
|
|
|
|
|
|
|
|
vma_sources = [thirdparty_dir + "/vk_mem_alloc.cpp"]
|
2020-12-17 23:01:36 +08:00
|
|
|
env_thirdparty.add_source_files(thirdparty_obj, vma_sources)
|
|
|
|
|
2020-03-06 02:00:28 +08:00
|
|
|
elif env["builtin_vulkan"]:
|
2019-08-05 17:48:54 +08:00
|
|
|
# Use bundled Vulkan headers
|
|
|
|
thirdparty_dir = "#thirdparty/vulkan"
|
2020-02-11 21:01:43 +08:00
|
|
|
env.Prepend(CPPPATH=[thirdparty_dir, thirdparty_dir + "/include", thirdparty_dir + "/loader"])
|
2019-06-08 00:07:57 +08:00
|
|
|
|
2019-08-05 17:48:54 +08:00
|
|
|
# Build Vulkan loader library
|
|
|
|
env_thirdparty = env.Clone()
|
|
|
|
env_thirdparty.disable_warnings()
|
|
|
|
|
|
|
|
loader_sources = [
|
|
|
|
"cJSON.c",
|
|
|
|
"debug_utils.c",
|
|
|
|
"dev_ext_trampoline.c",
|
|
|
|
"loader.c",
|
|
|
|
"murmurhash.c",
|
|
|
|
"phys_dev_ext.c",
|
|
|
|
"trampoline.c",
|
|
|
|
"unknown_ext_chain.c",
|
|
|
|
"wsi.c",
|
|
|
|
"extension_manual.c",
|
|
|
|
]
|
2020-02-11 21:01:43 +08:00
|
|
|
vma_sources = [thirdparty_dir + "/vk_mem_alloc.cpp"]
|
2019-08-05 17:48:54 +08:00
|
|
|
|
2020-03-30 14:28:32 +08:00
|
|
|
if env["platform"] == "windows":
|
2019-08-05 17:48:54 +08:00
|
|
|
loader_sources.append("dirent_on_windows.c")
|
2020-03-30 14:28:32 +08:00
|
|
|
env_thirdparty.AppendUnique(
|
|
|
|
CPPDEFINES=[
|
|
|
|
"VK_USE_PLATFORM_WIN32_KHR",
|
|
|
|
"VULKAN_NON_CMAKE_BUILD",
|
|
|
|
"WIN32_LEAN_AND_MEAN",
|
|
|
|
'API_NAME=\\"%s\\"' % "Vulkan",
|
|
|
|
]
|
|
|
|
)
|
|
|
|
if not env.msvc: # Windows 7+, missing in mingw headers
|
|
|
|
env_thirdparty.AppendUnique(
|
|
|
|
CPPDEFINES=["CM_GETIDLIST_FILTER_CLASS=0x00000200", "CM_GETIDLIST_FILTER_PRESENT=0x00000100"]
|
|
|
|
)
|
|
|
|
elif env["platform"] == "osx":
|
|
|
|
env_thirdparty.AppendUnique(
|
|
|
|
CPPDEFINES=[
|
|
|
|
"VK_USE_PLATFORM_MACOS_MVK",
|
|
|
|
"VULKAN_NON_CMAKE_BUILD",
|
|
|
|
'SYSCONFDIR=\\"%s\\"' % "/etc",
|
|
|
|
'FALLBACK_DATA_DIRS=\\"%s\\"' % "/usr/local/share:/usr/share",
|
|
|
|
'FALLBACK_CONFIG_DIRS=\\"%s\\"' % "/etc/xdg",
|
|
|
|
]
|
|
|
|
)
|
|
|
|
elif env["platform"] == "linuxbsd":
|
|
|
|
env_thirdparty.AppendUnique(
|
|
|
|
CPPDEFINES=[
|
|
|
|
"VK_USE_PLATFORM_XLIB_KHR",
|
|
|
|
"VULKAN_NON_CMAKE_BUILD",
|
|
|
|
'SYSCONFDIR=\\"%s\\"' % "/etc",
|
|
|
|
'FALLBACK_DATA_DIRS=\\"%s\\"' % "/usr/local/share:/usr/share",
|
|
|
|
'FALLBACK_CONFIG_DIRS=\\"%s\\"' % "/etc/xdg",
|
|
|
|
]
|
|
|
|
)
|
2020-02-14 22:32:03 +08:00
|
|
|
import platform
|
2020-03-30 14:28:32 +08:00
|
|
|
|
|
|
|
if platform.system() == "Linux":
|
2020-02-14 22:32:03 +08:00
|
|
|
# In glibc since 2.17 and musl libc since 1.1.24. Used by loader.c.
|
2020-03-30 14:28:32 +08:00
|
|
|
env_thirdparty.AppendUnique(CPPDEFINES=["HAVE_SECURE_GETENV"])
|
2019-08-05 17:48:54 +08:00
|
|
|
|
|
|
|
loader_sources = [thirdparty_dir + "/loader/" + file for file in loader_sources]
|
2020-12-17 23:01:36 +08:00
|
|
|
env_thirdparty.add_source_files(thirdparty_obj, loader_sources)
|
|
|
|
env_thirdparty.add_source_files(thirdparty_obj, vma_sources)
|
|
|
|
|
2020-07-26 19:20:08 +08:00
|
|
|
else: # Always build VMA.
|
|
|
|
thirdparty_dir = "#thirdparty/vulkan"
|
2021-07-22 21:29:24 +08:00
|
|
|
env.Prepend(CPPPATH=[thirdparty_dir, thirdparty_dir + "/include"])
|
2020-07-26 19:20:08 +08:00
|
|
|
|
|
|
|
# Build Vulkan loader library
|
|
|
|
env_thirdparty = env.Clone()
|
|
|
|
env_thirdparty.disable_warnings()
|
|
|
|
vma_sources = [thirdparty_dir + "/vk_mem_alloc.cpp"]
|
|
|
|
|
2020-12-17 23:01:36 +08:00
|
|
|
env_thirdparty.add_source_files(thirdparty_obj, vma_sources)
|
|
|
|
|
|
|
|
|
|
|
|
env.drivers_sources += thirdparty_obj
|
|
|
|
|
|
|
|
|
|
|
|
# Godot source files
|
|
|
|
|
|
|
|
driver_obj = []
|
|
|
|
|
|
|
|
env.add_source_files(driver_obj, "*.cpp")
|
|
|
|
env.drivers_sources += driver_obj
|
|
|
|
|
|
|
|
# Needed to force rebuilding the driver files when the thirdparty code is updated.
|
|
|
|
env.Depends(driver_obj, thirdparty_obj)
|