#!/bin/bash # Re-apply the asic-rs patch queue to the cargo-vendored tree and refresh the # affected crates' .cargo-checksum.json. Run this after `cargo vendor vendor` # (which regenerates a pristine vendor/ and drops our edits). A normal build # does NOT need this -- the committed vendor/ tree already has the patches # applied and checksums refreshed; this is the re-vendoring recipe (ADR 0003). set -euo pipefail REPO=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd) cd "$REPO" PATCHES_DIR="thirdparty/asic-rs/patches" shopt -s nullglob patches=("$PATCHES_DIR"/*.patch) if [ ${#patches[@]} -eq 0 ]; then echo "no patches in $PATCHES_DIR" exit 0 fi for p in "${patches[@]}"; do echo "== applying $p ==" if git apply --check -p1 "$p" 2>/dev/null; then git apply -p1 "$p" elif git apply --check -p1 --reverse "$p" 2>/dev/null; then echo " (already applied -- skipping)" else echo "ERROR: $p does not apply cleanly; resolve manually." >&2 exit 1 fi done echo "== refreshing checksums for all vendored asic-rs crates ==" python3 thirdparty/asic-rs/refresh-checksums.py --all echo "done."