Skip to content

Commit

Permalink
[GTK4] Add builder (#3915)
Browse files Browse the repository at this point in the history
* [GTK4] Add builder

* [GTK4] Add libsass as dependency and filter deps by platform

* [GTK4] Try to install native Sassc

* [GTK4] Install `gi-docgen` with `pip`...

* [GTK4] I think we can remove libsass completely

* [GTK4] Update to v4.6.0

* [GTK4] Downgrade to 4.5.0

v4.6.0 requires meson 0.59, which at the moment we don't have.  We'll eventually
rebuild the RootFS with a newer Meson, but at least we get this rolling.

* Revert "[GTK4] Downgrade to 4.5.0"

This reverts commit 808c38d.

* [GTK4] Add a patch for macOS

* Update build_tarballs.jl

* [GTK4] Use release build type

* [GTK4] Add patch for Windows

* [GTK4] Use `sassc` from our JLL package

* [GTK4] Remove `gi-docgen`, it's needed only to build docs

* [GTK4] Cleanup dependencies

* [GTK4] Change `ar` for macOS
  • Loading branch information
giordano authored Feb 6, 2022
1 parent fb31c78 commit 7b2b452
Show file tree
Hide file tree
Showing 3 changed files with 206 additions and 0 deletions.
123 changes: 123 additions & 0 deletions G/GTK4/build_tarballs.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
# Note that this script can accept some limited command-line arguments, run
# `julia build_tarballs.jl --help` to see a usage message.
using BinaryBuilder

name = "GTK4"
version = v"4.6.0"

# Collection of sources required to build GTK
sources = [
# https://download.gnome.org/sources/gtk/
ArchiveSource("https://download.gnome.org/sources/gtk/4.6/gtk-4.6.0.tar.xz",
"782d5951fbfd585fc9ec76c09d07e28e6014c72db001fb567fff217fb96e4d8c"),
DirectorySource("./bundled"),
]

# Bash recipe for building across all platforms
script = raw"""
cd $WORKSPACE/srcdir/gtk*/
# We need to run some commands with a native Glib
apk add glib-dev
# This is awful, I know
ln -sf /usr/bin/glib-compile-resources ${bindir}/glib-compile-resources
ln -sf /usr/bin/glib-compile-schemas ${bindir}/glib-compile-schemas
ln -sf /usr/bin/gdk-pixbuf-pixdata ${bindir}/gdk-pixbuf-pixdata
# Remove gio-2.0 pkgconfig file so that it isn't picked up by post-install script.
rm ${prefix}/lib/pkgconfig/gio-2.0.pc
# llvm-ar seems to generate corrupted static archives:
#
# [974/980] Linking target gtk/libgtk-4.1.dylib
# ninja: job failed: [...]
# ld: warning: ignoring file gtk/css/libgtk_css.a, building for macOS-x86_64 but attempting to link with file built for unknown-unsupported file format ( 0x21 0x3C 0x74 0x68 0x69 0x6E 0x3E 0x0A 0x2F 0x20 0x20 0x20 0x20 0x20 0x20 0x20 )
# ld: warning: ignoring file gtk/libgtk.a, building for macOS-x86_64 but attempting to link with file built for unknown-unsupported file format ( 0x21 0x3C 0x74 0x68 0x69 0x6E 0x3E 0x0A 0x2F 0x20 0x20 0x20 0x20 0x20 0x20 0x20 )
# ld: warning: ignoring file gsk/libgsk.a, building for macOS-x86_64 but attempting to link with file built for unknown-unsupported file format ( 0x21 0x3C 0x74 0x68 0x69 0x6E 0x3E 0x0A 0x2F 0x20 0x20 0x20 0x20 0x20 0x20 0x20 )
# ld: warning: ignoring file gsk/libgsk_f16c.a, building for macOS-x86_64 but attempting to link with file built for unknown-unsupported file format ( 0x21 0x3C 0x74 0x68 0x69 0x6E 0x3E 0x0A 0x2F 0x20 0x20 0x20 0x20 0x20 0x20 0x20 )
# Undefined symbols for architecture x86_64:
# "_gtk_make_symbolic_pixbuf_from_data", referenced from:
# _main in encodesymbolic.c.o
# ld: symbol(s) not found for architecture x86_64
if [[ "${target}" == *apple* ]]; then
sed -i "s?^ar = .*?ar = '/opt/${target}/bin/${target}-ar'?g" "${MESON_TARGET_TOOLCHAIN}"
fi
# https://gitlab.gnome.org/GNOME/gtk/-/merge_requests/4443
atomic_patch -p1 ../patches/0001-Include-gdk-private.h-to-fix-error-about-g_source_se.patch
# https://gitlab.gnome.org/GNOME/gtk/-/merge_requests/4445
atomic_patch -p1 ../patches/0001-gdkjpeg-include-stdlib.h-necessary-for-free.patch
FLAGS=()
if [[ "${target}" == *-apple-* ]]; then
FLAGS+=(-Dx11-backend=false -Dwayland-backend=false)
elif [[ "${target}" == *-freebsd* ]]; then
FLAGS+=(-Dwayland-backend=false)
elif [[ "${target}" == *-mingw* ]]; then
# Need to tell we're targeting at least Windows 7 so that `GC_ALLGESTURES` is defined
sed -ri "s/^c_args = \[(.*)\]/c_args = [\1, '-DWINVER=_WIN32_WINNT_WIN7']/" ${MESON_TARGET_TOOLCHAIN}
fi
mkdir build-gtk && cd build-gtk
meson .. \
--buildtype=release \
-Dmedia-gstreamer=disabled \
-Dintrospection=disabled \
-Ddemos=false \
-Dbuild-examples=false \
-Dbuild-tests=false \
-Dgtk_doc=false \
"${FLAGS[@]}" \
--cross-file="${MESON_TARGET_TOOLCHAIN}"
ninja -j${nproc}
ninja install
# Remove temporary links
rm ${bindir}/gdk-pixbuf-pixdata ${bindir}/glib-compile-{resources,schemas}
"""

# These are the platforms we will build for by default, unless further
# platforms are passed in on the command line
platforms = filter!(p -> arch(p) != "armv6l", supported_platforms(; experimental=true))

# The products that we will ensure are always built
products = [
LibraryProduct("libgtk-4", :libgtk4),
]

x11_platforms = filter(p -> Sys.islinux(p) || Sys.isfreebsd(p), platforms)

# Dependencies that must be installed before this package can be built
dependencies = [
# Need a native `sassc`
HostBuildDependency("SassC_jll"),
# Need a host Wayland for wayland-scanner
HostBuildDependency("Wayland_jll"; platforms=x11_platforms),
BuildDependency("Xorg_xorgproto_jll"; platforms=x11_platforms),
Dependency("Glib_jll"; compat="2.68.3"),
Dependency("Graphene_jll"; compat="1.10.6"),
Dependency("Cairo_jll"),
Dependency("Pango_jll"; compat="1.50.3"),
Dependency("FriBidi_jll"),
Dependency("FreeType2_jll"),
Dependency("gdk_pixbuf_jll"),
Dependency("Libepoxy_jll"),
Dependency("HarfBuzz_jll"),
Dependency("xkbcommon_jll"; platforms=x11_platforms),
Dependency("iso_codes_jll"),
Dependency("Wayland_jll"; platforms=x11_platforms),
Dependency("Wayland_protocols_jll"; compat="1.23", platforms=x11_platforms),
Dependency("Xorg_libXrandr_jll"; platforms=x11_platforms),
Dependency("Xorg_libX11_jll"; platforms=x11_platforms),
Dependency("Xorg_libXrender_jll"; platforms=x11_platforms),
Dependency("Xorg_libXi_jll"; platforms=x11_platforms),
Dependency("Xorg_libXext_jll"; platforms=x11_platforms),
Dependency("Xorg_libXcursor_jll"; platforms=x11_platforms),
Dependency("Xorg_libXdamage_jll"; platforms=x11_platforms),
Dependency("Xorg_libXfixes_jll"; platforms=x11_platforms),
Dependency("Xorg_libXinerama_jll"; platforms=x11_platforms),
Dependency("Fontconfig_jll"),
]

# Build the tarballs, and possibly a `build.jl` as well.
build_tarballs(ARGS, name, version, sources, script, platforms, products, dependencies; julia_compat="1.6", preferred_gcc_version=v"5")
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
From 2ceba0d31c40a916fc336d8662f1225710221cf8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Mos=C3=A8=20Giordano?= <[email protected]>
Date: Sat, 5 Feb 2022 21:51:40 +0000
Subject: [PATCH 1/1] Include `gdk-private.h` to fix error about
`g_source_set_static_name`

Without this change we get the following error:

```
[1/13] Compiling C object gdk/macos/libgdk-macos.a.p/gdkdisplaylinksource.c.o
ninja: job failed: /opt/bin/aarch64-apple-darwin20-libgfortran5-cxx11/aarch64-apple-darwin20-clang -Igdk/macos/libgdk-macos.a.p -Igdk/macos -I../gdk/macos -I. -I.. -Igdk -I../gdk -Isubprojects/pango/pango -I../subprojects/pango/pango -Isubprojects/pango -I../subprojects/pango -I/workspace/destdir/include/gdk-pixbuf-2.0 -I/workspace/destdir/include -I/workspace/destdir/include/glib-2.0 -I/workspace/destdir/lib/glib-2.0/include -I/workspace/destdir/lib/libffi-3.2.1/include -I/workspace/destdir/include/libpng16 -I/usr/include/libmount -I/usr/include/blkid -I/workspace/destdir/include/cairo -I/workspace/destdir/include/pixman-1 -I/workspace/destdir/include/freetype2 -I/workspace/destdir/include/fribidi -I/workspace/destdir/include/harfbuzz -I/workspace/destdir/include/graphene-1.0 -I/workspace/destdir/lib/graphene-1.0/include -I/workspace/destdir/include/gio-unix-2.0 -fcolor-diagnostics -Wall -Winvalid-pch -std=gnu99 -O2 -g -DG_LOG_USE_STRUCTURED=1 -DGLIB_DISABLE_DEPRECATION_WARNINGS '-DGTK_VERSION="4.6.0"' -D_GNU_SOURCE -DG_ENABLE_DEBUG -DGTK_COMPILATION '-DG_LOG_DOMAIN="Gdk"' -xobjective-c -fno-strict-aliasing -Wno-c++11-extensions -Wno-missing-include-dirs -Wno-typedef-redefinition -Wformat=2 -Wformat-nonliteral -Wformat-security -Wignored-qualifiers -Wimplicit-function-declaration -Wmisleading-indentation -Wmissing-format-attribute -Wmissing-include-dirs -Wmissing-noreturn -Wnested-externs -Wold-style-definition -Wpointer-arith -Wshadow -Wstrict-prototypes -Wswitch-default -Wswitch-enum -Wundef -Wuninitialized -Wunused -Werror=address -Werror=array-bounds -Werror=empty-body -Werror=implicit -Werror=implicit-fallthrough -Werror=init-self -Werror=int-to-pointer-cast -Werror=main -Werror=missing-braces -Werror=missing-declarations -Werror=missing-prototypes -Werror=nonnull -Werror=pointer-to-int-cast -Werror=redundant-decls -Werror=return-type -Werror=sequence-point -Werror=trigraphs -Werror=vla -Werror=write-strings -Wnull-dereference -fvisibility=hidden -MD -MQ gdk/macos/libgdk-macos.a.p/gdkdisplaylinksource.c.o -MF gdk/macos/libgdk-macos.a.p/gdkdisplaylinksource.c.o.d -o gdk/macos/libgdk-macos.a.p/gdkdisplaylinksource.c.o -c ../gdk/macos/gdkdisplaylinksource.c
../gdk/macos/gdkdisplaylinksource.c:201:3: error: implicit declaration of function 'g_source_set_static_name' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
g_source_set_static_name (source, "[gdk] quartz frame clock");
^
1 error generated.
ninja: subcommand failed
```
---
gdk/macos/gdkdisplaylinksource.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/gdk/macos/gdkdisplaylinksource.c b/gdk/macos/gdkdisplaylinksource.c
index 9587875dde..292b8be519 100644
--- a/gdk/macos/gdkdisplaylinksource.c
+++ b/gdk/macos/gdkdisplaylinksource.c
@@ -27,6 +27,7 @@
#include "gdkdisplaylinksource.h"

#include "gdkmacoseventsource-private.h"
+#include "gdk-private.h"

static gint64 host_to_frame_clock_time (gint64 val);

--
2.35.1

Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
From 4c211f1872eb6b1cd937bd98dc86b571fc87f304 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Mos=C3=A8=20Giordano?= <[email protected]>
Date: Sun, 6 Feb 2022 15:41:33 +0000
Subject: [PATCH 1/1] gdkjpeg: include `stdlib.h` necessary for `free`
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

`free` is defined in `stdlib.h`, see for example
<https://pubs.opengroup.org/onlinepubs/009604499/functions/free.html>. Without
this include compilation can fail with the following error:

```
../gdk/loaders/gdkjpeg.c: In function ‘gdk_save_jpeg’:
../gdk/loaders/gdkjpeg.c:264:7: warning: implicit declaration of function ‘free’ [-Wimplicit-function-declaration]
free (data);
^
../gdk/loaders/gdkjpeg.c:264:7: warning: incompatible implicit declaration of built-in function ‘free’
../gdk/loaders/gdkjpeg.c:264:7: note: include ‘<stdlib.h>’ or provide a declaration of ‘free’
../gdk/loaders/gdkjpeg.c:302:67: error: ‘free’ undeclared (first use in this function)
return g_bytes_new_with_free_func (data, size, (GDestroyNotify) free, NULL);
^
../gdk/loaders/gdkjpeg.c:302:67: note: each undeclared identifier is reported only once for each function it appears in
../gdk/loaders/gdkjpeg.c:303:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^
```
---
gdk/loaders/gdkjpeg.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/gdk/loaders/gdkjpeg.c b/gdk/loaders/gdkjpeg.c
index 8cbb0438a4..8f7e422f0c 100644
--- a/gdk/loaders/gdkjpeg.c
+++ b/gdk/loaders/gdkjpeg.c
@@ -15,6 +15,8 @@
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/

+#include <stdlib.h>
+
#include "config.h"

#include "gdkjpegprivate.h"
--
2.35.1

0 comments on commit 7b2b452

Please sign in to comment.