From 9c0cbb107be87ff02529e094505032b7fca6b3d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mario=20H=C3=BCttel?= Date: Sun, 1 Jan 2023 20:45:57 +0100 Subject: [PATCH] Add script to generate header file containing version and commit hash --- stm-firmware/create_version_header.sh | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100755 stm-firmware/create_version_header.sh diff --git a/stm-firmware/create_version_header.sh b/stm-firmware/create_version_header.sh new file mode 100755 index 0000000..0f87882 --- /dev/null +++ b/stm-firmware/create_version_header.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +if [[ -z $1 ]]; then + # Exit with error in case no output file is specified + exit -1 +fi + +firmware_version=`git describe --tags --always --dirty` +commit=`git rev-parse HEAD` + +echo "#ifndef _VERSION_GENERATED_H_" > $1 +echo "#define _VERSION_GENERATED_H_" >> $1 +echo "#define GIT_VERSION_STRING \"$firmware_version\"" >> $1 +echo "#define GIT_FULL_COMMIT \"$commit\"" >> $1 +echo "#endif /* _VERSION_GENERATED_H_ */" >> $1 \ No newline at end of file