[Bf-blender-cvs] [beaae4533a6] master: Cleanup: use full names for generated wayland headers, use own directory

Campbell Barton noreply at git.blender.org
Tue Jun 21 08:09:20 CEST 2022


Commit: beaae4533a634f667bdf8c50285fb6dd3aabeca9
Author: Campbell Barton
Date:   Tue Jun 21 09:11:30 2022 +1000
Branches: master
https://developer.blender.org/rBbeaae4533a634f667bdf8c50285fb6dd3aabeca9

Cleanup: use full names for generated wayland headers, use own directory

Instead of providing our own names for wayland headers, use the filename
component as the basis for the header names. This matches most reference
documentation for Wayland.

Also generate client protocols into a sub-directory `libwayland`,
instead of generating headers into the ghost directory. Making the
include path more specific & makes it easier to differentiate generated
headers from other build files.

===================================================================

M	intern/ghost/CMakeLists.txt
M	intern/ghost/intern/GHOST_SystemWayland.cpp
M	intern/ghost/intern/GHOST_SystemWayland.h
M	intern/ghost/intern/GHOST_WindowWayland.h

===================================================================

diff --git a/intern/ghost/CMakeLists.txt b/intern/ghost/CMakeLists.txt
index 5b06b5d98e6..945b3261562 100644
--- a/intern/ghost/CMakeLists.txt
+++ b/intern/ghost/CMakeLists.txt
@@ -303,59 +303,63 @@ elseif(WITH_GHOST_X11 OR WITH_GHOST_WAYLAND)
       message(FATAL_ERROR "path to wayland-protocols not found")
     endif()
 
+    set(INC_DST ${CMAKE_CURRENT_BINARY_DIR}/libwayland)
+
     # Generate protocols bindings.
-    macro(generate_protocol_bindings NAME PROT_DEF)
+    macro(generate_protocol_bindings PROT_DEF)
+      # File name without directory or extension (use for header name).
+      get_filename_component(_name ${PROT_DEF} NAME_WLE)
       add_custom_command(
-        OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${NAME}-client-protocol.h
-        COMMAND ${WAYLAND_SCANNER} client-header ${PROT_DEF} ${NAME}-client-protocol.h
+        OUTPUT ${INC_DST}/${_name}-client-protocol.h
+        COMMAND ${CMAKE_COMMAND} -E make_directory ${INC_DST}
+        COMMAND ${WAYLAND_SCANNER} client-header ${PROT_DEF} ${INC_DST}/${_name}-client-protocol.h
       )
       add_custom_command(
-        OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${NAME}-client-protocol.c
-        COMMAND ${WAYLAND_SCANNER} private-code ${PROT_DEF} ${NAME}-client-protocol.c
-        DEPENDS ${NAME}-client-protocol.h
+        OUTPUT ${INC_DST}/${_name}-client-protocol.c
+        COMMAND ${CMAKE_COMMAND} -E make_directory ${INC_DST}
+        COMMAND ${WAYLAND_SCANNER} private-code ${PROT_DEF} ${INC_DST}/${_name}-client-protocol.c
+        DEPENDS ${INC_DST}/${_name}-client-protocol.h
       )
       list(APPEND SRC
-        ${CMAKE_CURRENT_BINARY_DIR}/${NAME}-client-protocol.c
-        ${CMAKE_CURRENT_BINARY_DIR}/${NAME}-client-protocol.h
+        ${INC_DST}/${_name}-client-protocol.c
+        ${INC_DST}/${_name}-client-protocol.h
       )
+      unset(_name)
     endmacro()
 
