From cfaae52f53100d627d78fb59db7f12d8a28768a8 Mon Sep 17 00:00:00 2001 From: Luke Usher Date: Thu, 27 Oct 2016 09:19:50 +0100 Subject: [PATCH] implement automatic versioning based on git status If the current commit has a tag, the version string will be "Cxbx-Reloaded TAG_NAME (DATE) If the current commit does not have a tag, the version string will be "Cxbx-Reloaded COMMIT_SHORT_HASH (DATE)" --- .gitignore | 1 + Build/win32/Version.bat | 6 +++++ build/win32/CxbxKrnl.vcxproj | 44 ++++++++++++++++++++++++++++++++++++ src/Cxbx.h | 6 +++-- 4 files changed, 55 insertions(+), 2 deletions(-) create mode 100644 Build/win32/Version.bat diff --git a/.gitignore b/.gitignore index 2f5718f7e..1fd4fb129 100644 --- a/.gitignore +++ b/.gitignore @@ -76,3 +76,4 @@ packages/ #Test files *.testsettings +src/Version.h diff --git a/Build/win32/Version.bat b/Build/win32/Version.bat new file mode 100644 index 000000000..ba7c5c57b --- /dev/null +++ b/Build/win32/Version.bat @@ -0,0 +1,6 @@ +@ECHO OFF +SET GIT_VERSION= +git describe --always > GIT_VERSION +for /f "delims=" %%x in (GIT_VERSION) do set GIT_VERSION=%%x +ECHO #define _GIT_VERSION "%GIT_VERSION%" > "%~1" +del GIT_VERSION \ No newline at end of file diff --git a/build/win32/CxbxKrnl.vcxproj b/build/win32/CxbxKrnl.vcxproj index cb8f9bf1c..ef61f284f 100644 --- a/build/win32/CxbxKrnl.vcxproj +++ b/build/win32/CxbxKrnl.vcxproj @@ -55,6 +55,18 @@ ..\..\import\DirectX8\include;$(IncludePath) ..\..\import\DirectX8\lib;$(LibraryPath) + + + + + + + + + + + + NDEBUG;%(PreprocessorDefinitions) @@ -100,6 +112,22 @@ + + + + + + + + + + + + $(SolutionDir)Version.bat $(SolutionDir)..\..\src\Version.h + + + Build Version.ini + @@ -149,6 +177,22 @@ + + + + + + + + + + + + $(SolutionDir)Version.bat $(SolutionDir)..\..\src\Version.h + + + Build Version.ini + diff --git a/src/Cxbx.h b/src/Cxbx.h index a9fba48c4..a2e62a20f 100644 --- a/src/Cxbx.h +++ b/src/Cxbx.h @@ -82,11 +82,13 @@ typedef signed long sint32; /*! define this to dump textures that are registered */ //#define _DEBUG_DUMP_TEXTURE_REGISTER "D:\\cxbx\\_textures\\" +#include "Version.h" + /*! version string dependent on trace flag */ #ifndef _DEBUG_TRACE -#define _CXBX_VERSION "0.0.1-POC" +#define _CXBX_VERSION _GIT_VERSION " ("__DATE__ ")" #else -#define _CXBX_VERSION "0.0.1-POC-Trace" +#define _CXBX_VERSION _GIT_VERSION "-Trace ("__DATE__ ")" #endif /*! debug mode choices */