script: Implemented a helper script to help build include/version.h

This commit is contained in:
dragonmux 2022-06-11 18:59:16 -04:00 committed by Piotr Esden-Tempski
parent 9a0e4b4f23
commit e388fbbb2c
1 changed files with 18 additions and 0 deletions

18
scripts/gen-version.sh Executable file
View File

@ -0,0 +1,18 @@
#!/bin/sh
if ! command -v git &>/dev/null; then
echo "Git not found, assuming up to date include/version.h"
exit 0
fi
if ! git rev-parse HEAD &>/dev/null; then
echo "No git repository found, not updating include/version.h"
exit 0
fi
version=`git describe --always --dirty --tags`
header="#define FIRMWARE_VERSION \"$version\""
if [ "`cat include/version.h 2>/dev/null`" != "$header" ]; then
echo $header > include/version.h
fi