From e388fbbb2c6beee5f02cb55a1c0f4a9183173d92 Mon Sep 17 00:00:00 2001 From: dragonmux Date: Sat, 11 Jun 2022 18:59:16 -0400 Subject: [PATCH] script: Implemented a helper script to help build include/version.h --- scripts/gen-version.sh | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100755 scripts/gen-version.sh diff --git a/scripts/gen-version.sh b/scripts/gen-version.sh new file mode 100755 index 0000000..d0a09e0 --- /dev/null +++ b/scripts/gen-version.sh @@ -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