simplify git-revision.h generation.

This commit is contained in:
2025-05-19 13:29:54 +02:00
parent 005b33c379
commit e525abe614
4 changed files with 22 additions and 73 deletions

View File

@@ -1,21 +1,19 @@
#!/bin/bash
echo "Generating header for git hash" $1 $2
GIT_HEADER="$1/$2"
if [ -z "$2" ]; then
GIT_HEADER="$1/git-revision.h"
fi
echo "-- Generating header for git hash"
GIT_HEADER="src/git-revision.h"
GIT_BRANCH=`git rev-parse --abbrev-ref HEAD`
GIT_VERSION=`git log -n 1 --pretty=format:"%ad - %h"`
if grep --quiet "$GIT_VERSION" $GIT_HEADER; then
echo "No need to generate new $GIT_HEADER - git hash is unchanged"
exit 0;
if [ "$(grep -ics "$GIT_VERSION" $GIT_HEADER)" = 1 ]
then
echo "-- No need to generate new $GIT_HEADER - git hash is unchanged"
exit 0;
fi
echo "git branch is : " $GIT_BRANCH
echo "git version is : " $GIT_VERSION
echo "-- git branch is : " $GIT_BRANCH
echo "-- git version is : " $GIT_VERSION
echo "#ifndef GIT_VERSION_H" > $GIT_HEADER
echo "#define GIT_VERSION_H" >> $GIT_HEADER
@@ -25,4 +23,4 @@ echo "#define GIT_CURRENT_SHA1 \"$GIT_VERSION\"" >> $GIT_HEADER
echo "" >> $GIT_HEADER
echo "#endif //GIT_VERSION_H" >> $GIT_HEADER
echo "file is generated into" $GIT_HEADER
echo "-- file is generated into" $GIT_HEADER