summaryrefslogtreecommitdiffstats
path: root/recipes-multimedia/onevpl/onevpl/0001-samples-Addin-wayland-scanner-auto-generate-on-cmake.patch
blob: 351c707d6d25352868945224d54b8fd7eba59a69 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
From 7f428b8d0ca95b43b70663c27b525c5d6f7bf28d Mon Sep 17 00:00:00 2001
From: "Ung, Teng En" <teng.en.ung@intel.com>
Date: Tue, 25 Jan 2022 16:36:19 +0800
Subject: [PATCH 1/3] samples: Addin wayland-scanner auto generate on cmake.

Upstream-Status: Submitted
innersource PR #269
---
 tools/legacy/sample_common/CMakeLists.txt       | 22 +++++++++++++++++++
 tools/legacy/sample_misc/wayland/CMakeLists.txt | 29 +++++++++++++++++++++++++
 2 files changed, 51 insertions(+)

diff --git a/tools/legacy/sample_common/CMakeLists.txt b/tools/legacy/sample_common/CMakeLists.txt
index 24245cd..030ffee 100644
--- a/tools/legacy/sample_common/CMakeLists.txt
+++ b/tools/legacy/sample_common/CMakeLists.txt
@@ -103,6 +103,28 @@ if(CMAKE_SYSTEM_NAME MATCHES Linux)
         target_include_directories(
           sample_common
           PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../sample_misc/wayland/include)
+
+        find_program(WAYLAND_SCANNER_BIN "wayland-scanner")
+        pkg_check_modules(PKG_WAYLAND_PROTCOLS "wayland-protocols>=1.15")
+
+        if(WAYLAND_SCANNER_BIN AND PKG_WAYLAND_PROTCOLS_FOUND)
+          pkg_get_variable(WAYLAND_PROTOCOLS_PATH wayland-protocols pkgdatadir)
+          if(WAYLAND_PROTOCOLS_PATH)
+            find_file(
+                WAYLAND_LINUX_DMABUF_XML_PATH linux-dmabuf-unstable-v1.xml
+                PATHS ${WAYLAND_PROTOCOLS_PATH}/unstable/linux-dmabuf
+                NO_DEFAULT_PATH)
+          endif()
+        endif()
+
+        if(WAYLAND_LINUX_DMABUF_XML_PATH)
+          target_compile_definitions(
+            sample_common PUBLIC WAYLAND_LINUX_DMABUF_SUPPORT)
+          target_include_directories(
+            sample_common
+            PUBLIC ${CMAKE_BINARY_DIR}/tools/legacy/sample_misc/wayland)
+        endif()
+
       else()
         message(
           WARNING
diff --git a/tools/legacy/sample_misc/wayland/CMakeLists.txt b/tools/legacy/sample_misc/wayland/CMakeLists.txt
index cf91987..a2dffbb 100644
--- a/tools/legacy/sample_misc/wayland/CMakeLists.txt
+++ b/tools/legacy/sample_misc/wayland/CMakeLists.txt
@@ -20,6 +20,35 @@ target_sources(
           ${CMAKE_CURRENT_SOURCE_DIR}/src/listener_wayland.cpp
           ${CMAKE_CURRENT_SOURCE_DIR}/src/wayland-drm-protocol.c)
 
+if(WAYLAND_SCANNER_BIN AND PKG_WAYLAND_PROTCOLS_FOUND AND WAYLAND_LINUX_DMABUF_XML_PATH)
+  execute_process(
+      COMMAND "${WAYLAND_SCANNER_BIN_PATH}\/${WAYLAND_SCANNER_BIN}"
+              "client-header" "${WAYLAND_LINUX_DMABUF_XML_PATH}"
+              "tools/legacy/sample_misc/wayland/linux-dmabuf-unstable-v1.h"
+      WORKING_DIRECTORY "${CMAKE_BINARY_DIR}"
+      RESULT_VARIABLE WAYLAND_SCANNER_RESULT)
+  if (WAYLAND_SCANNER_RESULT)
+    message(FATAL_ERROR "Failed to generate linux-dmabuf-unstable-v1.h")
+  endif()
+
+  execute_process(
+      COMMAND "${WAYLAND_SCANNER_BIN_PATH}\/${WAYLAND_SCANNER_BIN}"
+              "private-code" "${WAYLAND_LINUX_DMABUF_XML_PATH}"
+              "tools/legacy/sample_misc/wayland/linux-dmabuf-unstable-v1.c"
+      WORKING_DIRECTORY "${CMAKE_BINARY_DIR}"
+      RESULT_VARIABLE WAYLAND_SCANNER_RESULT)
+  if (WAYLAND_SCANNER_RESULT)
+    message(FATAL_ERROR "Failed to generate linux-dmabuf-unstable-v1.c")
+  endif()
+
+  target_include_directories(
+    vpl_wayland PRIVATE ${CMAKE_BINARY_DIR}/tools/legacy/sample_misc/wayland)
+  target_sources(
+    vpl_wayland
+    PRIVATE ${CMAKE_BINARY_DIR}/tools/legacy/sample_misc/wayland/linux-dmabuf-unstable-v1.c)
+endif()
+
+
 target_link_libraries(vpl_wayland PRIVATE sample_common wayland-client va drm
                                           drm_intel)
 
-- 
2.7.4