scmversion: Include the current commit hash

This commit is contained in:
Connor McLaughlin
2020-08-06 20:11:22 +10:00
parent 64b745fd56
commit 8bc6433be1
4 changed files with 10 additions and 2 deletions

View File

@ -1,10 +1,11 @@
#!/bin/sh
VERSION_FILE="scmversion.cpp"
HASH=$(git rev-parse HEAD)
BRANCH=$(git rev-parse --abbrev-ref HEAD | tr -d '\r\n')
TAG=$(git describe --tags --dirty --exclude latest | tr -d '\r\n')
SIGNATURE_LINE="// ${BRANCH} ${TAG}"
SIGNATURE_LINE="// ${HASH} ${BRANCH} ${TAG}"
if [ -f $VERSION_FILE ]; then
EXISTING_LINE=$(head -n1 $VERSION_FILE | tr -d '\n')
@ -18,6 +19,7 @@ echo "Writing ${VERSION_FILE}..."
cat > $VERSION_FILE << EOF
${SIGNATURE_LINE}
const char* g_scm_hash_str = "${HASH}";
const char* g_scm_branch_str = "${BRANCH}";
const char* g_scm_tag_str = "${TAG}";