SCsub 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. #!/usr/bin/env python
  2. Import("env")
  3. thirdparty_obj = []
  4. thirdparty_dir = "#thirdparty/vulkan"
  5. thirdparty_volk_dir = "#thirdparty/volk"
  6. # Use bundled Vulkan headers
  7. env.Prepend(CPPPATH=[thirdparty_dir, thirdparty_dir + "/include"])
  8. if env["use_volk"]:
  9. env.AppendUnique(CPPDEFINES=["USE_VOLK"])
  10. env.Prepend(CPPPATH=[thirdparty_volk_dir])
  11. if env["platform"] == "android":
  12. env.AppendUnique(CPPDEFINES=["VK_USE_PLATFORM_ANDROID_KHR"])
  13. elif env["platform"] == "ios":
  14. env.AppendUnique(CPPDEFINES=["VK_USE_PLATFORM_IOS_MVK", "VK_USE_PLATFORM_METAL_EXT"])
  15. elif env["platform"] == "linuxbsd":
  16. if env["x11"]:
  17. env.AppendUnique(CPPDEFINES=["VK_USE_PLATFORM_XLIB_KHR"])
  18. if env["wayland"]:
  19. env.AppendUnique(CPPDEFINES=["VK_USE_PLATFORM_WAYLAND_KHR"])
  20. elif env["platform"] == "macos":
  21. env.AppendUnique(CPPDEFINES=["VK_USE_PLATFORM_MACOS_MVK", "VK_USE_PLATFORM_METAL_EXT"])
  22. elif env["platform"] == "windows":
  23. env.AppendUnique(CPPDEFINES=["VK_USE_PLATFORM_WIN32_KHR"])
  24. # Build Vulkan memory allocator and volk
  25. env_thirdparty_vma = env.Clone()
  26. env_thirdparty_vma.disable_warnings()
  27. thirdparty_sources_vma = [thirdparty_dir + "/vk_mem_alloc.cpp"]
  28. if env["use_volk"]:
  29. env_thirdparty_vma.AppendUnique(CPPDEFINES=["VMA_STATIC_VULKAN_FUNCTIONS=1"])
  30. env_thirdparty_volk = env.Clone()
  31. env_thirdparty_volk.disable_warnings()
  32. thirdparty_sources_volk = [thirdparty_volk_dir + "/volk.c"]
  33. env_thirdparty_volk.add_source_files(thirdparty_obj, thirdparty_sources_volk)
  34. elif env["platform"] == "android":
  35. # Our current NDK version only provides old Vulkan headers,
  36. # so we have to limit VMA.
  37. env_thirdparty_vma.AppendUnique(CPPDEFINES=["VMA_VULKAN_VERSION=1000000"])
  38. elif env["platform"] == "macos" or env["platform"] == "ios":
  39. # MoltenVK supports only Vulkan 1.1 API, limit VMA to the same version.
  40. env_thirdparty_vma.AppendUnique(CPPDEFINES=["VMA_VULKAN_VERSION=1001000"])
  41. env_thirdparty_vma.add_source_files(thirdparty_obj, thirdparty_sources_vma)
  42. env.drivers_sources += thirdparty_obj
  43. # Godot source files
  44. driver_obj = []
  45. env.add_source_files(driver_obj, "*.cpp")
  46. env.drivers_sources += driver_obj
  47. # Needed to force rebuilding the driver files when the thirdparty code is updated.
  48. env.Depends(driver_obj, thirdparty_obj)