SCsub 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. #!/usr/bin/env python
  2. from misc.utility.scons_hints import *
  3. Import("env")
  4. File = env.File
  5. # TODO: Add warning to headers and code about their autogenerated status.
  6. if env["use_sowrap"]:
  7. # We have to implement separate builders for so wrappers as the
  8. # autogenerated Wayland protocol wrapper must include them instead of the
  9. # native libraries.
  10. WAYLAND_BUILDERS_SOWRAP = {
  11. "WAYLAND_API_HEADER": Builder(
  12. action=env.Run(
  13. r"wayland-scanner -c client-header < ${SOURCE} | "
  14. r"sed 's:wayland-client-core\.h:../dynwrappers/wayland-client-core-so_wrap\.h:' > ${TARGET}",
  15. ),
  16. single_source=True,
  17. ),
  18. "WAYLAND_API_CODE": Builder(
  19. action=env.Run(
  20. r"wayland-scanner -c private-code < ${SOURCE} | "
  21. r"sed 's:wayland-util\.h:../dynwrappers/wayland-client-core-so_wrap\.h:' > ${TARGET}",
  22. ),
  23. single_source=True,
  24. ),
  25. }
  26. env.Append(BUILDERS=WAYLAND_BUILDERS_SOWRAP)
  27. else:
  28. WAYLAND_BUILDERS = {
  29. "WAYLAND_API_HEADER": Builder(
  30. action=env.Run(r"wayland-scanner -c client-header < ${SOURCE} > ${TARGET}"),
  31. single_source=True,
  32. ),
  33. "WAYLAND_API_CODE": Builder(
  34. action=env.Run(r"wayland-scanner -c private-code < ${SOURCE} > ${TARGET}"),
  35. single_source=True,
  36. ),
  37. }
  38. env.Append(BUILDERS=WAYLAND_BUILDERS)
  39. def generate_from_xml(name, path):
  40. header = env.WAYLAND_API_HEADER(File(f"protocol/{name}.gen.h"), path)
  41. source = env.WAYLAND_API_CODE(File(f"protocol/{name}.gen.c"), path)
  42. env.NoCache(header, source)
  43. return source
  44. generated_sources = [
  45. # Core protocol
  46. generate_from_xml("wayland", "#thirdparty/wayland/protocol/wayland.xml"),
  47. # Stable protocols
  48. generate_from_xml("tablet", "#thirdparty/wayland-protocols/stable/tablet/tablet-v2.xml"),
  49. generate_from_xml("viewporter", "#thirdparty/wayland-protocols/stable/viewporter/viewporter.xml"),
  50. generate_from_xml("xdg_shell", "#thirdparty/wayland-protocols/stable/xdg-shell/xdg-shell.xml"),
  51. # Staging protocols
  52. generate_from_xml("cursor_shape", "#thirdparty/wayland-protocols/staging/cursor-shape/cursor-shape-v1.xml"),
  53. generate_from_xml(
  54. "fractional_scale", "#thirdparty/wayland-protocols/staging/fractional-scale/fractional-scale-v1.xml"
  55. ),
  56. generate_from_xml("xdg_activation", "#thirdparty/wayland-protocols/staging/xdg-activation/xdg-activation-v1.xml"),
  57. generate_from_xml(
  58. "xdg_system_bell", "#thirdparty/wayland-protocols/staging/xdg-system-bell/xdg-system-bell-v1.xml"
  59. ),
  60. generate_from_xml(
  61. "xdg_toplevel_icon", "#thirdparty/wayland-protocols/staging/xdg-toplevel-icon/xdg-toplevel-icon-v1.xml"
  62. ),
  63. # Unstable protocols
  64. generate_from_xml(
  65. "idle_inhibit", "#thirdparty/wayland-protocols/unstable/idle-inhibit/idle-inhibit-unstable-v1.xml"
  66. ),
  67. generate_from_xml(
  68. "pointer_constraints",
  69. "#thirdparty/wayland-protocols/unstable/pointer-constraints/pointer-constraints-unstable-v1.xml",
  70. ),
  71. generate_from_xml(
  72. "pointer_gestures", "#thirdparty/wayland-protocols/unstable/pointer-gestures/pointer-gestures-unstable-v1.xml"
  73. ),
  74. generate_from_xml(
  75. "primary_selection",
  76. "#thirdparty/wayland-protocols/unstable/primary-selection/primary-selection-unstable-v1.xml",
  77. ),
  78. generate_from_xml(
  79. "relative_pointer", "#thirdparty/wayland-protocols/unstable/relative-pointer/relative-pointer-unstable-v1.xml"
  80. ),
  81. generate_from_xml("text_input", "#thirdparty/wayland-protocols/unstable/text-input/text-input-unstable-v3.xml"),
  82. generate_from_xml(
  83. "xdg_decoration", "#thirdparty/wayland-protocols/unstable/xdg-decoration/xdg-decoration-unstable-v1.xml"
  84. ),
  85. generate_from_xml(
  86. "xdg_foreign_v1", "#thirdparty/wayland-protocols/unstable/xdg-foreign/xdg-foreign-unstable-v1.xml"
  87. ), # Note: deprecated
  88. generate_from_xml(
  89. "xdg_foreign_v2", "#thirdparty/wayland-protocols/unstable/xdg-foreign/xdg-foreign-unstable-v2.xml"
  90. ),
  91. generate_from_xml("linux_dmabuf_v1", "#thirdparty/wayland-protocols/stable/linux-dmabuf/linux-dmabuf-v1.xml"),
  92. generate_from_xml(
  93. "linux_explicit_synchronization_unstable_v1",
  94. "#thirdparty/wayland-protocols/unstable/linux-explicit-synchronization/linux-explicit-synchronization-unstable-v1.xml",
  95. ),
  96. generate_from_xml("fifo_v1", "#thirdparty/wayland-protocols/staging/fifo/fifo-v1.xml"),
  97. generate_from_xml("commit_timing_v1", "#thirdparty/wayland-protocols/staging/commit-timing/commit-timing-v1.xml"),
  98. generate_from_xml(
  99. "linux_drm_syncobj_v1", "#thirdparty/wayland-protocols/staging/linux-drm-syncobj/linux-drm-syncobj-v1.xml"
  100. ),
  101. generate_from_xml(
  102. "tearing_control_v1", "#thirdparty/wayland-protocols/staging/tearing-control/tearing-control-v1.xml"
  103. ),
  104. generate_from_xml("wayland-drm", "#thirdparty/wayland-protocols/mesa/wayland-drm.xml"),
  105. generate_from_xml("godot_embedding_compositor", "godot-embedding-compositor.xml"),
  106. ]
  107. source_files = generated_sources + [
  108. File("detect_prime_egl.cpp"),
  109. File("display_server_wayland.cpp"),
  110. File("key_mapping_xkb.cpp"),
  111. File("wayland_thread.cpp"),
  112. File("wayland_embedder.cpp"),
  113. ]
  114. if env["use_sowrap"]:
  115. source_files.append(
  116. [
  117. File("dynwrappers/wayland-cursor-so_wrap.c"),
  118. File("dynwrappers/wayland-client-core-so_wrap.c"),
  119. File("dynwrappers/wayland-egl-core-so_wrap.c"),
  120. ]
  121. )
  122. if env["libdecor"]:
  123. source_files.append(File("dynwrappers/libdecor-so_wrap.c"))
  124. if env["vulkan"]:
  125. source_files.append(File("rendering_context_driver_vulkan_wayland.cpp"))
  126. if env["opengl3"]:
  127. source_files.append(File("egl_manager_wayland.cpp"))
  128. source_files.append(File("egl_manager_wayland_gles.cpp"))
  129. Return("source_files")