diff mbox series

[2/2] package/libgtk4: new package

Message ID 20240403084807.512825-2-francois.perrad@gadz.org
State Accepted
Headers show
Series [1/2] package/graphene: new package | expand

Commit Message

Francois Perrad April 3, 2024, 8:48 a.m. UTC
Signed-off-by: Francois Perrad <francois.perrad@gadz.org>
---
 DEVELOPERS                   |   1 +
 package/Config.in            |   1 +
 package/libgtk4/Config.in    | 106 +++++++++++++++++++++++++++++++++
 package/libgtk4/libgtk4.hash |   5 ++
 package/libgtk4/libgtk4.mk   | 111 +++++++++++++++++++++++++++++++++++
 5 files changed, 224 insertions(+)
 create mode 100644 package/libgtk4/Config.in
 create mode 100644 package/libgtk4/libgtk4.hash
 create mode 100644 package/libgtk4/libgtk4.mk

Comments

Thomas Petazzoni July 17, 2024, 8:44 p.m. UTC | #1
On Wed,  3 Apr 2024 10:48:07 +0200
Francois Perrad <francois.perrad@gadz.org> wrote:

> Signed-off-by: Francois Perrad <francois.perrad@gadz.org>
> ---
>  DEVELOPERS                   |   1 +
>  package/Config.in            |   1 +
>  package/libgtk4/Config.in    | 106 +++++++++++++++++++++++++++++++++
>  package/libgtk4/libgtk4.hash |   5 ++
>  package/libgtk4/libgtk4.mk   | 111 +++++++++++++++++++++++++++++++++++
>  5 files changed, 224 insertions(+)
>  create mode 100644 package/libgtk4/Config.in
>  create mode 100644 package/libgtk4/libgtk4.hash
>  create mode 100644 package/libgtk4/libgtk4.mk

I've applied, after doing a few changes. See below.


> diff --git a/package/libgtk4/Config.in b/package/libgtk4/Config.in
> new file mode 100644
> index 000000000..cda183c8d
> --- /dev/null
> +++ b/package/libgtk4/Config.in
> @@ -0,0 +1,106 @@
> +comment "libgtk4 needs a toolchain w/ wchar, threads, C++, gcc >= 4.9"
> +	depends on BR2_USE_MMU
> +	depends on BR2_TOOLCHAIN_HAS_SYNC_4
> +	depends on !BR2_USE_WCHAR || !BR2_INSTALL_LIBSTDCPP || \
> +		!BR2_TOOLCHAIN_GCC_AT_LEAST_4_9 || \
> +		!BR2_TOOLCHAIN_HAS_THREADS
> +
> +comment "libgtk4 needs an OpenGL or an OpenGL-EGL/wayland backend"
> +	depends on BR2_USE_MMU
> +	depends on BR2_TOOLCHAIN_HAS_SYNC_4
> +	depends on !BR2_PACKAGE_HAS_LIBEGL_WAYLAND && !BR2_PACKAGE_HAS_LIBGL

BR2_PACKAGE_HAS_LIBEGL_WAYLAND is gone. And in fact, even on X11/OpenGL
systems, EGL is needed. So I simplified this to:

+comment "libgtk4 needs an OpenGL(ES) EGL backend"
+       depends on BR2_USE_MMU
+       depends on BR2_TOOLCHAIN_HAS_SYNC_4
+       depends on !BR2_PACKAGE_HAS_LIBEGL


> +
> +config BR2_PACKAGE_LIBGTK4
> +	bool "libgtk4"
> +	depends on BR2_USE_WCHAR # glib2
> +	depends on BR2_TOOLCHAIN_HAS_THREADS # glib2
> +	depends on BR2_USE_MMU # glib2
> +	depends on BR2_INSTALL_LIBSTDCPP # pango
> +	depends on BR2_TOOLCHAIN_HAS_SYNC_4 # pango -> harfbuzz
> +	depends on BR2_TOOLCHAIN_GCC_AT_LEAST_4_9 # pango -> harfbuzz
> +	depends on BR2_PACKAGE_HAS_LIBEGL_WAYLAND || BR2_PACKAGE_HAS_LIBGL

And this to:

+       # Even in the case of X11/OpenGL, libgtk4 needs epoxy built
+       # with EGL support, see
+       # https://gitlab.gnome.org/GNOME/gtk/-/issues/6866.
+       depends on BR2_PACKAGE_HAS_LIBEGL


> +	select BR2_PACKAGE_CAIRO
> +	select BR2_PACKAGE_CAIRO_PS
> +	select BR2_PACKAGE_CAIRO_PDF
> +	select BR2_PACKAGE_CAIRO_SVG

