#!/usr/bin/env bash set -euo pipefail # Queso bundles the BEAM runtime and uses Zig to cross-compile its native # launcher. Install both tools before running this script. export PATH="$HOME/.cargo/bin:$PATH" QUESO="${QUESO:-$(command -v queso || true)}" if [ -z "$QUESO" ] && [ -x "$HOME/.cargo/bin/queso" ]; then QUESO="$HOME/.cargo/bin/queso" fi if [ -z "$QUESO" ]; then echo "queso is required: cargo install --locked queso" >&2 exit 1 fi if ! command -v cargo-zigbuild >/dev/null 2>&1; then echo "cargo-zigbuild is required: cargo install cargo-zigbuild" >&2 exit 1 fi if ! command -v zig >/dev/null 2>&1; then echo "zig is required: https://ziglang.org/download/" >&2 exit 1 fi if ! command -v rustup >/dev/null 2>&1; then echo "rustup is required to install the Linux cross-compilation targets" >&2 exit 1 fi # Queso uses cargo-zigbuild for the native launcher. Keep this setup in the # build command so a fresh build machine does not fail halfway through. rustup target add x86_64-unknown-linux-musl aarch64-unknown-linux-musl rm -rf build/queso # zstd (used by Queso's launcher) uses cc-rs directly. Point it at Zig so the # build does not require separate *-linux-musl-gcc packages on the host. mkdir -p build/luma-cross cat > build/luma-cross/x86_64-cc <<'EOF' #!/usr/bin/env bash args=() for arg in "$@"; do [[ "$arg" == --target=* ]] || args+=("$arg") done exec zig cc -target x86_64-linux-musl "${args[@]}" EOF cat > build/luma-cross/aarch64-cc <<'EOF' #!/usr/bin/env bash args=() for arg in "$@"; do [[ "$arg" == --target=* ]] || args+=("$arg") done exec zig cc -target aarch64-linux-musl "${args[@]}" EOF chmod +x build/luma-cross/*-cc export CC_x86_64_unknown_linux_musl="$PWD/build/luma-cross/x86_64-cc" export CC_aarch64_unknown_linux_musl="$PWD/build/luma-cross/aarch64-cc" "$QUESO" build \ --target x86_64-linux-static \ --target aarch64-linux-static find build/queso -type f -name '*x86_64*' -perm -u+x -exec cp {} luma_markdown-linux-x86_64 \; find build/queso -type f -name '*aarch64*' -perm -u+x -exec cp {} luma_markdown-linux-arm64 \; chmod +x luma_markdown-linux-x86_64 luma_markdown-linux-arm64 echo "Built luma_markdown-linux-x86_64 and luma_markdown-linux-arm64"