okami.mom/ultraviolet
git clone https://git.nkp.pet/okami.mom/ultraviolet
bbf040a
upstream
1name : libghostty-vt 2description : Build or restore libghostty-vt and point pkg-config at it. 3 4# libghostty-vt is the C library go-libghostty links against, and the 5# conformance module needs it to build at all. Three jobs across two workflows 6# need the same thing, so it lives here once rather than being copied into each 7# of them and drifting. 8 9runs : 10using : composite 11steps : 12# The library has to be built from the go-libghostty commit the module 13# already depends on. That commit's CMakeLists pins the ghostty revision it 14# fetches, and a different revision exports a different set of symbols than 15# these bindings call, so a mismatch fails at link time with undefined 16# symbols. Reading the commit out of go.mod is what keeps the two in step: 17# bumping the dependency moves the build with it, and there is no second 18# place to remember to update. 19- name : Resolve the go-libghostty pin 20id : pin 21shell : bash 22run : | 23mod=internal/conformance/go.mod 24 25# Exactly one line may mention the module. A replace directive, in 26# either spelling, adds another, and picking one silently builds a 27# revision the module does not use. 28matches=$(grep -c 'go\.mitchellh\.com/libghostty' "$mod" || true) 29if [ "$matches" -ne 1 ]; then 30echo "::error::expected one go.mitchellh.com/libghostty line in $mod, found $matches" 31exit 1 32fi 33version=$(awk '$1 == "go.mitchellh.com/libghostty" { print $2 }' "$mod") 34 35# A pseudo-version ends in the twelve-digit commit it was built from, 36# and that commit is the ref. Anything else is a tag, already a ref. 37rev=${version%+incompatible} 38if [[ $rev =~ -([0-9a-f]{12})$ ]]; then 39rev=${BASH_REMATCH[1]} 40fi 41echo "rev=$rev" >> "$GITHUB_OUTPUT" 42 43- uses : mlugg/setup-zig@v2 44with : 45version : "0.16.0" 46 47# Building from source takes a couple of minutes, so cache the result. The 48# key carries the pin, so the build happens again exactly when the 49# dependency moves and not otherwise. 50# 51# The cpu suffix is in the key so entries cached before the build below 52# pinned a baseline CPU are not reused. Those were tuned for whichever 53# runner produced them, and crash on a runner that lacks the instructions. 54- name : Cache libghostty-vt 55id : cache 56uses : actions/cache@v6 57with : 58path : ${{ github.workspace }}/.cache/libghostty-vt 59key : libghostty-vt-${{ steps.pin.outputs.rev }}-${{ runner.os }}-${{ runner.arch }}-cpu-baseline 60 61- name : Build libghostty-vt 62if : steps.cache.outputs.cache-hit != 'true' 63shell : bash 64run : | 65git clone https://github.com/mitchellh/go-libghostty /tmp/go-libghostty 66git -C /tmp/go-libghostty checkout --detach "${{ steps.pin.outputs.rev }}" 67# Zig builds for the host CPU unless told otherwise, so the library 68# picks up whatever instructions the runner that built it happened to 69# support. Every runner then shares that binary through the cache, and 70# one without those instructions dies on the first call into it. A 71# baseline CPU is what makes the artifact portable enough to cache. 72cmake -B /tmp/go-libghostty/build -S /tmp/go-libghostty \ 73-DCMAKE_BUILD_TYPE=Release \ 74-DGHOSTTY_ZIG_BUILD_FLAGS=-Dcpu=baseline 75cmake --build /tmp/go-libghostty/build 76mkdir -p .cache 77cp -r /tmp/go-libghostty/build/_deps/ghostty-src/zig-out .cache/libghostty-vt 78 79# The .pc file records the absolute path it was built at. Rewrite it to 80# point at this workspace so a restored cache resolves correctly, then put 81# it on PKG_CONFIG_PATH for every step that follows. 82- name : Configure pkg-config 83shell : bash 84run : | 85 prefix="${{ github.workspace }}/.cache/libghostty-vt" 86 sed -i "s|^prefix=.*|prefix=$prefix|" "$prefix/share/pkgconfig/libghostty-vt-static.pc" 87 echo "PKG_CONFIG_PATH=$prefix/share/pkgconfig" >> "$GITHUB_ENV"