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 @@
@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%

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}";

View file

@ -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;

3
src/scmversion/tag.h Normal file
View file

@ -0,0 +1,3 @@
#pragma once
#define SCM_RELEASE_TAG "latest"
#define SCM_RELEASE_ASSET "duckstation-windows-x64-release.zip"