From 8bc6433be176d27f1b4976846fb0be69cd8e57bd Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Thu, 6 Aug 2020 20:11:22 +1000 Subject: [PATCH] scmversion: Include the current commit hash --- src/scmversion/gen_scmversion.bat | 4 +++- src/scmversion/gen_scmversion.sh | 4 +++- src/scmversion/scmversion.h | 1 + src/scmversion/tag.h | 3 +++ 4 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 src/scmversion/tag.h diff --git a/src/scmversion/gen_scmversion.bat b/src/scmversion/gen_scmversion.bat index 6150eaa7f..79a19729a 100644 --- a/src/scmversion/gen_scmversion.bat +++ b/src/scmversion/gen_scmversion.bat @@ -1,10 +1,11 @@ @echo off SET VERSIONFILE="scmversion.cpp" +FOR /F "tokens=* USEBACKQ" %%g IN (`git rev-parse HEAD`) do (SET "HASH=%%g") FOR /F "tokens=* USEBACKQ" %%g IN (`git rev-parse --abbrev-ref HEAD`) do (SET "BRANCH=%%g") FOR /F "tokens=* USEBACKQ" %%g IN (`git describe --tags --dirty --exclude latest`) do (SET "TAG=%%g") -SET SIGNATURELINE=// %BRANCH% %TAG% +SET SIGNATURELINE=// %HASH% %BRANCH% %TAG% SET /P EXISTINGLINE=< %VERSIONFILE% IF "%EXISTINGLINE%"=="%SIGNATURELINE%" ( @@ -15,6 +16,7 @@ IF "%EXISTINGLINE%"=="%SIGNATURELINE%" ( ECHO Updating %VERSIONFILE%... (ECHO %SIGNATURELINE% +ECHO const char* g_scm_hash_str = "%HASH%"; ECHO const char* g_scm_branch_str = "%BRANCH%"; ECHO const char* g_scm_tag_str = "%TAG%"; )>%VERSIONFILE% diff --git a/src/scmversion/gen_scmversion.sh b/src/scmversion/gen_scmversion.sh index 3c7cddcb2..a6d92b8ac 100755 --- a/src/scmversion/gen_scmversion.sh +++ b/src/scmversion/gen_scmversion.sh @@ -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}"; diff --git a/src/scmversion/scmversion.h b/src/scmversion/scmversion.h index b615da4b3..681da7971 100644 --- a/src/scmversion/scmversion.h +++ b/src/scmversion/scmversion.h @@ -1,5 +1,6 @@ #pragma once +extern const char* g_scm_hash_str; extern const char* g_scm_branch_str; extern const char* g_scm_tag_str; diff --git a/src/scmversion/tag.h b/src/scmversion/tag.h new file mode 100644 index 000000000..625600f10 --- /dev/null +++ b/src/scmversion/tag.h @@ -0,0 +1,3 @@ +#pragma once +#define SCM_RELEASE_TAG "latest" +#define SCM_RELEASE_ASSET "duckstation-windows-x64-release.zip"