1DOLLY 72PACKAGE glib3REQUIRES HOST runtime@04REQUIRES HOST dso@05REQUIRES HOST threads@067# GLib from upstream's release, built by its own Meson with one patch8# (glib-dolly.patch: g_unix_fd_query_path is not supported here, as on Hurd).9# A program that links GLib is threaded, calls through libffi (dso@0's FFI)10# and calls functions through pointers cast to types of other parameters,11# which traps in WebAssembly: GObject's pkg-config file asks cc for12# --dolly-cast-emulation (Binaryen's wasm-opt --fpcast-emu after the link),13# and this package's own programs are passed through it here.14FROM /v0.1.5/demos/tools/Dollyfile-tools-build 9f9cfa93f7bc4ddd5fc5cbd9ced4d2100cd41349f9f2b6f75ab9d8e26a57da6215USE /v0.1.5/demos/tools/Dollyfile-meson 890d47e5587fb00a6ae468c7658415826862536b7390fd7fd1cb26abffa3dac616USE /v0.1.5/demos/zero-ad/Dollyfile-pkgconf 093ecdba243fbc62c20fd1c9c51aef92ed4a8f256f5500944e8011c832a9525817USE /v0.1.5/demos/tools/Dollyfile-xz 81e23252e1f473a7ea097b4c0cd9fcd460af14ab79499417ce8bdcac5b33061e18USE /v0.1.5/demos/tools/Dollyfile-tar 295eba689217629e18a9798ecc95ff30230161a0341c68d095fa4e23df51d9df19USE /v0.1.5/demos/tools/Dollyfile-binaryen 480e8afc4a00c4024e5ab9d5597c40b621cc58f1a4dad5c2e887d52048e7c74a20INSTALL /v0.1.5/demos/python/Dollyfile-libffi d8a7cebc28dc2c4ea4127c3eb866080a02bf4c817f425602567bff2a5acfed5f21INSTALL /v0.1.5/demos/gtk/Dollyfile-pcre2 109809537a9c2206d1283eed9097b16bcf6d0556b9996c35d1b5c35942a91db722INSTALL /v0.1.5/Dollyfile-zlib 0b706df4c643faf419bd9089995b97d13ff7237493d9bb9727f8d3df91cbe0332324REQUIRES HEADER ffi25REQUIRES HEADER pcre226REQUIRES HEADER zlib27REQUIRES LIB    ffi28REQUIRES LIB    pcre2-829REQUIRES LIB    z30REQUIRES TOOL   cc31REQUIRES TOOL   grep32REQUIRES TOOL   meson33REQUIRES TOOL   mv34REQUIRES TOOL   patch35REQUIRES TOOL   pkg-config36REQUIRES TOOL   sed37REQUIRES TOOL   tar38REQUIRES TOOL   wasm-opt39REQUIRES TOOL   xz4041SOURCE /v0.1.5/dist/static/gtk/glib-2.90.1.tar.xz 93c941aa17d5eb1d53fe838365f29a8b4e539c222a256d974ec8f30fc413e396 /tmp/glib.tar.xz42SOURCE /v0.1.5/dist/static/gtk/glib-dolly.patch f7cf8e258bd3cedd3ed89eeecd2b4cd98e9d90f6d308857895b843e9684d1d54 /tmp/glib-dolly.patch43SLOP CWD /tmp xz -dc glib.tar.xz | tar -xf -44SLOP patch -p1 -d /tmp/glib-2.90.1 -i /tmp/glib-dolly.patch45# No tests, translations, introspection data or kernel facilities Dolly has46# not; the wraps would download, so Meson finds the packages above.47SLOP meson setup /tmp/glib-build /tmp/glib-2.90.1 --wrap-mode=nodownload --prefix=/usr --libdir=lib \48  --buildtype=release -Ddefault_library=static -Dtests=false -Dintrospection=disabled -Dnls=disabled \49  -Dselinux=disabled -Dxattr=false -Dlibmount=disabled -Dman-pages=disabled -Ddtrace=disabled \50  -Dsystemtap=disabled -Dsysprof=disabled -Dlibelf=disabled -Dglib_debug=disabled51SLOP meson compile -C /tmp/glib-build && meson install --no-rebuild -C /tmp/glib-build52SLOP sed 's/^Libs: \(.*\)$/Libs: \1 --dolly-cast-emulation/' /usr/lib/pkgconfig/gobject-2.0.pc > /tmp/gobject.pc && \53  mv /tmp/gobject.pc /usr/lib/pkgconfig/gobject-2.0.pc54# Upstream's Python tools start with #!/usr/bin/env; Dolly's env is /bin/env.55SLOP CWD /usr/bin for script in glib-mkenums glib-genmarshal gdbus-codegen gtester-report; do \56  sed '1s|.*|#!/usr/bin/python3|' $script > /tmp/$script && mv /tmp/$script $script; done57SLOP CWD /usr/bin for program in glib-compile-resources glib-compile-schemas gio gresource gsettings; do \58  wasm-opt --fpcast-emu $program -o $program.emulated && mv $program.emulated $program; done5960# A GObject type, a signal its handler takes fewer parameters of, one through61# the generic marshaller (libffi), a sort through a cast, a thread, a main62# loop and GIO reading a file.63FILE /tmp/glib-check.c64    #include <gio/gio.h>65    #include <stdio.h>66    #include <string.h>67    #define PROBE_TYPE (probe_get_type())68    G_DECLARE_FINAL_TYPE(Probe, probe, PROBE, OBJECT, GObject)69    struct _Probe { GObject parent; int seen; };70    G_DEFINE_FINAL_TYPE(Probe, probe, G_TYPE_OBJECT)71    static guint touched, weighed;72    static void probe_class_init(ProbeClass *klass) {73      (void)klass;74      touched = g_signal_new("touched", PROBE_TYPE, G_SIGNAL_RUN_LAST, 0, NULL, NULL, NULL, G_TYPE_NONE, 1, G_TYPE_INT);75      weighed = g_signal_new("weighed", PROBE_TYPE, G_SIGNAL_RUN_LAST, 0, NULL, NULL, NULL,76                             G_TYPE_INT, 3, G_TYPE_INT, G_TYPE_DOUBLE, G_TYPE_STRING);77    }78    static void probe_init(Probe *self) { self->seen = 0; }79    static void on_touched(Probe *self) { self->seen = 1; }80    static int on_weighed(Probe *self, int number, double scale, const char *word, gpointer data) {81      (void)self;82      return number * (int)scale + (int)strlen(word) + GPOINTER_TO_INT(data);83    }84    static gint by_number(gconstpointer left, gconstpointer right) { return GPOINTER_TO_INT(left) - GPOINTER_TO_INT(right); }85    static gpointer twice(gpointer data) { return GINT_TO_POINTER(GPOINTER_TO_INT(data) * 2); }86    static gboolean quit(gpointer loop) { g_main_loop_quit(loop); return G_SOURCE_REMOVE; }87    int main(void) {88      Probe *probe = g_object_new(PROBE_TYPE, NULL);89      int weight = 0;90      g_signal_connect(probe, "touched", G_CALLBACK(on_touched), NULL);91      g_signal_connect(probe, "weighed", G_CALLBACK(on_weighed), GINT_TO_POINTER(1));92      g_signal_emit(probe, touched, 0, 7);93      g_signal_emit(probe, weighed, 0, 20, 2.0, "go", &weight);94      GList *list = g_list_sort(g_list_prepend(g_list_prepend(NULL, GINT_TO_POINTER(2)), GINT_TO_POINTER(1)), by_number);95      list = g_list_sort(list, by_number);96      GThread *thread = g_thread_new("twice", twice, GINT_TO_POINTER(21));97      GMainLoop *loop = g_main_loop_new(NULL, FALSE);98      g_timeout_add(10, quit, loop);99      g_main_loop_run(loop);100      char *contents = NULL;101      gboolean read = g_file_load_contents(g_file_new_for_path("/tmp/glib-check.c"), NULL, &contents, NULL, NULL, NULL);102      if (probe->seen != 1 || weight != 43 || GPOINTER_TO_INT(list->data) != 1 ||103          GPOINTER_TO_INT(g_thread_join(thread)) != 42 || !read || !strstr(contents, "GLIB-OK")) return 1;104      return puts("GLIB-OK") < 0;105    }106SLOP cc -O1 -pthread /tmp/glib-check.c -o /tmp/glib-check $(pkg-config --cflags --libs gio-2.0) && \107  /tmp/glib-check | grep -qx GLIB-OK108109EXPORTS LIB    glib-2.0    /usr/lib/libglib-2.0.a110EXPORTS LIB    gobject-2.0 /usr/lib/libgobject-2.0.a111EXPORTS LIB    gio-2.0     /usr/lib/libgio-2.0.a112EXPORTS LIB    gmodule-2.0 /usr/lib/libgmodule-2.0.a113EXPORTS LIB    gthread-2.0 /usr/lib/libgthread-2.0.a114EXPORTS HEADER glib        /usr/include/glib-2.0115EXPORTS HEADER glibconfig  /usr/lib/glib-2.0/include116EXPORTS HEADER gio-unix    /usr/include/gio-unix-2.0117EXPORTS FILE   glib-pkgconfig          /usr/lib/pkgconfig/glib-2.0.pc118EXPORTS FILE   gobject-pkgconfig       /usr/lib/pkgconfig/gobject-2.0.pc119EXPORTS FILE   gio-pkgconfig           /usr/lib/pkgconfig/gio-2.0.pc120EXPORTS FILE   gio-unix-pkgconfig      /usr/lib/pkgconfig/gio-unix-2.0.pc121EXPORTS FILE   gmodule-pkgconfig       /usr/lib/pkgconfig/gmodule-2.0.pc122EXPORTS FILE   gmodule-export-pkgconfig /usr/lib/pkgconfig/gmodule-export-2.0.pc123EXPORTS FILE   gmodule-no-export-pkgconfig /usr/lib/pkgconfig/gmodule-no-export-2.0.pc124EXPORTS FILE   gthread-pkgconfig       /usr/lib/pkgconfig/gthread-2.0.pc125EXPORTS TOOL   glib-compile-resources126EXPORTS TOOL   glib-compile-schemas127EXPORTS TOOL   glib-mkenums128EXPORTS TOOL   glib-genmarshal129EXPORTS TOOL   gdbus-codegen130EXPORTS TOOL   gio131EXPORTS TOOL   gresource132EXPORTS TOOL   gsettings133EXPORTS FOLDER glib-data   /usr/share/glib-2.0134# COPYING is a link to the licence.135SLOP mkdir -p /usr/share/licenses/glib && cp /tmp/glib-2.90.1/LICENSES/LGPL-2.1-or-later.txt /usr/share/licenses/glib/COPYING136FILE /usr/share/licenses/glib/COPYING137FILE /usr/share/man/cat1/glib.1138    GLib 2.90 inside Dolly: GLib, GObject and GIO for programs the cc package139    builds, and their tools.140    141      cc -pthread prog.c -o prog $(pkg-config --cflags --libs gio-2.0)142                       GObject's pkg-config file adds --dolly-cast-emulation:143                       GObject calls functions through casts144      glib-compile-resources, glib-compile-schemas, glib-mkenums,145      glib-genmarshal, gdbus-codegen        as upstream's146    147    Upstream's documentation: https://docs.gtk.org/glib/148