#!/bin/sh # gen_version.sh -- write OpenPuck/git_version.h with the current git short hash + dirty flag, for the build # provenance shown in the WebUSB panel. Run this BEFORE `arduino-cli compile` (it's a no-op to re-run). The # generated header is git-ignored, so generating it never itself marks the tree dirty. set -e cd "$(dirname "$0")" HASH=$(git rev-parse --short=8 HEAD 2>/dev/null || echo unknown) # Dirty = any tracked change OR untracked file (porcelain is empty only on a clean tree). git_version.h is # git-ignored so it doesn't count. if [ -z "$(git status --porcelain 2>/dev/null)" ]; then DIRTY=0; else DIRTY=1; fi cat > OpenPuck/git_version.h <