SCsub 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. #!/usr/bin/env python
  2. Import("env")
  3. Import("env_modules")
  4. env_openxr = env_modules.Clone()
  5. # Thirdparty source files
  6. thirdparty_obj = []
  7. # Khronos OpenXR loader
  8. # Needs even for build against shared library, at least the defines used in public headers.
  9. if env["platform"] == "android":
  10. # may need to set OPENXR_ANDROID_VERSION_SUFFIX
  11. env_openxr.AppendUnique(CPPDEFINES=["XR_OS_ANDROID", "XR_USE_PLATFORM_ANDROID"])
  12. env_openxr.AppendUnique(CPPDEFINES=["JSON_USE_EXCEPTION=0"])
  13. # may need to include java parts of the openxr loader
  14. elif env["platform"] == "linuxbsd":
  15. env_openxr.AppendUnique(CPPDEFINES=["XR_OS_LINUX"])
  16. if env["x11"]:
  17. env_openxr.AppendUnique(CPPDEFINES=["XR_USE_PLATFORM_XLIB"])
  18. if env["wayland"]:
  19. env_openxr.AppendUnique(CPPDEFINES=["XR_USE_PLATFORM_WAYLAND"])
  20. # FIXME: Review what needs to be set for Android and macOS.
  21. env_openxr.AppendUnique(CPPDEFINES=["HAVE_SECURE_GETENV"])
  22. elif env["platform"] == "windows":
  23. env_openxr.AppendUnique(CPPDEFINES=["XR_OS_WINDOWS", "NOMINMAX", "XR_USE_PLATFORM_WIN32"])
  24. elif env["platform"] == "macos":
  25. env_openxr.AppendUnique(CPPDEFINES=["XR_OS_APPLE"])
  26. # There does not seem to be a XR_USE_PLATFORM_XYZ for Apple
  27. # may need to check and set:
  28. # - XR_USE_TIMESPEC
  29. if env["builtin_openxr"]:
  30. thirdparty_dir = "#thirdparty/openxr"
  31. env_openxr.Prepend(
  32. CPPPATH=[
  33. thirdparty_dir,
  34. thirdparty_dir + "/include",
  35. thirdparty_dir + "/src",
  36. thirdparty_dir + "/src/common",
  37. thirdparty_dir + "/src/external/jsoncpp/include",
  38. ]
  39. )
  40. env_thirdparty = env_openxr.Clone()
  41. env_thirdparty.disable_warnings()
  42. env_thirdparty.AppendUnique(CPPDEFINES=["DISABLE_STD_FILESYSTEM"])
  43. if env["disable_exceptions"]:
  44. env_thirdparty.AppendUnique(CPPDEFINES=["XRLOADER_DISABLE_EXCEPTION_HANDLING", ("JSON_USE_EXCEPTION", 0)])
  45. env_thirdparty.Append(CPPPATH=[thirdparty_dir + "/src/loader"])
  46. # add in external jsoncpp dependency
  47. thirdparty_jsoncpp_dir = thirdparty_dir + "/src/external/jsoncpp/src/lib_json/"
  48. env_thirdparty.add_source_files(thirdparty_obj, thirdparty_jsoncpp_dir + "json_reader.cpp")
  49. env_thirdparty.add_source_files(thirdparty_obj, thirdparty_jsoncpp_dir + "json_value.cpp")
  50. env_thirdparty.add_source_files(thirdparty_obj, thirdparty_jsoncpp_dir + "json_writer.cpp")
  51. # add in load
  52. if env["platform"] != "android":
  53. # On Android the openxr_loader is provided by separate plugins for each device
  54. # Build the engine using object files
  55. khrloader_obj = []
  56. env_thirdparty.add_source_files(khrloader_obj, thirdparty_dir + "/src/xr_generated_dispatch_table_core.c")
  57. env_thirdparty.add_source_files(khrloader_obj, thirdparty_dir + "/src/common/filesystem_utils.cpp")
  58. env_thirdparty.add_source_files(khrloader_obj, thirdparty_dir + "/src/common/object_info.cpp")
  59. env_thirdparty.add_source_files(khrloader_obj, thirdparty_dir + "/src/loader/api_layer_interface.cpp")
  60. env_thirdparty.add_source_files(khrloader_obj, thirdparty_dir + "/src/loader/loader_core.cpp")
  61. env_thirdparty.add_source_files(khrloader_obj, thirdparty_dir + "/src/loader/loader_instance.cpp")
  62. env_thirdparty.add_source_files(khrloader_obj, thirdparty_dir + "/src/loader/loader_logger_recorders.cpp")
  63. env_thirdparty.add_source_files(khrloader_obj, thirdparty_dir + "/src/loader/loader_logger.cpp")
  64. env_thirdparty.add_source_files(khrloader_obj, thirdparty_dir + "/src/loader/manifest_file.cpp")
  65. env_thirdparty.add_source_files(khrloader_obj, thirdparty_dir + "/src/loader/runtime_interface.cpp")
  66. env_thirdparty.add_source_files(khrloader_obj, thirdparty_dir + "/src/loader/xr_generated_loader.cpp")
  67. env.modules_sources += khrloader_obj
  68. env.modules_sources += thirdparty_obj
  69. # Godot source files
  70. module_obj = []
  71. env_openxr.add_source_files(module_obj, "*.cpp")
  72. env.modules_sources += module_obj
  73. Export("env_openxr")
  74. SConscript("action_map/SCsub")
  75. SConscript("extensions/SCsub")
  76. SConscript("scene/SCsub")
  77. if env.editor_build:
  78. SConscript("editor/SCsub")
  79. # Needed to force rebuilding the module files when the thirdparty library is updated.
  80. env.Depends(module_obj, thirdparty_obj)