These 3 options no longer exist, so I dropped them.

> +if BR2_PACKAGE_LIBGTK4
> +
> +config BR2_PACKAGE_LIBGTK4_BROADWAY
> +	bool "Broadway GDK backend"
> +	default y
> +	  help
> +	  This enables the Broadway backend for GDK, which provides
> +	  support for displaying GTK+ applications in a web browser,
> +	  using HTML5 and web sockets.
> +
> +	  For example, to run gtk4-demo on a target which IP address is
> +	  192.168.0.1 and use it from a web browser, execute the
> +	  following commands:
> +
> +	  $ broadwayd -a 192.168.0.1 -p 8080 :2 &
> +	  $ export GDK_BACKEND=broadway
> +	  $ export BROADWAY_DISPLAY=:2
> +	  $ gtk4-demo
> +
> +	  Then open a web browser at address http://192.168.0.1:8080.
> +	  Javascript and web sockets should be enabled.
> +
> +comment "Wayland GDK backend needs an OpenGL EGL backend provided by mesa3d w/ headers >= 3.17"
> +	depends on !BR2_PACKAGE_MESA3D_OPENGL_EGL || !BR2_TOOLCHAIN_HEADERS_AT_LEAST_3_17
> +
> +config BR2_PACKAGE_LIBGTK4_WAYLAND
> +	bool "Wayland GDK backend"
> +	default y
> +	depends on BR2_PACKAGE_HAS_LIBEGL_WAYLAND

Dropped, as the main option now implies EGL is available.

> +	depends on BR2_TOOLCHAIN_HEADERS_AT_LEAST_3_17
> +	select BR2_PACKAGE_WAYLAND

+       select BR2_PACKAGE_WAYLAND_PROTOCOLS

was missing.


> diff --git a/package/libgtk4/libgtk4.mk b/package/libgtk4/libgtk4.mk
> new file mode 100644
> index 000000000..2d3e5049a
> --- /dev/null
> +++ b/package/libgtk4/libgtk4.mk
> @@ -0,0 +1,111 @@
> +################################################################################
> +#
> +# libgtk4
> +#
> +################################################################################
> +
> +LIBGTK4_VERSION_MAJOR = 4.12
> +LIBGTK4_VERSION = $(LIBGTK4_VERSION_MAJOR).4
> +LIBGTK4_SOURCE = gtk-$(LIBGTK4_VERSION).tar.xz
> +LIBGTK4_SITE = https://download.gnome.org/sources/gtk/$(LIBGTK4_VERSION_MAJOR)
> +LIBGTK4_LICENSE = LGPL-2.0+
> +LIBGTK4_LICENSE_FILES = COPYING
> +LIBGTK4_CPE_ID_VENDOR = gnome
> +LIBGTK4_CPE_ID_PRODUCT = gtk
> +LIBGTK4_INSTALL_STAGING = YES
> +
> +LIBGTK4_DEPENDENCIES = host-pkgconf host-libgtk4 \
> +	gdk-pixbuf graphene libepoxy libglib2 pango \
> +	$(TARGET_NLS_DEPENDENCIES)
> +
> +LIBGTK4_CONF_OPTS = -Dbuild-tests=false

Added many more disabling:

+LIBGTK4_CONF_OPTS = \
+       -Dbuild-tests=false \
+       -Dmedia-ffmpeg=disabled \
+       -Dprint-cpdb=disabled \
+       -Dvulkan=disabled \
+       -Dcloudproviders=disabled \
+       -Dsysprof=disabled \
+       -Dtracker=disabled \
+       -Dcolord=disabled \
+       -Dintrospection=disabled \
+       -Ddocumentation=false \
+       -Dscreenshots=false \
+       -Dman-pages=false


> +
> +ifeq ($(BR2_PACKAGE_LIBGTK4_X11),y)
> +LIBGTK4_DEPENDENCIES += xlib_libXcursor xlib_libXi xlib_libXinerama
> +LIBGTK4_CONF_OPTS += -Dx11-backend=true
> +else
> +LIBGTK4_CONF_OPTS += -Dx11-backend=false
> +endif
> +
> +ifeq ($(BR2_PACKAGE_LIBGTK4_WAYLAND),y)
> +LIBGTK4_DEPENDENCIES += wayland libxkbcommon

Added wayland-protocols here, which was missing.

And I think that's pretty much it. Thanks a lot for the contribution!

Best regards,

Thomas
diff mbox series

Patch

