Something went wrong. Try again.
A terminal UI for Libby libbui.vinnymac.dev
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869#!/usr/bin/env sh# Builds a static Linux libbui for one musl target and runs it once to prove# it starts: natively when the target matches this machine, otherwise under# qemu-user. The release workflow builds every Linux binary with this, and# scripts/riscv64.sh is this script for riscv64. Needs rustup, zig and# cargo-zigbuild.## scripts/static-linux.sh x86_64-unknown-linux-musl# scripts/static-linux.sh aarch64-unknown-linux-musl# QEMU=qemu-aarch64-static scripts/static-linux.sh aarch64-unknown-linux-musl# REQUIRE_QEMU=1 scripts/static-linux.sh ... # fail instead of skipping the runset -eu
if [ $# -ne 1 ]; then echo "usage: $0 <target>, such as x86_64-unknown-linux-musl" >&2 exit 2fitarget=$1case "$target" in *-linux-musl) ;; *) echo "error: $target is not a musl target; only musl builds are static" >&2 exit 2 ;;esac# riscv64gc-unknown-linux-musl runs on qemu-riscv64.arch="${target%%-*}"arch="${arch%gc}"cd "$(dirname "$0")/.."
rustup target add "$target" >/dev/nullcargo zigbuild --locked --release -p libbui --target "$target"binary="${CARGO_TARGET_DIR:-target}/$target/release/libbui"
# A static binary has no interpreter: it must run on any Linux of its# architecture, Alpine and the browser's aarch64 machine included.if readelf -l "$binary" | grep -q 'Requesting program interpreter'; then echo "error: $binary is dynamically linked" >&2 exit 1fi
if [ "$arch" = "$(uname -m)" ] && [ "$(uname -s)" = Linux ]; then runner="" where=nativelyelse runner="${QEMU:-qemu-$arch}" where="under $runner" if ! command -v "$runner" >/dev/null 2>&1; then if [ "${REQUIRE_QEMU:-0}" = 1 ]; then echo "error: $runner not found and REQUIRE_QEMU=1; the binary was never run" >&2 exit 1 fi echo "warning: $runner not found; built but not run" >&2 sha256sum "$binary" exit 0 fifi
# $runner is empty for a native run, so it must stay unquoted.# shellcheck disable=SC2086$runner "$binary" --version# shellcheck disable=SC2086$runner "$binary" --help >/dev/null# shellcheck disable=SC2086HOME="$(mktemp -d)" $runner "$binary" paths --json >/dev/nullecho "smoke test passed $where"
sha256sum "$binary"