Skip to content

Commit

Permalink
xrCore: build information (branch, commit hash, CI, CI build ID, buil…
Browse files Browse the repository at this point in the history
…der)

You will see at least branch and commit hash, other info will be shown depending on it's availability
  • Loading branch information
Xottab-DUTY committed Aug 7, 2018
1 parent cc2474f commit e06400e
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 18 deletions.
2 changes: 2 additions & 0 deletions src/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
xrCore/.GitInfo.hpp

# exclude binaries and temporary files
ipch/
packages/
Expand Down
10 changes: 10 additions & 0 deletions src/xrCore/.GitInfo.cmd
Original file line number Diff line number Diff line change
@@ -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
54 changes: 42 additions & 12 deletions src/xrCore/xrCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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*/,
Expand Down Expand Up @@ -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();
Expand Down
30 changes: 24 additions & 6 deletions src/xrCore/xrCore.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<AdditionalIncludeDirectories>$(xrExternals);$(xrExternals)lzo\include;$(xrExternals)pugixml\src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>_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)</PreprocessorDefinitions>
<PreprocessorDefinitions>_USRDLL;XRCORE_EXPORTS;CRYPTO_BUILD;CI=$(CI);APPVEYOR=$(APPVEYOR);APPVEYOR_BUILD_VERSION=$(APPVEYOR_BUILD_VERSION);APPVEYOR_ACCOUNT_NAME=$(APPVEYOR_ACCOUNT_NAME);%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<AdditionalDependencies>PowrProf.lib;DbgHelp.lib;%(AdditionalDependencies)</AdditionalDependencies>
Expand All @@ -114,11 +114,14 @@
<PostBuildEvent>
<Message>Copying the required libraries ...</Message>
</PostBuildEvent>
<PreBuildEvent>
<Command>call .GitInfo.cmd</Command>
</PreBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<AdditionalIncludeDirectories>$(xrExternals);$(xrExternals)lzo\include;$(xrExternals)pugixml\src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>_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)</PreprocessorDefinitions>
<PreprocessorDefinitions>_USRDLL;XRCORE_EXPORTS;CRYPTO_BUILD;CI=$(CI);APPVEYOR=$(APPVEYOR);APPVEYOR_BUILD_VERSION=$(APPVEYOR_BUILD_VERSION);APPVEYOR_ACCOUNT_NAME=$(APPVEYOR_ACCOUNT_NAME);%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<AdditionalDependencies>PowrProf.lib;DbgHelp.lib;%(AdditionalDependencies)</AdditionalDependencies>
Expand All @@ -127,11 +130,14 @@
<Command>for /r "$(xrSdkDir)binaries/$(PlatformShortName)" %%f in (*.dll *.pdb) do @xcopy /Q /D "%%f" "$(OutDir)"</Command>
<Message>Copying the required libraries ...</Message>
</PostBuildEvent>
<PreBuildEvent>
<Command>call .GitInfo.cmd</Command>
</PreBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<AdditionalIncludeDirectories>$(xrExternals);$(xrExternals)lzo\include;$(xrExternals)pugixml\src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>_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)</PreprocessorDefinitions>
<PreprocessorDefinitions>_USRDLL;XRCORE_EXPORTS;CRYPTO_BUILD;CI=$(CI);APPVEYOR=$(APPVEYOR);APPVEYOR_BUILD_VERSION=$(APPVEYOR_BUILD_VERSION);APPVEYOR_ACCOUNT_NAME=$(APPVEYOR_ACCOUNT_NAME);%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<AdditionalDependencies>PowrProf.lib;DbgHelp.lib;%(AdditionalDependencies)</AdditionalDependencies>
Expand All @@ -142,11 +148,14 @@
<PostBuildEvent>
<Message>Copying the required libraries ...</Message>
</PostBuildEvent>
<PreBuildEvent>
<Command>call .GitInfo.cmd</Command>
</PreBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<AdditionalIncludeDirectories>$(xrExternals);$(xrExternals)lzo\include;$(xrExternals)pugixml\src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>_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)</PreprocessorDefinitions>
<PreprocessorDefinitions>_USRDLL;XRCORE_EXPORTS;CRYPTO_BUILD;CI=$(CI);APPVEYOR=$(APPVEYOR);APPVEYOR_BUILD_VERSION=$(APPVEYOR_BUILD_VERSION);APPVEYOR_ACCOUNT_NAME=$(APPVEYOR_ACCOUNT_NAME);%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<AdditionalDependencies>PowrProf.lib;DbgHelp.lib;%(AdditionalDependencies)</AdditionalDependencies>
Expand All @@ -155,11 +164,14 @@
<Command>for /r "$(xrSdkDir)binaries/$(PlatformShortName)" %%f in (*.dll *.pdb) do @xcopy /Q /D "%%f" "$(OutDir)"</Command>
<Message>Copying the required libraries ...</Message>
</PostBuildEvent>
<PreBuildEvent>
<Command>call .GitInfo.cmd</Command>
</PreBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Mixed|Win32'">
<ClCompile>
<AdditionalIncludeDirectories>$(xrExternals);$(xrExternals)lzo\include;$(xrExternals)pugixml\src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>_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)</PreprocessorDefinitions>
<PreprocessorDefinitions>_USRDLL;XRCORE_EXPORTS;CRYPTO_BUILD;CI=$(CI);APPVEYOR=$(APPVEYOR);APPVEYOR_BUILD_VERSION=$(APPVEYOR_BUILD_VERSION);APPVEYOR_ACCOUNT_NAME=$(APPVEYOR_ACCOUNT_NAME);%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<AdditionalDependencies>PowrProf.lib;DbgHelp.lib;%(AdditionalDependencies)</AdditionalDependencies>
Expand All @@ -170,11 +182,14 @@
<PostBuildEvent>
<Message>Copying the required libraries ...</Message>
</PostBuildEvent>
<PreBuildEvent>
<Command>call .GitInfo.cmd</Command>
</PreBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Mixed|x64'">
<ClCompile>
<AdditionalIncludeDirectories>$(xrExternals);$(xrExternals)lzo\include;$(xrExternals)pugixml\src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>_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)</PreprocessorDefinitions>
<PreprocessorDefinitions>_USRDLL;XRCORE_EXPORTS;CRYPTO_BUILD;CI=$(CI);APPVEYOR=$(APPVEYOR);APPVEYOR_BUILD_VERSION=$(APPVEYOR_BUILD_VERSION);APPVEYOR_ACCOUNT_NAME=$(APPVEYOR_ACCOUNT_NAME);%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<AdditionalDependencies>PowrProf.lib;DbgHelp.lib;%(AdditionalDependencies)</AdditionalDependencies>
Expand All @@ -183,6 +198,9 @@
<Command>for /r "$(xrSdkDir)binaries/$(PlatformShortName)" %%f in (*.dll *.pdb) do @xcopy /Q /D "%%f" "$(OutDir)"</Command>
<Message>Copying the required libraries ...</Message>
</PostBuildEvent>
<PreBuildEvent>
<Command>call .GitInfo.cmd</Command>
</PreBuildEvent>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="Animation\Bone.cpp" />
Expand Down

0 comments on commit e06400e

Please sign in to comment.