diff --git a/recipes/incoming-clib/gtk4-hello.toml b/recipes/incoming-clib/gtk4-hello.toml new file mode 100644 index 00000000..017e29a5 --- /dev/null +++ b/recipes/incoming-clib/gtk4-hello.toml @@ -0,0 +1,47 @@ +# gtk4-hello — app GTK4 mínima de VALIDACIÓN: prueba que libgtk-4.a (static) es linkeable de verdad. +# Reutiliza el tarball de GTK4 solo como acarreo de [source] (lo ignora); escribe su propio hello.c y +# lo linkea ESTÁTICO contra todo el cierre GTK4 vía `pkg-config --static gtk4`. Si sella, el toolkit +# de GUI del lab es usable por apps, no solo "compila". deps = cierre .pc completo + gtk4. +name = "gtk4-hello" +version = "4.18.6" + +[source] +tarball = "https://download.gnome.org/sources/gtk/4.18/gtk-4.18.6.tar.xz" +sha256 = "e1817c650ddc3261f9a8345b3b22a26a5d80af154630dedc03cc7becefffd0fa" + +[build] +compiler = "zig-cc" +target = "x86_64-linux-musl" +link = "static" + +[build.phases] +# no-op: el tarball trae meson.build y el lab inyectaría `meson setup` por defecto si omito configure. +configure = "true" +compile = ''' +cat > hammer_hello.c <<'CEOF' +#include +static void activate(GtkApplication *app, gpointer user_data) { + GtkWidget *win = gtk_application_window_new(app); + gtk_window_set_title(GTK_WINDOW(win), "Hola desde hammer"); + gtk_window_set_default_size(GTK_WINDOW(win), 360, 220); + GtkWidget *label = gtk_label_new("GTK4 static-musl ✓ (zig cc)"); + gtk_window_set_child(GTK_WINDOW(win), label); + gtk_window_present(GTK_WINDOW(win)); +} +int main(int argc, char **argv) { + GtkApplication *app = gtk_application_new("org.hammer.hola", G_APPLICATION_DEFAULT_FLAGS); + g_signal_connect(app, "activate", G_CALLBACK(activate), NULL); + int status = g_application_run(G_APPLICATION(app), argc, argv); + g_object_unref(app); + return status; +} +CEOF +# gtk4.pc NO declara Libs.private (asume link dinámico contra libgtk-4.so); para ESTÁTICO hay que sumar +# las privadas que gdk/gsk linkean directo (harfbuzz-subset, epoxy, wayland, xkbcommon, tiff, jpeg). +export PKG_CONFIG_PATH=/usr/lib/pkgconfig +zig cc -mcpu=baseline -static hammer_hello.c -o gtk4-hello $(pkg-config --cflags --libs --static gtk4 harfbuzz-subset epoxy xkbcommon wayland-client wayland-egl libtiff-4 libjpeg cairo-script-interpreter) +''' +install = "mkdir -p /out/usr/bin && cp gtk4-hello /out/usr/bin/gtk4-hello" + +[deps] +build = ["pkgconf", "gtk4", "pango", "gdk-pixbuf", "cairo", "graphene", "glib", "harfbuzz", "fribidi", "fontconfig", "freetype", "pixman", "libpng", "expat", "libjpeg-turbo", "libtiff", "libepoxy", "wayland", "libxkbcommon", "libdrm", "pcre2", "libffi", "zlib", "mesa"] diff --git a/recipes/incoming-clib/gtk4.toml b/recipes/incoming-clib/gtk4.toml index 5d2349c6..e4b78d85 100644 --- a/recipes/incoming-clib/gtk4.toml +++ b/recipes/incoming-clib/gtk4.toml @@ -20,9 +20,20 @@ link = "static" # "libgtk_dep" NO es substring de "libgtk_static_dep" ⇒ no toca las que ya usan el estático. configure = "sed -i 's/libgtk_dep/libgtk_static_dep/g' tools/meson.build && PKG_CONFIG_PATH=/usr/lib/pkgconfig PYTHONPATH=/usr/lib/python3.12/site-packages meson setup output --prefix=/usr --buildtype=release --wrap-mode=nodownload --prefer-static -Ddefault_library=static -Dwayland-backend=true -Dx11-backend=false -Dbroadway-backend=false -Dwin32-backend=false -Dmacos-backend=false -Dvulkan=disabled -Dintrospection=disabled -Dbuild-demos=false -Dbuild-testsuite=false -Dbuild-tests=false -Dbuild-examples=false -Dmedia-gstreamer=disabled -Dprint-cups=disabled -Dprint-cpdb=disabled -Dcloudproviders=disabled -Dsysprof=disabled -Dtracker=disabled -Dcolord=disabled -Df16c=disabled -Ddocumentation=false -Dman-pages=false -Dc_args=-Wno-error=date-time" compile = "PYTHONPATH=/usr/lib/python3.12/site-packages ninja -C output" -# meson instala solo libgtk-4.so; copio el static_library('gtk') (libgtk.a, GTK completo) como libgtk-4.a -# para que `-lgtk-4` + `-static` resuelva al estático (el lab es static-musl). -install = "PYTHONPATH=/usr/lib/python3.12/site-packages DESTDIR=/out meson install -C output --no-rebuild && cp output/gtk/libgtk.a /out/usr/lib/libgtk-4.a" +# meson instala solo libgtk-4.so y genera convenience-libs THIN (gtk/gdk/gsk por separado, referencian +# los .o por ruta → inútiles fuera del build dir). Fusiono los tres en UN archive GORDO libgtk-4.a (embebe +# todos los .o) para que `-lgtk-4` + `-static` linkee de verdad en el lab static-musl. +install = ''' +PYTHONPATH=/usr/lib/python3.12/site-packages DESTDIR=/out meson install -C output --no-rebuild +rm -f /out/usr/lib/libgtk-4.a +cd output +objs="" +for a in $(find . -name '*.a'); do + d=$(dirname "$a"); b=$(basename "$a") + for o in $(cd "$d" && zig ar t "$b"); do objs="$objs $d/$o"; done +done +zig ar rcs /out/usr/lib/libgtk-4.a $objs +''' [deps] build = ["meson", "samurai", "python3", "pkgconf", "glib", "cairo", "pango", "gdk-pixbuf", "graphene", "libepoxy", "wayland", "wayland-protocols", "libxkbcommon", "libdrm", "fontconfig", "harfbuzz", "fribidi", "libpng", "pixman", "freetype", "expat", "libffi", "pcre2", "zlib", "libjpeg-turbo", "libtiff", "mesa"]