diff mbox series

[RFC] piglit: add a patch to address host contamination for wayland-scanner

Message ID 20240823135024.699680-1-alex.kanavin@gmail.com
State Accepted, archived
Commit cb99666b084fc7dc88b0f370b8c920624dbe68f0
Headers show
Series [RFC] piglit: add a patch to address host contamination for wayland-scanner | expand

Commit Message

Alexander Kanavin Aug. 23, 2024, 1:50 p.m. UTC
From: Alexander Kanavin <alex@linutronix.de>

Signed-off-by: Alexander Kanavin <alex@linutronix.de>
---
 ...o-not-obtain-wayland-scanner-path-fr.patch | 38 +++++++++++++++++++
 meta/recipes-graphics/piglit/piglit_git.bb    |  1 +
 2 files changed, 39 insertions(+)
 create mode 100644 meta/recipes-graphics/piglit/piglit/0001-CMakeLists.txt-do-not-obtain-wayland-scanner-path-fr.patch

Comments

Richard Purdie Aug. 23, 2024, 4:55 p.m. UTC | #1
On Fri, 2024-08-23 at 15:50 +0200, Alexander Kanavin via lists.openembedded.org wrote:
> From: Alexander Kanavin <alex@linutronix.de>
> 
> Signed-off-by: Alexander Kanavin <alex@linutronix.de>
> ---
>  ...o-not-obtain-wayland-scanner-path-fr.patch | 38 +++++++++++++++++++
>  meta/recipes-graphics/piglit/piglit_git.bb    |  1 +
>  2 files changed, 39 insertions(+)
>  create mode 100644 meta/recipes-graphics/piglit/piglit/0001-CMakeLists.txt-do-not-obtain-wayland-scanner-path-fr.patch
> 
> diff --git a/meta/recipes-graphics/piglit/piglit/0001-CMakeLists.txt-do-not-obtain-wayland-scanner-path-fr.patch b/meta/recipes-graphics/piglit/piglit/0001-CMakeLists.txt-do-not-obtain-wayland-scanner-path-fr.patch
> new file mode 100644
> index 00000000000..b47e16af6b3
> --- /dev/null
> +++ b/meta/recipes-graphics/piglit/piglit/0001-CMakeLists.txt-do-not-obtain-wayland-scanner-path-fr.patch
> @@ -0,0 +1,38 @@
> +From 8f25cdf54e35ab1a174cabf5078784b8e48bda01 Mon Sep 17 00:00:00 2001
> +From: Alexander Kanavin <alex@linutronix.de>
> +Date: Fri, 23 Aug 2024 15:29:45 +0200
> +Subject: [PATCH] CMakeLists.txt: do not obtain wayland-scanner path from
> + pkg-config
> +
> +cmake can only use target wayland-scanner.pc which (correctly) points to /usr/bin/wayland-scanner
> +
> +However in cross builds it should be using wayland-scanner from native sysroot,
> +otherwise builds will break if wayland-scanner is not installed on the host
> +distro.
> +
> +Upstream-Status: Inappropriate [yocto specific]
> +Signed-off-by: Alexander Kanavin <alex@linutronix.de>
> +---
> + CMakeLists.txt | 6 +-----
> + 1 file changed, 1 insertion(+), 5 deletions(-)
> +
> +diff --git a/CMakeLists.txt b/CMakeLists.txt
> +index d169fb481..8394f5236 100644
> +--- a/CMakeLists.txt
> ++++ b/CMakeLists.txt
> +@@ -211,11 +211,7 @@ if(PIGLIT_USE_WAYLAND)
> + 		message(FATAL_ERROR "Failed to find wayland-protocols XML path")
> + 	endif()
> + 
> +-	pkg_check_modules(WaylandScanner REQUIRED wayland-scanner)
> +-	pkg_get_variable(WaylandScannerPath wayland-scanner wayland_scanner)
> +-	if (NOT WaylandScannerPath)
> +-		message(FATAL_ERROR "Failed to find wayland-scanner path from pkg-config")
> +-	endif()
> ++	set(WaylandScannerPath wayland-scanner)
> + 	add_executable(WaylandScannerExe IMPORTED)
> + 	set_property(TARGET WaylandScannerExe PROPERTY IMPORTED_LOCATION ${WaylandScannerPath})
> + endif()

