SCsub 4.7 KB

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