diff --git a/DEVELOPERS b/DEVELOPERS
index f4b3d4627..d0a2cadba 100644
--- a/DEVELOPERS
+++ b/DEVELOPERS
@@ -1122,6 +1122,7 @@  F:	package/dado/
 F:	package/ficl/
 F:	package/graphene/
 F:	package/janet/
+F:	package/libgtk4/
 F:	package/libtomcrypt/
 F:	package/libtommath/
 F:	package/libwpe/
diff --git a/package/Config.in b/package/Config.in
index 9d659320b..5087792f7 100644
--- a/package/Config.in
+++ b/package/Config.in
@@ -1679,6 +1679,7 @@  menu "Graphics"
 	source "package/libgta/Config.in"
 	source "package/libgtk2/Config.in"
 	source "package/libgtk3/Config.in"
+	source "package/libgtk4/Config.in"
 	source "package/libjxl/Config.in"
 	source "package/libmediaart/Config.in"
 	source "package/libmng/Config.in"
diff --git a/package/libgtk4/Config.in b/package/libgtk4/Config.in
new file mode 100644
index 000000000..cda183c8d
--- /dev/null
+++ b/package/libgtk4/Config.in
@@ -0,0 +1,106 @@ 
+comment "libgtk4 needs a toolchain w/ wchar, threads, C++, gcc >= 4.9"
+	depends on BR2_USE_MMU
+	depends on BR2_TOOLCHAIN_HAS_SYNC_4
+	depends on !BR2_USE_WCHAR || !BR2_INSTALL_LIBSTDCPP || \
+		!BR2_TOOLCHAIN_GCC_AT_LEAST_4_9 || \
+		!BR2_TOOLCHAIN_HAS_THREADS
+
+comment "libgtk4 needs an OpenGL or an OpenGL-EGL/wayland backend"
+	depends on BR2_USE_MMU
+	depends on BR2_TOOLCHAIN_HAS_SYNC_4
+	depends on !BR2_PACKAGE_HAS_LIBEGL_WAYLAND && !BR2_PACKAGE_HAS_LIBGL
+
+config BR2_PACKAGE_LIBGTK4
+	bool "libgtk4"
+	depends on BR2_USE_WCHAR # glib2
+	depends on BR2_TOOLCHAIN_HAS_THREADS # glib2
+	depends on BR2_USE_MMU # glib2
+	depends on BR2_INSTALL_LIBSTDCPP # pango
+	depends on BR2_TOOLCHAIN_HAS_SYNC_4 # pango -> harfbuzz
+	depends on BR2_TOOLCHAIN_GCC_AT_LEAST_4_9 # pango -> harfbuzz
+	depends on BR2_PACKAGE_HAS_LIBEGL_WAYLAND || BR2_PACKAGE_HAS_LIBGL
+	select BR2_PACKAGE_CAIRO
+	select BR2_PACKAGE_CAIRO_PS
+	select BR2_PACKAGE_CAIRO_PDF
+	select BR2_PACKAGE_CAIRO_SVG
+	select BR2_PACKAGE_GDK_PIXBUF
+	select BR2_PACKAGE_GRAPHENE
+	select BR2_PACKAGE_LIBEPOXY
+	select BR2_PACKAGE_LIBGLIB2
+	select BR2_PACKAGE_PANGO
+	select BR2_PACKAGE_TIFF
+	# At least one backend is required
+	select BR2_PACKAGE_LIBGTK4_BROADWAY if \
+		!(BR2_PACKAGE_LIBGTK4_X11 || BR2_PACKAGE_LIBGTK4_WAYLAND)
+	help
+	  The GTK version 4 graphical user interface library
+
+	  https://www.gtk.org/
+
+if BR2_PACKAGE_LIBGTK4
+
+config BR2_PACKAGE_LIBGTK4_BROADWAY
+	bool "Broadway GDK backend"
+	default y
+	  help
+	  This enables the Broadway backend for GDK, which provides
+	  support for displaying GTK+ applications in a web browser,
+	  using HTML5 and web sockets.
+
+	  For example, to run gtk4-demo on a target which IP address is
+	  192.168.0.1 and use it from a web browser, execute the
+	  following commands:
+
+	  $ broadwayd -a 192.168.0.1 -p 8080 :2 &
+	  $ export GDK_BACKEND=broadway
+	  $ export BROADWAY_DISPLAY=:2
+	  $ gtk4-demo
+
+	  Then open a web browser at address http://192.168.0.1:8080.
+	  Javascript and web sockets should be enabled.
+
+comment "Wayland GDK backend needs an OpenGL EGL backend provided by mesa3d w/ headers >= 3.17"
+	depends on !BR2_PACKAGE_MESA3D_OPENGL_EGL || !BR2_TOOLCHAIN_HEADERS_AT_LEAST_3_17
+
+config BR2_PACKAGE_LIBGTK4_WAYLAND
+	bool "Wayland GDK backend"
+	default y
+	depends on BR2_PACKAGE_HAS_LIBEGL_WAYLAND
+	depends on BR2_TOOLCHAIN_HEADERS_AT_LEAST_3_17
+	select BR2_PACKAGE_WAYLAND
+	select BR2_PACKAGE_LIBXKBCOMMON
+	help
+	  This enables the Wayland backend for GDK.
+
+comment "X11 GDK backend needs an OpenGL provider"
+	depends on !BR2_PACKAGE_HAS_LIBGL
+
+config BR2_PACKAGE_LIBGTK4_X11
+	bool "X11 GDK backend"
+	default y
+	depends on BR2_PACKAGE_XORG7
+	depends on BR2_PACKAGE_HAS_LIBGL
+	select BR2_PACKAGE_XLIB_LIBXCURSOR
+	select BR2_PACKAGE_XLIB_LIBXI
+	select BR2_PACKAGE_XLIB_LIBXINERAMA
+	help
+	  This enables the X11 backend for GDK.
+
+config BR2_PACKAGE_LIBGTK4_GSTREAMER
+	bool "gstreamer support"
+	select BR2_PACKAGE_GSTREAMER1
+	select BR2_PACKAGE_GST1_PLUGINS_BASE
+	select BR2_PACKAGE_GST1_PLUGINS_BASE_LIB_OPENGL
+	select BR2_PACKAGE_GST1_PLUGINS_BAD
+	help
+	  Enable gstreamer support.
+
+config BR2_PACKAGE_LIBGTK4_DEMO
+	bool "Install libgtk4 demo/example programs"
+	select BR2_PACKAGE_SHARED_MIME_INFO
+	select BR2_PACKAGE_HICOLOR_ICON_THEME
+	help
+	  The GTK source base contains demo/exmaple programs.
+	  This option allows to install them to the target.
+
+endif
diff --git a/package/libgtk4/libgtk4.hash b/package/libgtk4/libgtk4.hash
new file mode 100644
index 000000000..efb944f2a
--- /dev/null
+++ b/package/libgtk4/libgtk4.hash
@@ -0,0 +1,5 @@ 
+# From https://download.gnome.org/sources/gtk/4.12/gtk-4.12.4.sha256sum
+sha256  ba67c6498e5599f928edafb9e08a320adfaa50ab2f0da6fc6ab2252fc2d57520  gtk-4.12.4.tar.xz
+
+# Hash for license file:
+sha256  b7993225104d90ddd8024fd838faf300bea5e83d91203eab98e29512acebd69c  COPYING
diff --git a/package/libgtk4/libgtk4.mk b/package/libgtk4/libgtk4.mk
new file mode 100644
index 000000000..2d3e5049a
--- /dev/null
+++ b/package/libgtk4/libgtk4.mk
@@ -0,0 +1,111 @@ 
+################################################################################
+#
+# libgtk4
+#
+################################################################################
+
+LIBGTK4_VERSION_MAJOR = 4.12
+LIBGTK4_VERSION = $(LIBGTK4_VERSION_MAJOR).4
+LIBGTK4_SOURCE = gtk-$(LIBGTK4_VERSION).tar.xz
+LIBGTK4_SITE = https://download.gnome.org/sources/gtk/$(LIBGTK4_VERSION_MAJOR)
+LIBGTK4_LICENSE = LGPL-2.0+
+LIBGTK4_LICENSE_FILES = COPYING
+LIBGTK4_CPE_ID_VENDOR = gnome
+LIBGTK4_CPE_ID_PRODUCT = gtk
+LIBGTK4_INSTALL_STAGING = YES
+
+LIBGTK4_DEPENDENCIES = host-pkgconf host-libgtk4 \
+	gdk-pixbuf graphene libepoxy libglib2 pango \
+	$(TARGET_NLS_DEPENDENCIES)
+
+LIBGTK4_CONF_OPTS = -Dbuild-tests=false
+
+ifeq ($(BR2_PACKAGE_LIBGTK4_X11),y)
+LIBGTK4_DEPENDENCIES += xlib_libXcursor xlib_libXi xlib_libXinerama
+LIBGTK4_CONF_OPTS += -Dx11-backend=true
+else
+LIBGTK4_CONF_OPTS += -Dx11-backend=false
+endif
+
+ifeq ($(BR2_PACKAGE_LIBGTK4_WAYLAND),y)
+LIBGTK4_DEPENDENCIES += wayland libxkbcommon
+LIBGTK4_CONF_OPTS += -Dwayland-backend=true
+else
+LIBGTK4_CONF_OPTS += -Dwayland-backend=false
+endif
+
+ifeq ($(BR2_PACKAGE_LIBGTK4_BROADWAY),y)
+LIBGTK4_CONF_OPTS += -Dbroadway-backend=true
+else
+LIBGTK4_CONF_OPTS += -Dbroadway-backend=false
+endif
+
+ifeq ($(BR2_PACKAGE_LIBGTK4_GSTREAMER),y)
+LIBGTK4_CONF_OPTS += -Dmedia-gstreamer=enabled
+LIBGTK4_DEPENDENCIES += gstreamer1 gst1-plugins-base gst1-plugins-bad
+else
+LIBGTK4_CONF_OPTS += -Dmedia-gstreamer=disabled
+endif
+
+ifeq ($(BR2_PACKAGE_CUPS),y)
+LIBGTK4_CONF_OPTS += -Dprint-cups=enabled
+LIBGTK4_DEPENDENCIES += cups
+else
+LIBGTK4_CONF_OPTS += -Dprint-cups=disabled
+endif
+
+ifeq ($(BR2_PACKAGE_LIBGTK4_DEMO),y)
+LIBGTK4_CONF_OPTS += -Ddemos=true -Dbuild-examples=true
+LIBGTK4_DEPENDENCIES += hicolor-icon-theme shared-mime-info
+else
+LIBGTK4_CONF_OPTS += -Ddemos=false -Dbuild-examples=false
+endif
+
+define LIBGTK4_COMPILE_GLIB_SCHEMAS
+	$(HOST_DIR)/bin/glib-compile-schemas \
+		$(TARGET_DIR)/usr/share/glib-2.0/schemas
+endef
+LIBGTK4_POST_INSTALL_TARGET_HOOKS += LIBGTK4_COMPILE_GLIB_SCHEMAS
+
+# here, we build a native gtk4-update-icon-cache as host-libgtk4
+
+HOST_LIBGTK4_DEPENDENCIES = \
+	host-gdk-pixbuf \
+	host-libglib2 \
+	host-pkgconf
+
+HOST_LIBGTK4_CFLAGS = \
+	-I $(@D)/gtk \
+	`$(HOST_MAKE_ENV) $(PKG_CONFIG_HOST_BINARY) --cflags --libs gdk-pixbuf-2.0`
+
+define HOST_LIBGTK4_CONFIGURE_CMDS
+	echo "#define BUILD_TOOLS 1" >> $(@D)/gtk/config.h
+	echo "#define GETTEXT_PACKAGE \"gtk40\"" >> $(@D)/gtk/config.h
+	echo "#define GTK_LOCALEDIR \"/usr/share/locale\"" >> $(@D)/gtk/config.h
+	echo "#define HAVE_UNISTD_H 1" >> $(@D)/gtk/config.h
+	echo "#define HAVE_FTW_H 1" >> $(@D)/gtk/config.h
+endef
+
+define HOST_LIBGTK4_BUILD_CMDS
+	$(HOSTCC) $(HOST_CFLAGS) $(HOST_LDFLAGS) \
+		$(@D)/tools/updateiconcache.c $(@D)/gtk/gtkiconcachevalidator.c\
+		$(HOST_LIBGTK4_CFLAGS) \
+		-o $(@D)/tools/gtk4-update-icon-cache
+endef
+
+define HOST_LIBGTK4_INSTALL_CMDS
+	$(INSTALL) -D -m 0755 $(@D)/tools/gtk4-update-icon-cache \
+		$(HOST_DIR)/bin/gtk4-update-icon-cache
+endef
+
+# Create icon-theme.cache for each of the icon directories/themes
+# It's not strictly necessary but speeds up lookups
+define LIBGTK4_UPDATE_ICON_CACHE
+	[ ! -d $(TARGET_DIR)/usr/share/icons ] || \
+		find $(TARGET_DIR)/usr/share/icons -maxdepth 1 -mindepth 1 -type d \
+			-exec $(HOST_DIR)/bin/gtk-update-icon-cache {} \;
+endef
+LIBGTK4_TARGET_FINALIZE_HOOKS += LIBGTK4_UPDATE_ICON_CACHE
+
+$(eval $(meson-package))
+$(eval $(host-generic-package))