commit: 78658acbd51f6965cd11fd39dc3e9877f23cf221 Author: Eli Schwartz <eschwartz93 <AT> gmail <DOT> com> AuthorDate: Thu Jun 20 03:03:40 2024 +0000 Commit: Eli Schwartz <eschwartz <AT> gentoo <DOT> org> CommitDate: Fri Aug 2 00:36:19 2024 +0000 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=78658acb
gui-libs/gtk: add a "poison" macro support to disable X/wayland Many packages perform automagic dependencies on gdk's backend implementations by checking if the macro is defined and then using the code it unlocks, rather than having a buildsystem option such as -Dwayland=true. It's unfeasible to patch every such package's source code to add configure options and respect them. Instead add a truly filthy hack and permit gtk itself to selectively show or hide the windowing system in use. Bug: https://bugs.gentoo.org/624960 Signed-off-by: Eli Schwartz <eschwartz93 <AT> gmail.com> Part-of: https://github.com/gentoo/gentoo/pull/37259 Signed-off-by: Eli Schwartz <eschwartz <AT> gentoo.org> ...add-a-poison-macro-to-hide-GDK_WINDOWING_.patch | 91 ++++++++++++++++++++++ .../{gtk-4.14.3.ebuild => gtk-4.12.5-r2.ebuild} | 49 +++++------- .../{gtk-4.14.3.ebuild => gtk-4.14.3-r1.ebuild} | 8 ++ .../{gtk-4.14.4.ebuild => gtk-4.14.4-r1.ebuild} | 8 ++ 4 files changed, 126 insertions(+), 30 deletions(-) diff --git a/gui-libs/gtk/files/0001-gdk-add-a-poison-macro-to-hide-GDK_WINDOWING_.patch b/gui-libs/gtk/files/0001-gdk-add-a-poison-macro-to-hide-GDK_WINDOWING_.patch new file mode 100644 index 000000000000..652e9e116339 --- /dev/null +++ b/gui-libs/gtk/files/0001-gdk-add-a-poison-macro-to-hide-GDK_WINDOWING_.patch @@ -0,0 +1,91 @@ +From 0537043f72ea1a634b101efa9e11cc0a22baaf71 Mon Sep 17 00:00:00 2001 +From: Eli Schwartz <[email protected]> +Date: Wed, 19 Jun 2024 21:28:31 -0400 +Subject: [PATCH] gdk: add a "poison" macro to hide GDK_WINDOWING_* + +Many packages perform automagic dependencies on gdk's backend +implementations by checking if the macro is defined and then using the +code it unlocks, rather than having a buildsystem option such as +-Dwayland=true. + +It's unfeasible to patch every such package's source code to add +configure options and respect them. Instead add a truly filthy hack and +permit gtk itself to selectively show or hide the windowing system in +use. + +By default, we assume this macro is never defined. It should only ever +be defined inside an ebuild, as such: + +``` +use wayland || append-cflags -DGENTOO_GTK_HIDE_WAYLAND +use X || append-cflags -DGENTOO_GTK_HIDE_X11 +``` + +When seen, this will prevent code using "#ifdef GDK_WINDOWING_*" from +seeing the define, so the automagic dependency won't be picked up. It +will also cause any attempt to #include the backend-specific headers to +bug out. + +Bug: https://bugs.gentoo.org/624960 +Signed-off-by: Eli Schwartz <[email protected]> +--- + gdk/gdkconfig.h.meson | 7 +++++++ + gdk/wayland/gdkwayland.h | 4 ++++ + gdk/x11/gdkx.h | 4 ++++ + 3 files changed, 15 insertions(+) + +diff --git a/gdk/gdkconfig.h.meson b/gdk/gdkconfig.h.meson +index d5b48f3184..22baab52ae 100644 +--- a/gdk/gdkconfig.h.meson ++++ b/gdk/gdkconfig.h.meson +@@ -10,10 +10,17 @@ + G_BEGIN_DECLS + + ++#ifndef GENTOO_GTK_HIDE_X11 + #mesondefine GDK_WINDOWING_X11 ++#endif ++ + #mesondefine GDK_WINDOWING_BROADWAY + #mesondefine GDK_WINDOWING_MACOS ++ ++#ifndef GENTOO_GTK_HIDE_WAYLAND + #mesondefine GDK_WINDOWING_WAYLAND ++#endif ++ + #mesondefine GDK_WINDOWING_WIN32 + + #mesondefine GDK_RENDERING_CAIRO +diff --git a/gdk/wayland/gdkwayland.h b/gdk/wayland/gdkwayland.h +index 846445910e..5d84619295 100644 +--- a/gdk/wayland/gdkwayland.h ++++ b/gdk/wayland/gdkwayland.h +@@ -24,6 +24,10 @@ + + #pragma once + ++#ifdef GENTOO_GTK_HIDE_WAYLAND ++ #error "A Gentoo ebuild has hidden wayland and it cannot be used in this compilation unit. Please file a bug if you see this error." ++#endif ++ + #include <gdk/gdk.h> + + #define __GDKWAYLAND_H_INSIDE__ +diff --git a/gdk/x11/gdkx.h b/gdk/x11/gdkx.h +index 6bef6b6de8..d4f8b94550 100644 +--- a/gdk/x11/gdkx.h ++++ b/gdk/x11/gdkx.h +@@ -24,6 +24,10 @@ + + #pragma once + ++#ifdef GENTOO_GTK_HIDE_X11 ++ #error "A Gentoo ebuild has hidden x11 and it cannot be used in this compilation unit. Please file a bug if you see this error." ++#endif ++ + #include <gdk/gdk.h> + + #include <X11/Xlib.h> +-- +2.44.2 + diff --git a/gui-libs/gtk/gtk-4.14.3.ebuild b/gui-libs/gtk/gtk-4.12.5-r2.ebuild similarity index 82% copy from gui-libs/gtk/gtk-4.14.3.ebuild copy to gui-libs/gtk/gtk-4.12.5-r2.ebuild index 7f0c8930ab74..aaf7a773087e 100644 --- a/gui-libs/gtk/gtk-4.14.3.ebuild +++ b/gui-libs/gtk/gtk-4.12.5-r2.ebuild @@ -10,7 +10,7 @@ HOMEPAGE="https://www.gtk.org/ https://gitlab.gnome.org/GNOME/gtk/" LICENSE="LGPL-2+" SLOT="4" -IUSE="aqua broadway cloudproviders colord cups examples gstreamer +introspection sysprof test vulkan wayland +X cpu_flags_x86_f16c" +IUSE="aqua broadway cloudproviders colord cups examples ffmpeg gstreamer +introspection sysprof test vulkan wayland +X cpu_flags_x86_f16c" REQUIRED_USE=" || ( aqua wayland X ) test? ( introspection ) @@ -18,7 +18,6 @@ REQUIRED_USE=" KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~ia64 ~loong ~ppc ~ppc64 ~riscv ~sparc ~x86" -# TODO: Optional gst build dep on >=gst-plugins-base-1.23.1, so depend on it once we can COMMON_DEPEND=" >=dev-libs/glib-2.76.0:2 >=x11-libs/cairo-1.17.6[aqua?,glib,svg(+),X?] @@ -37,17 +36,13 @@ COMMON_DEPEND=" cloudproviders? ( net-libs/libcloudproviders ) colord? ( >=x11-misc/colord-0.1.9:0= ) cups? ( >=net-print/cups-2.0 ) - examples? ( gnome-base/librsvg:2 ) + ffmpeg? ( media-video/ffmpeg:= ) gstreamer? ( - >=media-libs/gstreamer-1.12.3:1.0 >=media-libs/gst-plugins-bad-1.12.3:1.0 - || ( - >=media-libs/gst-plugins-base-1.12.3:1.0[gles2] - >=media-libs/gst-plugins-base-1.12.3:1.0[opengl] - ) + >=media-libs/gst-plugins-base-1.12.3:1.0[opengl] ) introspection? ( >=dev-libs/gobject-introspection-1.76:= ) - vulkan? ( >=media-libs/vulkan-loader-1.3:= ) + vulkan? ( media-libs/vulkan-loader:= ) wayland? ( >=dev-libs/wayland-1.21.0 >=dev-libs/wayland-protocols-1.31 @@ -55,6 +50,7 @@ COMMON_DEPEND=" >=x11-libs/libxkbcommon-0.2 ) X? ( + >=app-accessibility/at-spi2-core-2.46.0 media-libs/fontconfig media-libs/mesa[X(+)] x11-libs/libX11 @@ -68,19 +64,15 @@ COMMON_DEPEND=" ) " DEPEND="${COMMON_DEPEND} - kernel_linux? ( - x11-libs/libdrm - sys-kernel/linux-headers - ) sysprof? ( >=dev-util/sysprof-capture-3.40.1:4 ) X? ( x11-base/xorg-proto ) " RDEPEND="${COMMON_DEPEND} >=dev-util/gtk-update-icon-cache-3 " -# librsvg for svg icons (PDEPEND to avoid circular dep on wd40 profiles with librsvg[tools]), bug #547710 +# librsvg for svg icons (PDEPEND to avoid circular dep), bug #547710 PDEPEND=" - gnome-base/librsvg:2 + gnome-base/librsvg >=x11-themes/adwaita-icon-theme-3.14 " BDEPEND=" @@ -108,6 +100,14 @@ BDEPEND=" ) " +PATCHES=( + # Gentoo-specific patch to add a "poison" macro support, allowing other ebuilds + # with USE="-wayland -X" to trick gtk into claiming that it wasn't built with + # such support. + # https://bugs.gentoo.org/624960 + "${FILESDIR}"/0001-gdk-add-a-poison-macro-to-hide-GDK_WINDOWING_.patch +) + python_check_deps() { python_has_version "dev-python/pygobject:3[${PYTHON_USEDEP}]" || return } @@ -147,6 +147,7 @@ src_configure() { $(meson_use aqua macos-backend) # Media backends + $(meson_feature ffmpeg media-ffmpeg) $(meson_feature gstreamer media-gstreamer) # Print backends @@ -172,7 +173,7 @@ src_configure() { -Dman-pages=true # Demos, examples, and tests - -Dprofile=default + -Ddemo-profile=default $(meson_use examples build-demos) $(meson_use test build-testsuite) $(meson_use examples build-examples) @@ -186,13 +187,7 @@ src_test() { if use X; then einfo "Running tests under X" - GSETTINGS_SCHEMA_DIR="${S}/gtk" virtx meson_src_test --timeout-multiplier=130 \ - --setup=x11 \ - --no-suite=failing \ - --no-suite=x11_failing \ - --no-suite=flaky \ - --no-suite=headless \ - --no-suite=gsk-compare-broadway + GSETTINGS_SCHEMA_DIR="${S}/gtk" virtx meson_src_test --setup=x11 --timeout-multiplier=130 fi if use wayland; then @@ -204,13 +199,7 @@ src_test() { compositor=$! export WAYLAND_DISPLAY=wayland-5 - GSETTINGS_SCHEMA_DIR="${S}/gtk" meson_src_test --timeout-multiplier=130 \ - --setup=wayland \ - --no-suite=failing \ - --no-suite=wayland_failing \ - --no-suite=flaky \ - --no-suite=headless \ - --no-suite=gsk-compare-broadway + GSETTINGS_SCHEMA_DIR="${S}/gtk" meson_src_test --setup=wayland --timeout-multiplier=130 exit_code=$? kill ${compositor} diff --git a/gui-libs/gtk/gtk-4.14.3.ebuild b/gui-libs/gtk/gtk-4.14.3-r1.ebuild similarity index 95% rename from gui-libs/gtk/gtk-4.14.3.ebuild rename to gui-libs/gtk/gtk-4.14.3-r1.ebuild index 7f0c8930ab74..00d8f5bbcaa1 100644 --- a/gui-libs/gtk/gtk-4.14.3.ebuild +++ b/gui-libs/gtk/gtk-4.14.3-r1.ebuild @@ -108,6 +108,14 @@ BDEPEND=" ) " +PATCHES=( + # Gentoo-specific patch to add a "poison" macro support, allowing other ebuilds + # with USE="-wayland -X" to trick gtk into claiming that it wasn't built with + # such support. + # https://bugs.gentoo.org/624960 + "${FILESDIR}"/0001-gdk-add-a-poison-macro-to-hide-GDK_WINDOWING_.patch +) + python_check_deps() { python_has_version "dev-python/pygobject:3[${PYTHON_USEDEP}]" || return } diff --git a/gui-libs/gtk/gtk-4.14.4.ebuild b/gui-libs/gtk/gtk-4.14.4-r1.ebuild similarity index 95% rename from gui-libs/gtk/gtk-4.14.4.ebuild rename to gui-libs/gtk/gtk-4.14.4-r1.ebuild index 7f0c8930ab74..00d8f5bbcaa1 100644 --- a/gui-libs/gtk/gtk-4.14.4.ebuild +++ b/gui-libs/gtk/gtk-4.14.4-r1.ebuild @@ -108,6 +108,14 @@ BDEPEND=" ) " +PATCHES=( + # Gentoo-specific patch to add a "poison" macro support, allowing other ebuilds + # with USE="-wayland -X" to trick gtk into claiming that it wasn't built with + # such support. + # https://bugs.gentoo.org/624960 + "${FILESDIR}"/0001-gdk-add-a-poison-macro-to-hide-GDK_WINDOWING_.patch +) + python_check_deps() { python_has_version "dev-python/pygobject:3[${PYTHON_USEDEP}]" || return }
