# SPDX-License-Identifier: MIT # Where the reference and its data are: sourced by every rung script. # # SH2_PYTHON the sh2-python checkout (default: ../sh2-python beside this repository) # SH2_PYTHON_PIN the commit it must be at: the rungs refuse to judge against another # revision (or a modified src/) unless ALLOW_OTHER_PIN=1 # REFERENCE_PYTHON its interpreter (default: its own .venv-pypy) # SH2_MAME_TRACES rung 2's MAME 0.285 traces (default: its tests/mame_traces; machine-local, # made by its scripts/mame_trace.py from the user's own cartridges) # JOBS parallel processes (default 8; the machine is shared) ROOT=${ROOT:-$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)} SH2_PYTHON=${SH2_PYTHON:-"$ROOT/../sh2-python"} SH2_PYTHON_PIN=${SH2_PYTHON_PIN:-8824075c090795bfb43813a6def540e12095cb3e} REFERENCE_PYTHON=${REFERENCE_PYTHON:-"$SH2_PYTHON/.venv-pypy/bin/python"} SH2_MAME_TRACES=${SH2_MAME_TRACES:-"$SH2_PYTHON/tests/mame_traces"} JOBS=${JOBS:-8} export ROOT SH2_PYTHON SH2_PYTHON_PIN REFERENCE_PYTHON SH2_MAME_TRACES JOBS export PYPY_GC_NURSERY=${PYPY_GC_NURSERY:-1M} # A cargo whose clippy matches its rustc, when the default one's does not. STABLE="$HOME/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin" # The reference must be at its pin, with a clean src/, for a lockstep verdict to mean anything. require_reference() { if [ ! -x "$REFERENCE_PYTHON" ]; then echo "no reference interpreter at $REFERENCE_PYTHON: set SH2_PYTHON or REFERENCE_PYTHON" >&2 exit 2 fi local head head=$(git -C "$SH2_PYTHON" rev-parse HEAD 2>/dev/null || echo unknown) if [ "$head" != "$SH2_PYTHON_PIN" ] || [ -n "$(git -C "$SH2_PYTHON" status --porcelain -- src tests validation benchmarks 2>/dev/null)" ]; then if [ "${ALLOW_OTHER_PIN:-0}" != 1 ]; then echo "sh2-python is at $head (or its src/ tests/ validation/ are modified); the pin is $SH2_PYTHON_PIN" >&2 exit 2 fi echo "warning: judging against sh2-python $head, not the pin" >&2 fi } build() { nice -n 19 cargo build --release -q -j "$JOBS" --manifest-path "$ROOT/Cargo.toml" }