Is there any notion of cross compiling in cmake? This might be
upstreamable if you could make "wayland-scanner" conditional upon cross
compiling?

Cheers,

Richard
Alexander Kanavin Aug. 23, 2024, 5 p.m. UTC | #2
On Fri, 23 Aug 2024 at 18:55, Richard Purdie
<richard.purdie@linuxfoundation.org> wrote:

> Is there any notion of cross compiling in cmake? This might be
> upstreamable if you could make "wayland-scanner" conditional upon cross
> compiling?

The correct fix would be to use the output from 'native' pkg-config
(set via cmake class to point to pkg-config-native executable) for
finding this particular piece, but I couldn't find such a notion in
cmake. It does exist in meson, and we use it, sending fixes upstream
where they get native vs 'regular' pkg-config wrong.

Another option would be to actually send the patch as it is - simply
use 'wayland-scanner' from PATH always. There's little reason for it
to be called something else, or supplied from a non-standard location
which is not in PATH.

Alex
diff mbox series

Patch

diff --git a/meta/recipes-graphics/piglit/piglit/0001-CMakeLists.txt-do-not-obtain-wayland-scanner-path-fr.patch b/meta/recipes-graphics/piglit/piglit/0001-CMakeLists.txt-do-not-obtain-wayland-scanner-path-fr.patch
new file mode 100644
index 00000000000..b47e16af6b3
--- /dev/null
+++ b/meta/recipes-graphics/piglit/piglit/0001-CMakeLists.txt-do-not-obtain-wayland-scanner-path-fr.patch
@@ -0,0 +1,38 @@ 
+From 8f25cdf54e35ab1a174cabf5078784b8e48bda01 Mon Sep 17 00:00:00 2001
+From: Alexander Kanavin <alex@linutronix.de>
+Date: Fri, 23 Aug 2024 15:29:45 +0200
+Subject: [PATCH] CMakeLists.txt: do not obtain wayland-scanner path from
+ pkg-config
+
+cmake can only use target wayland-scanner.pc which (correctly) points to /usr/bin/wayland-scanner
+
+However in cross builds it should be using wayland-scanner from native sysroot,
+otherwise builds will break if wayland-scanner is not installed on the host
+distro.
+
+Upstream-Status: Inappropriate [yocto specific]
+Signed-off-by: Alexander Kanavin <alex@linutronix.de>
+---
+ CMakeLists.txt | 6 +-----
+ 1 file changed, 1 insertion(+), 5 deletions(-)
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index d169fb481..8394f5236 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -211,11 +211,7 @@ if(PIGLIT_USE_WAYLAND)
+ 		message(FATAL_ERROR "Failed to find wayland-protocols XML path")
+ 	endif()
+ 
+-	pkg_check_modules(WaylandScanner REQUIRED wayland-scanner)
+-	pkg_get_variable(WaylandScannerPath wayland-scanner wayland_scanner)
+-	if (NOT WaylandScannerPath)
+-		message(FATAL_ERROR "Failed to find wayland-scanner path from pkg-config")
+-	endif()
++	set(WaylandScannerPath wayland-scanner)
+ 	add_executable(WaylandScannerExe IMPORTED)
+ 	set_property(TARGET WaylandScannerExe PROPERTY IMPORTED_LOCATION ${WaylandScannerPath})
+ endif()
+-- 
+2.39.2
+
diff --git a/meta/recipes-graphics/piglit/piglit_git.bb b/meta/recipes-graphics/piglit/piglit_git.bb
index a1fd2b8bde1..3a2dec34d7e 100644
--- a/meta/recipes-graphics/piglit/piglit_git.bb
+++ b/meta/recipes-graphics/piglit/piglit_git.bb
@@ -10,6 +10,7 @@  SRC_URI = "git://gitlab.freedesktop.org/mesa/piglit.git;protocol=https;branch=ma
            file://0002-cmake-use-proper-WAYLAND_INCLUDE_DIRS-variable.patch \
            file://0003-tests-util-piglit-shader.c-do-not-hardcode-build-pat.patch \
            file://0001-tests-Fix-narrowing-errors-seen-with-clang.patch \
+           file://0001-CMakeLists.txt-do-not-obtain-wayland-scanner-path-fr.patch \
            "
 UPSTREAM_CHECK_COMMITS = "1"