# 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 <gtk/gtk.h>
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"]
