All checks were successful
Build and Deploy Documentation / build-and-deploy (push) Successful in 18s
Generate git-revision.h into CMAKE_BINARY_DIR/src/ (which is in the include path) instead of the source tree. Remove the header from add_executable() source lists, and add missing add_dependencies on git_revision for all Qt5/Qt6 targets. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
33 lines
969 B
Bash
Executable File
33 lines
969 B
Bash
Executable File
#!/bin/bash
|
|
|
|
# Usage: git_revision.sh <output_dir>
|
|
# Generates git-revision.h in the specified output directory.
|
|
|
|
OUTPUT_DIR="${1:-.}"
|
|
|
|
echo "-- Generating header for git hash"
|
|
GIT_HEADER="${OUTPUT_DIR}/git-revision.h"
|
|
[ -d "${OUTPUT_DIR}" ] || mkdir -p "${OUTPUT_DIR}"
|
|
|
|
GIT_BRANCH=`git rev-parse --abbrev-ref HEAD`
|
|
|
|
GIT_VERSION=`git log -n 1 --pretty=format:"%ad - %h"`
|
|
if [ -f "$GIT_HEADER" ] && [ "$(grep -cs "$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 "#ifndef GIT_VERSION_H" > $GIT_HEADER
|
|
echo "#define GIT_VERSION_H" >> $GIT_HEADER
|
|
echo "" >> $GIT_HEADER
|
|
echo "#define GIT_BRANCH \"$GIT_BRANCH\"" >> $GIT_HEADER
|
|
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
|