#!/bin/bash # The port's gate: the generated workflow - build, size tests, and the # simulator-driven protocol suite. --full adds the reflect build, which # compiles the same TUs through libavr's other producer. libavr resolves from # the `libavr/` submodule; LIBAVR_ROOT overrides it for a working tree. set -e cd "$(dirname "$0")/.." full=0 [[ "$1" == "--full" ]] && { full=1; shift; } # The chip lists come from the presets rather than being spelled a second time # here: a chip added to make_presets.py and missed in a copy of its list would # be a gate that silently never builds it, which is the one failure mode a gate # cannot report. tools/make_presets.py is the single source, CMakePresets.json # is its output, and this reads that. readarray -t WORKFLOWS < <(python3 -c ' import json, sys presets = json.load(open("CMakePresets.json"))["workflowPresets"] print("\n".join(p["name"] for p in presets))') if ((${#WORKFLOWS[@]} == 0)); then echo "no workflow presets in CMakePresets.json - run tools/make_presets.py" >&2 exit 1 fi CHIPS=() REFLECT_SPOT=() for workflow in "${WORKFLOWS[@]}"; do case $workflow in *-generated) CHIPS+=("${workflow%-generated}") ;; *-reflect) REFLECT_SPOT+=("${workflow%-reflect}") ;; esac done # Every preset runs even after one goes red, and the gate fails at the end # naming all of them: stopping at the first failure turns a red - a stale size # canary above all - into an alibi for every chip behind it, and a loader can # ship on a chip this gate has not compiled since. red=() run_preset() { echo "==== $1 ====" cmake --workflow --preset "$1" "${@:2}" || red+=("$1") } for chip in "${CHIPS[@]}"; do run_preset "$chip-generated" "$@" done if ((full)); then for chip in "${REFLECT_SPOT[@]}"; do run_preset "$chip-reflect" "$@" done fi if ((${#red[@]})); then printf '==== red presets ====\n' >&2 printf ' %s\n' "${red[@]}" >&2 exit 1 fi echo "check: every chip green"