SCsub 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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. # FIXME: Review what needs to be set for Android and macOS.
  19. env_openxr.AppendUnique(CPPDEFINES=["HAVE_SECURE_GETENV"])
  20. elif env["platform"] == "windows":
  21. env_openxr.AppendUnique(CPPDEFINES=["XR_OS_WINDOWS", "NOMINMAX", "XR_USE_PLATFORM_WIN32"])
  22. elif env["platform"] == "macos":
  23. env_openxr.AppendUnique(CPPDEFINES=["XR_OS_APPLE"])
  24. # There does not seem to be a XR_USE_PLATFORM_XYZ for Apple
  25. # may need to check and set:
  26. # - XR_USE_TIMESPEC
  27. if env["builtin_openxr"]:
  28. thirdparty_dir = "#thirdparty/openxr"
  29. env_openxr.Prepend(
  30. CPPPATH=[
  31. thirdparty_dir,
  32. thirdparty_dir + "/include",
  33. thirdparty_dir + "/src",
  34. thirdparty_dir + "/src/common",
  35. thirdparty_dir + "/src/external/jsoncpp/include",
  36. ]
  37. )
  38. env_thirdparty = env_openxr.Clone()
  39. env_thirdparty.disable_warnings()
  40. env_thirdparty.AppendUnique(CPPDEFINES=["DISABLE_STD_FILESYSTEM"])
  41. if env["disable_exceptions"]:
  42. env_thirdparty.AppendUnique(CPPDEFINES=["XRLOADER_DISABLE_EXCEPTION_HANDLING", ("JSON_USE_EXCEPTION", 0)])
  43. env_thirdparty.Append(CPPPATH=[thirdparty_dir + "/src/loader"])
  44. # add in external jsoncpp dependency
  45. thirdparty_jsoncpp_dir = thirdparty_dir + "/src/external/jsoncpp/src/lib_json/"
  46. env_thirdparty.add_source_files(thirdparty_obj, thirdparty_jsoncpp_dir + "json_reader.cpp")
  47. env_thirdparty.add_source_files(thirdparty_obj, thirdparty_jsoncpp_dir + "json_value.cpp")
  48. env_thirdparty.add_source_files(thirdparty_obj, thirdparty_jsoncpp_dir + "json_writer.cpp")
  49. # add in load
  50. if env["platform"] != "android":
  51. # On Android the openxr_loader is provided by separate plugins for each device
  52. # Build the engine using object files
  53. khrloader_obj = []
  54. env_thirdparty.add_source_files(khrloader_obj, thirdparty_dir + "/src/xr_generated_dispatch_table_core.c")
  55. env_thirdparty.add_source_files(khrloader_obj, thirdparty_dir + "/src/common/filesystem_utils.cpp")
  56. env_thirdparty.add_source_files(khrloader_obj, thirdparty_dir + "/src/common/object_info.cpp")
  57. env_thirdparty.add_source_files(khrloader_obj, thirdparty_dir + "/src/loader/api_layer_interface.cpp")
  58. env_thirdparty.add_source_files(khrloader_obj, thirdparty_dir + "/src/loader/loader_core.cpp")
  59. env_thirdparty.add_source_files(khrloader_obj, thirdparty_dir + "/src/loader/loader_instance.cpp")
  60. env_thirdparty.add_source_files(khrloader_obj, thirdparty_dir + "/src/loader/loader_logger_recorders.cpp")
  61. env_thirdparty.add_source_files(khrloader_obj, thirdparty_dir + "/src/loader/loader_logger.cpp")
  62. env_thirdparty.add_source_files(khrloader_obj, thirdparty_dir + "/src/loader/manifest_file.cpp")
  63. env_thirdparty.add_source_files(khrloader_obj, thirdparty_dir + "/src/loader/runtime_interface.cpp")
  64. env_thirdparty.add_source_files(khrloader_obj, thirdparty_dir + "/src/loader/xr_generated_loader.cpp")
  65. env.modules_sources += khrloader_obj
  66. env.modules_sources += thirdparty_obj
  67. # Godot source files
  68. module_obj = []
  69. env_openxr.add_source_files(module_obj, "*.cpp")
  70. env_openxr.add_source_files(module_obj, "action_map/*.cpp")
  71. env_openxr.add_source_files(module_obj, "scene/*.cpp")
  72. # We're a little more targeted with our extensions
  73. if env["platform"] == "android":
  74. env_openxr.add_source_files(module_obj, "extensions/openxr_android_extension.cpp")
  75. if env["vulkan"]:
  76. env_openxr.add_source_files(module_obj, "extensions/openxr_vulkan_extension.cpp")
  77. if env["opengl3"] and env["platform"] != "macos":
  78. env_openxr.add_source_files(module_obj, "extensions/openxr_opengl_extension.cpp")
  79. env_openxr.add_source_files(module_obj, "extensions/openxr_palm_pose_extension.cpp")
  80. env_openxr.add_source_files(module_obj, "extensions/openxr_composition_layer_depth_extension.cpp")
  81. env_openxr.add_source_files(module_obj, "extensions/openxr_eye_gaze_interaction.cpp")
  82. env_openxr.add_source_files(module_obj, "extensions/openxr_htc_controller_extension.cpp")
  83. env_openxr.add_source_files(module_obj, "extensions/openxr_htc_vive_tracker_extension.cpp")
  84. env_openxr.add_source_files(module_obj, "extensions/openxr_huawei_controller_extension.cpp")
  85. env_openxr.add_source_files(module_obj, "extensions/openxr_hand_tracking_extension.cpp")
  86. env_openxr.add_source_files(module_obj, "extensions/openxr_fb_foveation_extension.cpp")
  87. env_openxr.add_source_files(module_obj, "extensions/openxr_fb_update_swapchain_extension.cpp")
  88. env_openxr.add_source_files(module_obj, "extensions/openxr_fb_passthrough_extension_wrapper.cpp")
  89. env_openxr.add_source_files(module_obj, "extensions/openxr_fb_display_refresh_rate_extension.cpp")
  90. env_openxr.add_source_files(module_obj, "extensions/openxr_pico_controller_extension.cpp")
  91. env_openxr.add_source_files(module_obj, "extensions/openxr_wmr_controller_extension.cpp")
  92. env_openxr.add_source_files(module_obj, "extensions/openxr_ml2_controller_extension.cpp")
  93. env_openxr.add_source_files(module_obj, "extensions/openxr_extension_wrapper_extension.cpp")
  94. env_openxr.add_source_files(module_obj, "extensions/openxr_api_extension.cpp")
  95. env.modules_sources += module_obj
  96. if env.editor_build:
  97. SConscript("editor/SCsub")
  98. # Needed to force rebuilding the module files when the thirdparty library is updated.
  99. env.Depends(module_obj, thirdparty_obj)