65816-llvm-mos/scripts/updateLlvmMos.sh
2026-09-27 21:22:25 -05:00

31 lines
1.1 KiB
Bash
Executable file

#!/usr/bin/env bash
# Move the pinned llvm-mos checkout to the latest upstream main, re-apply
# our backend (symlinks + patches), and record the new commit in
# llvmMosCommit.txt. Rebuild, run the tests, then commit the pin file.
#
# This is the ONLY script that is allowed to move the clone to an
# UNPINNED commit. installLlvmMos.sh only ever moves it to the pin.
set -euo pipefail
source "$(dirname "$0")/common.sh"
[ -d "$LLVM_SRC/.git" ] || die "llvm-mos checkout not found; run setup.sh first"
currentBranch="$(git -C "$LLVM_SRC" rev-parse --abbrev-ref HEAD)"
if [ "$currentBranch" != "main" ]; then
die "llvm-mos is on branch '$currentBranch', expected main. Refusing to reset."
fi
unapplyBackend
log "fetching and resetting to origin/main"
git -C "$LLVM_SRC" fetch --depth=1 origin main
git -C "$LLVM_SRC" reset --hard FETCH_HEAD
log "re-applying backend"
"$PROJECT_ROOT/scripts/applyBackend.sh"
newCommit="$(git -C "$LLVM_SRC" rev-parse HEAD)"
printf '%s\n' "$newCommit" > "$LLVM_MOS_COMMIT_FILE"
log "update complete: pinned llvm-mos to $newCommit"
log "rebuild (ninja -C $LLVM_BUILD), run the W65816 tests, then commit llvmMosCommit.txt"