1
0
mirror of https://github.com/FunkyFr3sh/cnc-ddraw.git synced 2025-03-14 22:03:27 +01:00

add git commit hash to file version and log

This commit is contained in:
FunkyFr3sh 2024-08-31 13:22:29 +02:00
parent 7a8db6c189
commit b5eea287d5
5 changed files with 58 additions and 3 deletions

2
.gitignore vendored
View File

@ -1,4 +1,6 @@
inc/version_tmp.h
# C++ Builder
__astcache/

View File

@ -230,6 +230,12 @@ if NOT "$(LocalDebuggerWorkingDirectory)" == "$(ProjectDir)" if exist "$(LocalDe
)
</Command>
</PostBuildEvent>
<PreBuildEvent>
<Command>echo | set /p dummyName=#define GIT_COMMIT &gt; inc/version_tmp.h
"$(DevEnvDir)\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\Git\mingw64\bin\git" rev-parse --short HEAD &gt;&gt; inc/version_tmp.h || git rev-parse --verify HEAD &gt;&gt; inc/version_tmp.h || echo UNKNOWN &gt;&gt; inc/version_tmp.h
SET ERRORLEVEL = 0</Command>
</PreBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
@ -257,6 +263,12 @@ if NOT "$(LocalDebuggerWorkingDirectory)" == "$(ProjectDir)" if exist "$(LocalDe
)
</Command>
</PostBuildEvent>
<PreBuildEvent>
<Command>echo | set /p dummyName=#define GIT_COMMIT &gt; inc/version_tmp.h
"$(DevEnvDir)\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\Git\mingw64\bin\git" rev-parse --short HEAD &gt;&gt; inc/version_tmp.h || git rev-parse --verify HEAD &gt;&gt; inc/version_tmp.h || echo UNKNOWN &gt;&gt; inc/version_tmp.h
SET ERRORLEVEL = 0</Command>
</PreBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseXP|Win32'">
<ClCompile>
@ -284,6 +296,12 @@ if NOT "$(LocalDebuggerWorkingDirectory)" == "$(ProjectDir)" if exist "$(LocalDe
)
</Command>
</PostBuildEvent>
<PreBuildEvent>
<Command>echo | set /p dummyName=#define GIT_COMMIT &gt; inc/version_tmp.h
"$(DevEnvDir)\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\Git\mingw64\bin\git" rev-parse --short HEAD &gt;&gt; inc/version_tmp.h || git rev-parse --verify HEAD &gt;&gt; inc/version_tmp.h || echo UNKNOWN &gt;&gt; inc/version_tmp.h
SET ERRORLEVEL = 0</Command>
</PreBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='DebugLogXP|Win32'">
<ClCompile>
@ -311,6 +329,12 @@ if NOT "$(LocalDebuggerWorkingDirectory)" == "$(ProjectDir)" if exist "$(LocalDe
)
</Command>
</PostBuildEvent>
<PreBuildEvent>
<Command>echo | set /p dummyName=#define GIT_COMMIT &gt; inc/version_tmp.h
"$(DevEnvDir)\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\Git\mingw64\bin\git" rev-parse --short HEAD &gt;&gt; inc/version_tmp.h || git rev-parse --verify HEAD &gt;&gt; inc/version_tmp.h || echo UNKNOWN &gt;&gt; inc/version_tmp.h
SET ERRORLEVEL = 0</Command>
</PreBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='DebugLogMiniXP|Win32'">
<ClCompile>
@ -338,6 +362,12 @@ if NOT "$(LocalDebuggerWorkingDirectory)" == "$(ProjectDir)" if exist "$(LocalDe
)
</Command>
</PostBuildEvent>
<PreBuildEvent>
<Command>echo | set /p dummyName=#define GIT_COMMIT &gt; inc/version_tmp.h
"$(DevEnvDir)\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\Git\mingw64\bin\git" rev-parse --short HEAD &gt;&gt; inc/version_tmp.h || git rev-parse --verify HEAD &gt;&gt; inc/version_tmp.h || echo UNKNOWN &gt;&gt; inc/version_tmp.h
SET ERRORLEVEL = 0</Command>
</PreBuildEvent>
</ItemDefinitionGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets" />

View File

@ -3,6 +3,7 @@
#define str(s) #s
#define ver_str(a,b,c,d) str(a) "." str(b) "." str(c) "." str(d)
#define git_str(a) str(a)
#define VERSION_MAJOR 6
#define VERSION_MINOR 8

12
res.rc
View File

@ -1,5 +1,13 @@
#include "inc/version.h"
#ifndef __GNUC__
#include "inc/version_tmp.h"
#endif
#ifndef GIT_COMMIT
#define GIT_COMMIT UNKNOWN
#endif
1 VERSIONINFO
FILEVERSION VERSION
PRODUCTVERSION VERSION
@ -10,13 +18,13 @@ PRODUCTVERSION VERSION
{
VALUE "CompanyName", "github.com/FunkyFr3sh"
VALUE "FileDescription", "DirectDraw replacement"
VALUE "FileVersion", VERSION_STRING
VALUE "FileVersion", VERSION_STRING " (git~" git_str(GIT_COMMIT) ")"
VALUE "InternalName", "ddraw"
VALUE "LegalCopyright", "Copyright (c) 2010-2024"
VALUE "LegalTrademarks", ""
VALUE "OriginalFileName", "ddraw.dll"
VALUE "ProductName", "cnc-ddraw"
VALUE "ProductVersion", VERSION_STRING
VALUE "ProductVersion", VERSION_STRING " (git~" git_str(GIT_COMMIT) ")"
VALUE "Comments", "https://github.com/FunkyFr3sh/cnc-ddraw"
}
}

View File

@ -10,6 +10,14 @@
#include "version.h"
#include "versionhelpers.h"
#ifndef __GNUC__
#include "version_tmp.h"
#endif
#ifndef GIT_COMMIT
#define GIT_COMMIT UNKNOWN
#endif
double g_dbg_frame_time = 0;
DWORD g_dbg_frame_count = 0;
@ -151,7 +159,13 @@ void dbg_init()
setvbuf(g_dbg_log_file, NULL, _IOLBF, 1024);
}
TRACE("cnc-ddraw version = %d.%d.%d.%d\n", VERSION_MAJOR, VERSION_MINOR, VERSION_BUILD, VERSION_REVISION);
TRACE(
"cnc-ddraw version = %d.%d.%d.%d (git~%s)\n",
VERSION_MAJOR,
VERSION_MINOR,
VERSION_BUILD,
VERSION_REVISION,
git_str(GIT_COMMIT));
HKEY hkey;
LONG status =