+
     list(APPEND INC_SYS
-      ${CMAKE_CURRENT_BINARY_DIR}
+      ${INC_DST}
     )
 
     # `xdg-shell`.
     generate_protocol_bindings(
-      xdg-shell
       "${WAYLAND_PROTOCOLS_DIR}/stable/xdg-shell/xdg-shell.xml"
     )
     # `xdg-decoration`.
     generate_protocol_bindings(
-      xdg-decoration
       "${WAYLAND_PROTOCOLS_DIR}/unstable/xdg-decoration/xdg-decoration-unstable-v1.xml"
     )
     # `xdg-output`.
     generate_protocol_bindings(
-      xdg-output
       "${WAYLAND_PROTOCOLS_DIR}/unstable/xdg-output/xdg-output-unstable-v1.xml"
     )
     # Pointer-constraints.
     generate_protocol_bindings(
-      pointer-constraints
       "${WAYLAND_PROTOCOLS_DIR}/unstable/pointer-constraints/pointer-constraints-unstable-v1.xml"
     )
     # Relative-pointer.
     generate_protocol_bindings(
-      relative-pointer
       "${WAYLAND_PROTOCOLS_DIR}/unstable/relative-pointer/relative-pointer-unstable-v1.xml"
     )
     # Tablet.
     generate_protocol_bindings(
-      tablet
       "${WAYLAND_PROTOCOLS_DIR}/unstable/tablet/tablet-unstable-v2.xml"
     )
 
     add_definitions(-DWITH_GHOST_WAYLAND)
+
+    unset(INC_DST)
   endif()
 
   if(WITH_INPUT_NDOF)
diff --git a/intern/ghost/intern/GHOST_SystemWayland.cpp b/intern/ghost/intern/GHOST_SystemWayland.cpp
index 5ca85933cc7..33afb5f3155 100644
--- a/intern/ghost/intern/GHOST_SystemWayland.cpp
+++ b/intern/ghost/intern/GHOST_SystemWayland.cpp
@@ -26,15 +26,18 @@
 #include <unordered_map>
 #include <unordered_set>
 
-#include "GHOST_WaylandCursorSettings.h"
-#include <pointer-constraints-client-protocol.h>
-#include <relative-pointer-client-protocol.h>
-#include <tablet-client-protocol.h>
 #include <wayland-cursor.h>
-#include <xdg-output-client-protocol.h>
+
+#include "GHOST_WaylandCursorSettings.h"
 
 #include <xkbcommon/xkbcommon.h>
 
+/* Generated by `wayland-scanner`. */
+#include <pointer-constraints-unstable-v1-client-protocol.h>
+#include <relative-pointer-unstable-v1-client-protocol.h>
+#include <tablet-unstable-v2-client-protocol.h>
+#include <xdg-output-unstable-v1-client-protocol.h>
+
 #include <fcntl.h>
 #include <sys/mman.h>
 #include <unistd.h>
diff --git a/intern/ghost/intern/GHOST_SystemWayland.h b/intern/ghost/intern/GHOST_SystemWayland.h
index 1599e644c68..4b953dccac6 100644
--- a/intern/ghost/intern/GHOST_SystemWayland.h
+++ b/intern/ghost/intern/GHOST_SystemWayland.h
@@ -12,7 +12,9 @@
 #include "GHOST_WindowWayland.h"
 
 #include <wayland-client.h>
-#include <xdg-decoration-client-protocol.h>
+
+/* Generated by `wayland-scanner`. */
+#include <xdg-decoration-unstable-v1-client-protocol.h>
 #include <xdg-shell-client-protocol.h>
 
 #include <string>
diff --git a/intern/ghost/intern/GHOST_WindowWayland.h b/intern/ghost/intern/GHOST_WindowWayland.h
index d1eadd8fcd4..89354c54c0f 100644
--- a/intern/ghost/intern/GHOST_WindowWayland.h
+++ b/intern/ghost/intern/GHOST_WindowWayland.h
@@ -10,7 +10,6 @@
 
 #include "GHOST_Window.h"
 
-#include <unordered_set>
 #include <vector>
 
 class GHOST_SystemWayland;



More information about the Bf-blender-cvs mailing list