# SPDX-License-Identifier: MIT # Where the reference and its data are: sourced by every rung script. # # ARM7TDMI_PYTHON_PIN the reference commit this crate transcribes (f492a9a...): the # rungs refuse to judge against another revision. # REFERENCE the reference's source, a clone checked out at the pin (default: # external/arm7tdmi-python; scripts/fetch_reference.sh makes it). # ARM7TDMI_PYTHON the reference's working checkout, for its fetched data only # (default: ../arm7tdmi-python beside this repository): its # reference/ holds the corpus and the test ROMs # (its scripts/fetch_references.py) and the multiply model # (its scripts/build_referees.py). # REFERENCE_PYTHON the interpreter that runs the reference (default: that # checkout's .venv-pypy); the reference's own src/ comes first # on its path (PYTHONPATH), so the pinned code is what runs. # SST_CORPUS SingleStepTests ARM7TDMI v1 (default: its reference/src/...). # TEST_ROMS the directory holding jsmolka-gba-tests and alyosha-gba-tests. # MUL_MODEL zaydlang's multiply model built as a shared library. # REFCACHE the reference's cached traces and hashes (default: external/refcache), # keyed by the pin; another pin's cache is moved aside, never deleted. ROOT=${ROOT:-$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)} ARM7TDMI_PYTHON_PIN=f492a9aea77c63e538c948b969a7fd012b451284 REFERENCE=${REFERENCE:-"$ROOT/external/arm7tdmi-python"} ARM7TDMI_PYTHON=${ARM7TDMI_PYTHON:-"$ROOT/../arm7tdmi-python"} REFERENCE_PYTHON=${REFERENCE_PYTHON:-"$ARM7TDMI_PYTHON/.venv-pypy/bin/python"} SST_CORPUS=${SST_CORPUS:-"$ARM7TDMI_PYTHON/reference/src/SingleStepTests-ARM7TDMI/v1"} TEST_ROMS=${TEST_ROMS:-"$ARM7TDMI_PYTHON/reference/src"} MUL_MODEL=${MUL_MODEL:-"$ARM7TDMI_PYTHON/reference/build/mul_model.so"} REFCACHE=${REFCACHE:-"$ROOT/external/refcache"} JOBS=${JOBS:-4} export ROOT REFERENCE ARM7TDMI_PYTHON REFERENCE_PYTHON SST_CORPUS TEST_ROMS MUL_MODEL REFCACHE JOBS export PYTHONPATH="$REFERENCE/src:$REFERENCE${PYTHONPATH:+:$PYTHONPATH}" export PYPY_GC_NURSERY=${PYPY_GC_NURSERY:-1M} # The reference must be at its pin, with a clean tree, for a lockstep verdict to mean anything; # the cache must be the pin's. require_reference() { if [ ! -x "$REFERENCE_PYTHON" ]; then echo "no reference interpreter at $REFERENCE_PYTHON: set ARM7TDMI_PYTHON or REFERENCE_PYTHON" >&2 exit 2 fi local head head=$(git -C "$REFERENCE" rev-parse HEAD 2>/dev/null || echo unknown) if [ "$head" != "$ARM7TDMI_PYTHON_PIN" ] || [ -n "$(git -C "$REFERENCE" status --porcelain 2>/dev/null)" ]; then echo "$REFERENCE is at $head (or modified); the pin is $ARM7TDMI_PYTHON_PIN (scripts/fetch_reference.sh)" >&2 exit 2 fi local imported imported=$(cd / && "$REFERENCE_PYTHON" -c "import arm7tdmi_python, sys; print(arm7tdmi_python.__file__)") case "$imported" in "$REFERENCE/src/"*) ;; *) echo "the reference interpreter imports $imported, not the pinned clone" >&2; exit 2 ;; esac if [ -f "$REFCACHE/PIN" ] && [ "$(cat "$REFCACHE/PIN")" != "$ARM7TDMI_PYTHON_PIN" ]; then mv "$REFCACHE" "$REFCACHE-$(cut -c1-7 "$REFCACHE/PIN")" # moved aside, never deleted fi mkdir -p "$REFCACHE" echo "$ARM7TDMI_PYTHON_PIN" > "$REFCACHE/PIN" }