#!/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) # - the provisioned cmake/ninja's OWN lib root on LD_LIBRARY_PATH # (without it cmake dies with exit 127: librhash/libuv/libjsoncpp # not found) # 3. Runs the gate, as three distinguishable steps: # a. `cargo check --all-targets` — TYPE-check everything, tests # included (compile-only; the historical main blocker) # b. `cargo test --no-run` — LINK every test binary (a test # that type-checks but cannot link is still a broken gate) # c. `cargo test --lib` — EXECUTE the headless library unit # tests (netplay state sync etc.; see docs/build-gate.md) # # 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 # cmake/ninja from this root link against librhash/libuv/libjsoncpp that # ship in the SAME root (`usr/lib/x86_64-linux-gnu`); without that dir on # LD_LIBRARY_PATH they die with exit 127 and cmake-rs reports it as # "is `cmake` not installed?" — the issue #16 review bounce. export LD_LIBRARY_PATH="$HOME/local-tools/root/usr/lib/x86_64-linux-gnu${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}" 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 # --- Gate: type-check, then link tests, then run the headless lib tests ---- echo "GATE step 1/3: cargo check --all-targets" cargo check --all-targets echo "GATE step 2/3: cargo test --no-run" cargo test --no-run echo "GATE step 3/3: cargo test --lib" # Issue #23: libtest runs each test on a thread with the 2 MiB default stack, # but debug builds of Device::new() materialise ~300 KiB of struct literals on # the stack per construction, so any Device-constructing unit test overflows # and aborts the WHOLE test binary. Give the test threads the same 8 MiB the # project already standardises on for the main thread (.cargo/config.toml # /STACK:8388608, Windows). Tests should additionally route their bodies # through test_util::with_big_stack so they also pass under a bare # `cargo test --lib` (see src/test_util.rs). export RUST_MIN_STACK=8388608 cargo test --lib echo "GATE_OK"