diff --git a/src/.gitignore b/src/.gitignore
index c161bcbb958..845aba9db94 100644
--- a/src/.gitignore
+++ b/src/.gitignore
@@ -1,3 +1,5 @@
+xrCore/.GitInfo.hpp
+
# exclude binaries and temporary files
ipch/
packages/
diff --git a/src/xrCore/.GitInfo.cmd b/src/xrCore/.GitInfo.cmd
new file mode 100644
index 00000000000..6d8348deb29
--- /dev/null
+++ b/src/xrCore/.GitInfo.cmd
@@ -0,0 +1,10 @@
+where git >nul 2>nul
+if %errorLevel% neq 0 (
+ goto :EOF
+)
+
+echo | set /p dummyName=#define GIT_INFO_CURRENT_COMMIT > .GitInfo.hpp
+git rev-parse --verify HEAD >> .GitInfo.hpp
+
+echo | set /p dummyName=#define GIT_INFO_CURRENT_BRANCH >> .GitInfo.hpp
+git rev-parse --abbrev-ref HEAD >> .GitInfo.hpp
diff --git a/src/xrCore/xrCore.cpp b/src/xrCore/xrCore.cpp
index 87dac172ae6..30c0b58380f 100644
--- a/src/xrCore/xrCore.cpp
+++ b/src/xrCore/xrCore.cpp
@@ -13,6 +13,18 @@
#include "Math/MathUtil.hpp"
#include "xrCore/_std_extensions.h"
+#if __has_include(".GitInfo.hpp")
+#include ".GitInfo.hpp"
+#endif
+
+#ifndef GIT_INFO_CURRENT_BRANCH
+#define GIT_INFO_CURRENT_BRANCH unknown
+#endif
+
+#ifndef GIT_INFO_CURRENT_COMMIT
+#define GIT_INFO_CURRENT_COMMIT unknown
+#endif
+
#include "Compression/compression_ppmd_stream.h"
extern compression::ppmd::stream* trained_model;
@@ -23,33 +35,51 @@ static u32 init_counter = 0;
#define DO_EXPAND(VAL) VAL##1
#define EXPAND(VAL) DO_EXPAND(VAL)
+#ifdef CI
#if EXPAND(CI) == 1
#undef CI
#endif
+#endif
#define HELPER(s) #s
#define TO_STRING(s) HELPER(s)
-void PrintCI()
+void PrintBuildInfo()
{
-#if defined(CI)
- pcstr name = nullptr;
+ pcstr name = "Custom";
pcstr buildId = nullptr;
pcstr builder = nullptr;
- pcstr commit = nullptr;
+ pcstr commit = TO_STRING(GIT_INFO_CURRENT_COMMIT);
+ pcstr branch = TO_STRING(GIT_INFO_CURRENT_BRANCH);
+
+#if defined(CI)
#if defined(APPVEYOR)
name = "AppVeyor";
buildId = TO_STRING(APPVEYOR_BUILD_VERSION);
builder = TO_STRING(APPVEYOR_ACCOUNT_NAME);
- commit = TO_STRING(APPVEYOR_REPO_COMMIT);
+#elif defined(TRAVIS)
+ name = "Travis";
+ buildId = TO_STRING(TRAVIS_BUILD_NUMBER);
#else
#pragma TODO("PrintCI for other CIs")
- return;
+ name = "CI";
+ builder = "Unknown CI";
#endif
- Msg("%s build %s from commit %s (built by %s)", name, buildId, commit, builder);
-#else
- Log("This is a custom build");
#endif
+
+ string512 buf;
+ strconcat(sizeof(buf), buf, name, " build "); // "%s build "
+
+ if (buildId)
+ strconcat(sizeof(buf), buf, buf, buildId, " "); // "id "
+
+ strconcat(sizeof(buf), buf, buf, "from commit[", commit, "]"); // "from commit[hash]"
+ strconcat(sizeof(buf), buf, buf, " branch[", branch, "]"); // " branch[name]"
+
+ if (builder)
+ strconcat(sizeof(buf), buf, buf, " (built by ", builder, ")"); // " (built by builder)"
+
+ Log(buf); // "%s build %s from commit[%s] branch[%s] (built by %s)"
}
void SDLLogOutput(void* /*userdata*/,
@@ -208,9 +238,9 @@ void xrCore::Initialize(pcstr _ApplicationName, LogCallback cb, bool init_fs, pc
Memory._initialize();
SDL_LogSetOutputFunction(SDLLogOutput, nullptr);
- Msg("%s %s build %d, %s\n", "OpenXRay", GetBuildConfiguration(), buildId, buildDate);
- PrintCI();
- Msg("command line %s\n", Params);
+ Msg("%s %s build %d, %s", "OpenXRay", GetBuildConfiguration(), buildId, buildDate);
+ PrintBuildInfo();
+ Msg("\ncommand line %s\n", Params);
_initialize_cpu();
R_ASSERT(CPU::ID.hasFeature(CpuFeature::Sse));
ttapi.initialize();
diff --git a/src/xrCore/xrCore.vcxproj b/src/xrCore/xrCore.vcxproj
index 3cd8f81c2e8..ba4dae63207 100644
--- a/src/xrCore/xrCore.vcxproj
+++ b/src/xrCore/xrCore.vcxproj
@@ -103,7 +103,7 @@
$(xrExternals);$(xrExternals)lzo\include;$(xrExternals)pugixml\src;%(AdditionalIncludeDirectories)
- _USRDLL;XRCORE_EXPORTS;CRYPTO_BUILD;CI=$(CI);APPVEYOR=$(APPVEYOR);APPVEYOR_BUILD_VERSION=$(APPVEYOR_BUILD_VERSION);APPVEYOR_ACCOUNT_NAME=$(APPVEYOR_ACCOUNT_NAME);APPVEYOR_REPO_COMMIT=$(APPVEYOR_REPO_COMMIT);%(PreprocessorDefinitions)
+ _USRDLL;XRCORE_EXPORTS;CRYPTO_BUILD;CI=$(CI);APPVEYOR=$(APPVEYOR);APPVEYOR_BUILD_VERSION=$(APPVEYOR_BUILD_VERSION);APPVEYOR_ACCOUNT_NAME=$(APPVEYOR_ACCOUNT_NAME);%(PreprocessorDefinitions)
PowrProf.lib;DbgHelp.lib;%(AdditionalDependencies)
@@ -114,11 +114,14 @@
Copying the required libraries ...
+
+ call .GitInfo.cmd
+
$(xrExternals);$(xrExternals)lzo\include;$(xrExternals)pugixml\src;%(AdditionalIncludeDirectories)
- _USRDLL;XRCORE_EXPORTS;CRYPTO_BUILD;CI=$(CI);APPVEYOR=$(APPVEYOR);APPVEYOR_BUILD_VERSION=$(APPVEYOR_BUILD_VERSION);APPVEYOR_ACCOUNT_NAME=$(APPVEYOR_ACCOUNT_NAME);APPVEYOR_REPO_COMMIT=$(APPVEYOR_REPO_COMMIT);%(PreprocessorDefinitions)
+ _USRDLL;XRCORE_EXPORTS;CRYPTO_BUILD;CI=$(CI);APPVEYOR=$(APPVEYOR);APPVEYOR_BUILD_VERSION=$(APPVEYOR_BUILD_VERSION);APPVEYOR_ACCOUNT_NAME=$(APPVEYOR_ACCOUNT_NAME);%(PreprocessorDefinitions)
PowrProf.lib;DbgHelp.lib;%(AdditionalDependencies)
@@ -127,11 +130,14 @@
for /r "$(xrSdkDir)binaries/$(PlatformShortName)" %%f in (*.dll *.pdb) do @xcopy /Q /D "%%f" "$(OutDir)"
Copying the required libraries ...
+
+ call .GitInfo.cmd
+
$(xrExternals);$(xrExternals)lzo\include;$(xrExternals)pugixml\src;%(AdditionalIncludeDirectories)
- _USRDLL;XRCORE_EXPORTS;CRYPTO_BUILD;CI=$(CI);APPVEYOR=$(APPVEYOR);APPVEYOR_BUILD_VERSION=$(APPVEYOR_BUILD_VERSION);APPVEYOR_ACCOUNT_NAME=$(APPVEYOR_ACCOUNT_NAME);APPVEYOR_REPO_COMMIT=$(APPVEYOR_REPO_COMMIT);%(PreprocessorDefinitions)
+ _USRDLL;XRCORE_EXPORTS;CRYPTO_BUILD;CI=$(CI);APPVEYOR=$(APPVEYOR);APPVEYOR_BUILD_VERSION=$(APPVEYOR_BUILD_VERSION);APPVEYOR_ACCOUNT_NAME=$(APPVEYOR_ACCOUNT_NAME);%(PreprocessorDefinitions)
PowrProf.lib;DbgHelp.lib;%(AdditionalDependencies)
@@ -142,11 +148,14 @@
Copying the required libraries ...
+
+ call .GitInfo.cmd
+
$(xrExternals);$(xrExternals)lzo\include;$(xrExternals)pugixml\src;%(AdditionalIncludeDirectories)
- _USRDLL;XRCORE_EXPORTS;CRYPTO_BUILD;CI=$(CI);APPVEYOR=$(APPVEYOR);APPVEYOR_BUILD_VERSION=$(APPVEYOR_BUILD_VERSION);APPVEYOR_ACCOUNT_NAME=$(APPVEYOR_ACCOUNT_NAME);APPVEYOR_REPO_COMMIT=$(APPVEYOR_REPO_COMMIT);%(PreprocessorDefinitions)
+ _USRDLL;XRCORE_EXPORTS;CRYPTO_BUILD;CI=$(CI);APPVEYOR=$(APPVEYOR);APPVEYOR_BUILD_VERSION=$(APPVEYOR_BUILD_VERSION);APPVEYOR_ACCOUNT_NAME=$(APPVEYOR_ACCOUNT_NAME);%(PreprocessorDefinitions)
PowrProf.lib;DbgHelp.lib;%(AdditionalDependencies)
@@ -155,11 +164,14 @@
for /r "$(xrSdkDir)binaries/$(PlatformShortName)" %%f in (*.dll *.pdb) do @xcopy /Q /D "%%f" "$(OutDir)"
Copying the required libraries ...
+
+ call .GitInfo.cmd
+
$(xrExternals);$(xrExternals)lzo\include;$(xrExternals)pugixml\src;%(AdditionalIncludeDirectories)
- _USRDLL;XRCORE_EXPORTS;CRYPTO_BUILD;CI=$(CI);APPVEYOR=$(APPVEYOR);APPVEYOR_BUILD_VERSION=$(APPVEYOR_BUILD_VERSION);APPVEYOR_ACCOUNT_NAME=$(APPVEYOR_ACCOUNT_NAME);APPVEYOR_REPO_COMMIT=$(APPVEYOR_REPO_COMMIT);%(PreprocessorDefinitions)
+ _USRDLL;XRCORE_EXPORTS;CRYPTO_BUILD;CI=$(CI);APPVEYOR=$(APPVEYOR);APPVEYOR_BUILD_VERSION=$(APPVEYOR_BUILD_VERSION);APPVEYOR_ACCOUNT_NAME=$(APPVEYOR_ACCOUNT_NAME);%(PreprocessorDefinitions)
PowrProf.lib;DbgHelp.lib;%(AdditionalDependencies)
@@ -170,11 +182,14 @@
Copying the required libraries ...
+
+ call .GitInfo.cmd
+
$(xrExternals);$(xrExternals)lzo\include;$(xrExternals)pugixml\src;%(AdditionalIncludeDirectories)
- _USRDLL;XRCORE_EXPORTS;CRYPTO_BUILD;CI=$(CI);APPVEYOR=$(APPVEYOR);APPVEYOR_BUILD_VERSION=$(APPVEYOR_BUILD_VERSION);APPVEYOR_ACCOUNT_NAME=$(APPVEYOR_ACCOUNT_NAME);APPVEYOR_REPO_COMMIT=$(APPVEYOR_REPO_COMMIT);%(PreprocessorDefinitions)
+ _USRDLL;XRCORE_EXPORTS;CRYPTO_BUILD;CI=$(CI);APPVEYOR=$(APPVEYOR);APPVEYOR_BUILD_VERSION=$(APPVEYOR_BUILD_VERSION);APPVEYOR_ACCOUNT_NAME=$(APPVEYOR_ACCOUNT_NAME);%(PreprocessorDefinitions)
PowrProf.lib;DbgHelp.lib;%(AdditionalDependencies)
@@ -183,6 +198,9 @@
for /r "$(xrSdkDir)binaries/$(PlatformShortName)" %%f in (*.dll *.pdb) do @xcopy /Q /D "%%f" "$(OutDir)"
Copying the required libraries ...
+
+ call .GitInfo.cmd
+