1DOLLY 82PACKAGE ghostty-gtk3REQUIRES HOST runtime@04REQUIRES HOST dso@05REQUIRES HOST pty@06REQUIRES HOST sockets@07REQUIRES HOST threads@089# Ghostty's GTK application from its release tarball, which carries its10# compiled interface files, built by Zig in Dolly over gtk-build and the11# libadwaita package: Ghostty's own build.zig (ghostty-dolly.patch; its12# packages fetched on the host, prepare-ghostty.sh).13FROM /demos/gtk/Dollyfile-gtk-build d669480ef8c389e2b97ec595f10f773a19792330fa5d56870573915141b2714c14USE /demos/zig/Dollyfile-zig-llvm f3629ce2c84a41427a65caad88636216ed8a8d7c7190b4b7f95b47f2b184dfcf15USE /demos/ghostty-gtk/Dollyfile-libadwaita abd97abd6a0191359088f6018ffee39f7ce196da1bcdf9eac3857a21f0a06f5616USE /Dollyfile-libdolly-pty 2dc46dfff7c7fee8075069868c7bbc87077a3eb712bb1865f34264ac0315dbd91718REQUIRES TOOL   c++19REQUIRES TOOL   cc20REQUIRES TOOL   cp21REQUIRES TOOL   glib-compile-schemas22REQUIRES TOOL   gzip23REQUIRES TOOL   ln24REQUIRES TOOL   meson25REQUIRES TOOL   mkdir26REQUIRES TOOL   patch27REQUIRES TOOL   python328REQUIRES TOOL   tar29REQUIRES TOOL   zig3031# What GTK's libraries read as they start, which a static link leaves out:32# GTK's settings schemas, which gtk-build keeps, compiled (a dialog that keeps33# a setting, as the emoji chooser of a text field does, aborts without its34# schema), and fontconfig's configuration, for the fonts an image has in35# /usr/share/fonts.36SLOP glib-compile-schemas --strict /usr/share/glib-2.0/schemas37FILE /usr/share/glib-2.0/schemas/gschemas.compiled38FILE /etc/fonts/fonts.conf39    <?xml version="1.0"?>40    <!DOCTYPE fontconfig SYSTEM "urn:fontconfig:fonts.dtd">41    <fontconfig>42      <dir>/usr/share/fonts</dir>43      <cachedir>/tmp/fontconfig</cachedir>44    </fontconfig>4546# Zig hands a link to cc without the program's own flags. This cc passes47# all of it to Dolly's and gives Ghostty's link the rest: Binaryen's cast48# emulation (GObject calls through pointers of other types), the X libraries,49# Mesa's driver, which its EGL links, and libadwaita's resources, registered50# by constructors that wasm-ld keeps only for objects something keeps (an51# export does).52FILE /tmp/ghostty-cc/cc.c53    #include <spawn.h>54    #include <stdio.h>55    #include <stdlib.h>56    #include <string.h>57    #include <sys/wait.h>58    extern char **environ;59    static const char *const ghostty[] = {"--dolly-cast-emulation", "-Wl,--initial-memory=268435456",60      "-Wl,--export=adw_get_resource", "-Wl,--export=adw_stylesheet_get_resource", "-L/usr/lib",61      "-lgallium_dri", "-lXext", "-lX11", "-lxcb", "-lXau", "-lz", "-ldolly-sockets", "-lm"};62    int main(int argc, char **argv) {63      int link = 1, program = 0;64      for (int i = 1; i < argc; i++) {65        if (!strcmp(argv[i], "-c") || !strcmp(argv[i], "-E") || !strcmp(argv[i], "-S")) link = 0;66        if (!strcmp(argv[i], "-o") && i + 1 < argc) {67          const char *slash = strrchr(argv[i + 1], '/');68          program = !strcmp(slash ? slash + 1 : argv[i + 1], "ghostty.wasm");69        }70      }71      char **args = calloc((size_t)argc + sizeof(ghostty) / sizeof(*ghostty) + 1, sizeof(char *));72      size_t n = 0;73      args[n++] = link && program ? "/bin/c++" : "/bin/cc";74      for (int i = 1; i < argc; i++) args[n++] = argv[i];75      if (link && program) for (size_t i = 0; i < sizeof(ghostty) / sizeof(*ghostty); i++) args[n++] = (char *)ghostty[i];76      pid_t pid;77      int status;78      if (posix_spawn(&pid, args[0], NULL, NULL, args, environ) != 0) return perror(args[0]), 127;79      if (waitpid(pid, &status, 0) != pid) return 127;80      return WIFEXITED(status) ? WEXITSTATUS(status) : 128 + WTERMSIG(status);81    }82SLOP cc -O1 /tmp/ghostty-cc/cc.c -o /tmp/ghostty-cc/cc83# Ghostty's build finds libdolly-sockets and libdolly-pty under a prefix's lib.84SLOP mkdir -p /tmp/ghostty-prefix && ln -s /usr/lib /tmp/ghostty-prefix/lib8586SOURCE /dist/static/ghostty-gtk/ghostty.tar.gz f11c48d17b3237e5f8590f6df96a61eac3f5abade37d1b52aaf75f5611600077 /tmp/ghostty.tar.gz87SLOP gzip -dc /tmp/ghostty.tar.gz | tar -xf - -C /88# Ghostty's threads share the program's memory, so its code needs wasm's89# atomics, which Zig's baseline for Emscripten lacks: the CPU Dolly's cc90# compiles for, with the simd128 Ghostty adds when no CPU is named.91SLOP CWD /tmp/ghostty PATH=/tmp/ghostty-cc:$PATH ZIG_LIBC=/usr/lib/zig/libc.txt zig build -Dapp-runtime=gtk -Doptimize=ReleaseFast -Dcpu=generic+atomics+simd128 \92  -Dgtk-wayland=false -Dsentry=false -Di18n=false -Demit-docs=false -Demit-terminfo=false -Demit-termcap=false \93  -Dversion-string=1.4.0 -fsys=freetype -fsys=harfbuzz -fsys=fontconfig -fsys=libpng -fsys=zlib \94  --search-prefix /tmp/ghostty-prefix --summary none95SLOP cp /tmp/ghostty/zig-out/bin/ghostty.wasm /usr/bin/ghostty96SLOP ghostty +version | grep -q 'Ghostty 1.4.0'9798SLOP mkdir -p /usr/share/licenses/ghostty-gtk99SLOP cp /tmp/ghostty/LICENSE /usr/share/licenses/ghostty-gtk/ghostty-LICENSE100SLOP cp /usr/share/licenses/libadwaita/COPYING /usr/share/licenses/ghostty-gtk/libadwaita-COPYING101SLOP cp /usr/share/licenses/mesa/license.rst /usr/share/licenses/ghostty-gtk/mesa-license.rst102EXPORTS TOOL ghostty103FILE /usr/share/licenses/ghostty-gtk/ghostty-LICENSE104FILE /usr/share/licenses/ghostty-gtk/libadwaita-COPYING105FILE /usr/share/licenses/ghostty-gtk/mesa-license.rst106FILE /usr/share/man/cat1/ghostty.1107    ghostty: Ghostty's GTK application, built inside Dolly from the pinned108    commit, for an X server (x11-desktop starts one).109    110      ghostty                           a window with $SHELL in it111      ghostty --command=direct:/bin/slop --gtk-single-instance=false112      ghostty +version                  its version113      ghostty +help                     the actions and options114    115    It draws its terminal with Mesa's OpenGL in the program (softpipe through116    EGL's surfaceless platform) and its window with cairo.117    Upstream's documentation: https://ghostty.org/docs118