This repository has been archived on 2026-08-27. You can view files and clone it, but cannot push or open issues or pull requests.
gopher64-netplay/scripts/gate.sh
Claude c30bb32bf9 gopher64-netplay#16: runnable build gate on the review box
Two blockers fixed in .cargo/config.toml plus a documented gate script:
- target-cpu=x86-64-v3 (AVX2-only) is now opt-in — the default build is
  portable; on Sandy Bridge (x86-64-v2) it miscompiled build scripts
  (num-traits SIGABRT, 648518346341351440-byte allocation).
- AR=llvm-ar dropped (GNU ar is fine); CC=clang/CXX=clang++ retained
  because build.rs needs clang for -flto=thin, resolved via PATH.

scripts/gate.sh records the review-box command: init submodules, wire the
user-local LLVM-18 / pkgconf / fontconfig-X11 roots (no sudo available),
then cargo check --all-targets. docs/build-gate.md explains the failure
modes. Verified: ./scripts/gate.sh exits 0 end-to-end on this box.
2026-08-25 16:21:01 -05:00

57 lines
2.4 KiB
Bash
Executable File

#!/usr/bin/env bash
# gopher64-netplay review gate (issue #16)
#
# Documented gate command (from a clean origin/main checkout):
# ./scripts/gate.sh
#
# What it does:
# 1. `git submodule update --init --recursive` (parallel-rdp,
# retroachievements/rcheevos, src/compat/sse2neon) — required by
# build.rs.
# 2. Wires the review box's user-local provisioning onto PATH/env (only
# when present; a no-op on hosts with system toolchains):
# - clang/clang++ from the local LLVM-18 root (build.rs requires
# clang for `-flto=thin`)
# - a real pkgconf + fontconfig/X11 dev pc files (the box has no
# system pkg-config/fontconfig and no sudo)
# 3. Runs `cargo check --all-targets`.
#
# On AVX2-capable hardware, opt into the optimised CPU target:
# RUSTFLAGS="-C target-cpu=x86-64-v3" ./scripts/gate.sh
# (RUSTFLAGS REPLACES the config's rustflags for the whole invocation, so
# carry any other flags you need.)
set -euo pipefail
REPO_ROOT="$(cd "$(dirname "$0")/.." && pwd)"
cd "$REPO_ROOT"
git submodule update --init --recursive
# --- Review-box provisioning ----------------------------------------------
LLVM_BIN="$HOME/local-tools/root/usr/lib/llvm-18/bin"
LLVM_BIN2="$HOME/local-tools/root/usr/bin"
FCPC="$HOME/.local/bin-fc/pkg-config"
FCROOT="$HOME/.local/fcroot/usr"
PC_DIR="$FCROOT/lib/x86_64-linux-gnu/pkgconfig"
if [ -d "$LLVM_BIN" ]; then
export PATH="$LLVM_BIN:$PATH" # clang / clang++ (build.rs needs clang)
fi
if [ -d "$LLVM_BIN2" ]; then
export PATH="$LLVM_BIN2:$PATH" # cmake, ninja, pkgconf, wayland-scanner
fi
if [ -x "$FCPC" ] && [ -d "$PC_DIR" ]; then
export PATH="$(dirname "$FCPC"):$PATH" # real pkg-config (not the pypi shim)
export PKG_CONFIG_PATH="$PC_DIR"
# SDL's cmake resolves X11 via CMake's classic FindX11 module (path
# scan), not through pkg-config — point those scans at the root too.
export CMAKE_INCLUDE_PATH="$FCROOT/include${CMAKE_INCLUDE_PATH:+:$CMAKE_INCLUDE_PATH}"
export CMAKE_LIBRARY_PATH="$FCROOT/lib/x86_64-linux-gnu${CMAKE_LIBRARY_PATH:+:$CMAKE_LIBRARY_PATH}"
export LD_LIBRARY_PATH="$FCROOT/lib/x86_64-linux-gnu${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
fi
if [ -d "$HOME/local-tools/root/usr/lib/llvm-18/lib" ]; then
export LIBCLANG_PATH="$HOME/local-tools/root/usr/lib/llvm-18/lib" # bindgen/clang-sys
export LD_LIBRARY_PATH="$HOME/local-tools/root/usr/lib/llvm-18/lib${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
fi
exec cargo check --all-targets