1DOLLY 72PACKAGE glib3REQUIRES HOST runtime@04REQUIRES HOST dso@05REQUIRES HOST http@06REQUIRES HOST sockets@07REQUIRES HOST threads@089# GLib from upstream's release, built by its own Meson with one patch10# (glib-dolly.patch: g_unix_fd_query_path is not supported here, as on Hurd).11# A program that links GLib is threaded, calls through libffi (dso@0's FFI)12# and calls functions through pointers cast to types of other parameters,13# which traps in WebAssembly: GObject's pkg-config file asks cc for14# --dolly-cast-emulation (Binaryen's wasm-opt --fpcast-emu after the link),15# and this package's own programs are passed through it here.16FROM /v0.1.4/demos/tools/Dollyfile-tools-build 81e1c1bc8b06c83b1daead6c8f09bc8b1382e8fe165f896a98109396b58bb30517INSTALL /v0.1.4/demos/tools/Dollyfile-meson fdf6b56135f6b2446e9b02680b94a43c04a95ddb0aa1ee9ec9176658b365eb8a18INSTALL /v0.1.4/demos/zero-ad/Dollyfile-pkgconf c9be89938c3e165017d6b0763625b658b6409345f90275460e4a161d90f679ef19INSTALL /v0.1.4/demos/tools/Dollyfile-xz 97034a7e8088aba5b63ff0a5f8fea7b42e7e44c88c69ea20e23ad165ae1e658d20INSTALL /v0.1.4/demos/tools/Dollyfile-tar 23cd8ef5cce746bd0a47657aba6d1914efd81017ec0a4c20e7f78944e058eae721INSTALL /v0.1.4/demos/tools/Dollyfile-binaryen cd48f69ce9313510b9d9841a27dafa3612b28b373aa533e09c63a61ceb68d1cd22INSTALL /v0.1.4/demos/python/Dollyfile-libffi 5e6a33f1ebf1a038fb1799089b2f806acb35df54f315c1b140a544e78c92c7fc23INSTALL /v0.1.4/demos/gtk/Dollyfile-pcre2 cd1ab1a2d55cfb88c4b0300936afe442c9eb1eb141937ba36b907799160e143c24INSTALL /v0.1.4/Dollyfile-zlib 7f3254e8d51bc7edd2fa47b19f3b1e2e43c747476ab93c57654639e4119abde72526REQUIRES HEADER ffi27REQUIRES HEADER pcre228REQUIRES HEADER zlib29REQUIRES LIB    ffi30REQUIRES LIB    pcre2-831REQUIRES LIB    z32REQUIRES TOOL   cc33REQUIRES TOOL   grep34REQUIRES TOOL   meson35REQUIRES TOOL   mv36REQUIRES TOOL   patch37REQUIRES TOOL   pkg-config38REQUIRES TOOL   sed39REQUIRES TOOL   tar40REQUIRES TOOL   wasm-opt41REQUIRES TOOL   xz4243SOURCE /v0.1.4/dist/static/gtk/glib-2.90.1.tar.xz 93c941aa17d5eb1d53fe838365f29a8b4e539c222a256d974ec8f30fc413e396 /tmp/glib.tar.xz44SOURCE /v0.1.4/dist/static/gtk/glib-dolly.patch f7cf8e258bd3cedd3ed89eeecd2b4cd98e9d90f6d308857895b843e9684d1d54 /tmp/glib-dolly.patch45SLOP CWD /tmp xz -dc glib.tar.xz | tar -xf -46SLOP patch -p1 -d /tmp/glib-2.90.1 -i /tmp/glib-dolly.patch47# No tests, translations, introspection data or kernel facilities Dolly has48# not; the wraps would download, so Meson finds the packages above.49SLOP meson setup /tmp/glib-build /tmp/glib-2.90.1 --wrap-mode=nodownload --prefix=/usr --libdir=lib \50  --buildtype=release -Ddefault_library=static -Dtests=false -Dintrospection=disabled -Dnls=disabled \51  -Dselinux=disabled -Dxattr=false -Dlibmount=disabled -Dman-pages=disabled -Ddtrace=disabled \52  -Dsystemtap=disabled -Dsysprof=disabled -Dlibelf=disabled -Dglib_debug=disabled53SLOP meson compile -C /tmp/glib-build && meson install --no-rebuild -C /tmp/glib-build54SLOP sed 's/^Libs: \(.*\)$/Libs: \1 --dolly-cast-emulation/' /usr/lib/pkgconfig/gobject-2.0.pc > /tmp/gobject.pc && \55  mv /tmp/gobject.pc /usr/lib/pkgconfig/gobject-2.0.pc56# Upstream's Python tools start with #!/usr/bin/env; Dolly's env is /bin/env.57SLOP CWD /usr/bin for script in glib-mkenums glib-genmarshal gdbus-codegen gtester-report; do \58  sed '1s|.*|#!/usr/bin/python3|' $script > /tmp/$script && mv /tmp/$script $script; done59SLOP CWD /usr/bin for program in glib-compile-resources glib-compile-schemas gio gresource gsettings; do \60  wasm-opt --fpcast-emu $program -o $program.emulated && mv $program.emulated $program; done6162# A GObject type, a signal its handler takes fewer parameters of, one through63# the generic marshaller (libffi), a sort through a cast, a thread, a main64# loop and GIO reading a file.65FILE /tmp/glib-check.c66    #include <gio/gio.h>67    #include <stdio.h>68    #include <string.h>69    #define PROBE_TYPE (probe_get_type())70    G_DECLARE_FINAL_TYPE(Probe, probe, PROBE, OBJECT, GObject)71    struct _Probe { GObject parent; int seen; };72    G_DEFINE_FINAL_TYPE(Probe, probe, G_TYPE_OBJECT)73    static guint touched, weighed;74    static void probe_class_init(ProbeClass *klass) {75      (void)klass;76      touched = g_signal_new("touched", PROBE_TYPE, G_SIGNAL_RUN_LAST, 0, NULL, NULL, NULL, G_TYPE_NONE, 1, G_TYPE_INT);77      weighed = g_signal_new("weighed", PROBE_TYPE, G_SIGNAL_RUN_LAST, 0, NULL, NULL, NULL,78                             G_TYPE_INT, 3, G_TYPE_INT, G_TYPE_DOUBLE, G_TYPE_STRING);79    }80    static void probe_init(Probe *self) { self->seen = 0; }81    static void on_touched(Probe *self) { self->seen = 1; }82    static int on_weighed(Probe *self, int number, double scale, const char *word, gpointer data) {83      (void)self;84      return number * (int)scale + (int)strlen(word) + GPOINTER_TO_INT(data);85    }86    static gint by_number(gconstpointer left, gconstpointer right) { return GPOINTER_TO_INT(left) - GPOINTER_TO_INT(right); }87    static gpointer twice(gpointer data) { return GINT_TO_POINTER(GPOINTER_TO_INT(data) * 2); }88    static gboolean quit(gpointer loop) { g_main_loop_quit(loop); return G_SOURCE_REMOVE; }89    int main(void) {90      Probe *probe = g_object_new(PROBE_TYPE, NULL);91      int weight = 0;92      g_signal_connect(probe, "touched", G_CALLBACK(on_touched), NULL);93      g_signal_connect(probe, "weighed", G_CALLBACK(on_weighed), GINT_TO_POINTER(1));94      g_signal_emit(probe, touched, 0, 7);95      g_signal_emit(probe, weighed, 0, 20, 2.0, "go", &weight);96      GList *list = g_list_sort(g_list_prepend(g_list_prepend(NULL, GINT_TO_POINTER(2)), GINT_TO_POINTER(1)), by_number);97      list = g_list_sort(list, by_number);98      GThread *thread = g_thread_new("twice", twice, GINT_TO_POINTER(21));99      GMainLoop *loop = g_main_loop_new(NULL, FALSE);100      g_timeout_add(10, quit, loop);101      g_main_loop_run(loop);102      char *contents = NULL;103      gboolean read = g_file_load_contents(g_file_new_for_path("/tmp/glib-check.c"), NULL, &contents, NULL, NULL, NULL);104      if (probe->seen != 1 || weight != 43 || GPOINTER_TO_INT(list->data) != 1 ||105          GPOINTER_TO_INT(g_thread_join(thread)) != 42 || !read || !strstr(contents, "GLIB-OK")) return 1;106      return puts("GLIB-OK") < 0;107    }108SLOP cc -O1 -pthread /tmp/glib-check.c -o /tmp/glib-check $(pkg-config --cflags --libs gio-2.0) && \109  /tmp/glib-check | grep -qx GLIB-OK110111EXPORTS LIB    glib-2.0    /usr/lib/libglib-2.0.a112EXPORTS LIB    gobject-2.0 /usr/lib/libgobject-2.0.a113EXPORTS LIB    gio-2.0     /usr/lib/libgio-2.0.a114EXPORTS LIB    gmodule-2.0 /usr/lib/libgmodule-2.0.a115EXPORTS LIB    gthread-2.0 /usr/lib/libgthread-2.0.a116EXPORTS HEADER glib        /usr/include/glib-2.0117EXPORTS HEADER glibconfig  /usr/lib/glib-2.0/include118EXPORTS HEADER gio-unix    /usr/include/gio-unix-2.0119EXPORTS FILE   glib-pkgconfig          /usr/lib/pkgconfig/glib-2.0.pc120EXPORTS FILE   gobject-pkgconfig       /usr/lib/pkgconfig/gobject-2.0.pc121EXPORTS FILE   gio-pkgconfig           /usr/lib/pkgconfig/gio-2.0.pc122EXPORTS FILE   gio-unix-pkgconfig      /usr/lib/pkgconfig/gio-unix-2.0.pc123EXPORTS FILE   gmodule-pkgconfig       /usr/lib/pkgconfig/gmodule-2.0.pc124EXPORTS FILE   gmodule-export-pkgconfig /usr/lib/pkgconfig/gmodule-export-2.0.pc125EXPORTS FILE   gmodule-no-export-pkgconfig /usr/lib/pkgconfig/gmodule-no-export-2.0.pc126EXPORTS FILE   gthread-pkgconfig       /usr/lib/pkgconfig/gthread-2.0.pc127EXPORTS TOOL   glib-compile-resources128EXPORTS TOOL   glib-compile-schemas129EXPORTS TOOL   glib-mkenums130EXPORTS TOOL   glib-genmarshal131EXPORTS TOOL   gdbus-codegen132EXPORTS TOOL   gio133EXPORTS TOOL   gresource134EXPORTS TOOL   gsettings135EXPORTS FOLDER glib-data   /usr/share/glib-2.0136# COPYING is a link to the licence.137SLOP mkdir -p /usr/share/licenses/glib && cp /tmp/glib-2.90.1/LICENSES/LGPL-2.1-or-later.txt /usr/share/licenses/glib/COPYING138FILE /usr/share/licenses/glib/COPYING139FILE /usr/share/man/cat1/glib.1140    GLib 2.90 inside Dolly: GLib, GObject and GIO for programs the cc package141    builds, and their tools.142    143      cc -pthread prog.c -o prog $(pkg-config --cflags --libs gio-2.0)144                       GObject's pkg-config file adds --dolly-cast-emulation:145                       GObject calls functions through casts146      glib-compile-resources, glib-compile-schemas, glib-mkenums,147      glib-genmarshal, gdbus-codegen        as upstream's148    149    Upstream's documentation: https://docs.gtk.org/glib/150