From 13d2e9ac600597c1917dafd94e06ffecd4de9232 Mon Sep 17 00:00:00 2001 From: Benualdo Date: Tue, 29 Oct 2024 18:28:22 +0100 Subject: [PATCH] Add commit revision to window title --- generate_version_header.bat | 14 ++++++++++++++ src/application/WinMain.cpp | 37 ++++++++----------------------------- src/version.h | 2 ++ 3 files changed, 24 insertions(+), 29 deletions(-) create mode 100644 generate_version_header.bat create mode 100644 src/version.h diff --git a/generate_version_header.bat b/generate_version_header.bat new file mode 100644 index 000000000..58c6e4bcb --- /dev/null +++ b/generate_version_header.bat @@ -0,0 +1,14 @@ +@echo off + +rem Change to the directory where your header should be generated +cd /d "src" + +rem Get the current short Git revision +for /f "delims=" %%i in ('git rev-parse --short HEAD') do set GIT_REVISION=%%i + +rem Create the version header file +echo // This file is generated automatically > version.h +echo #define GIT_REVISION "%GIT_REVISION%" >> version.h + +rem Optional: print a message +echo Version header generated with GIT revision: %GIT_REVISION% \ No newline at end of file diff --git a/src/application/WinMain.cpp b/src/application/WinMain.cpp index 36c797d13..b9e382dca 100644 --- a/src/application/WinMain.cpp +++ b/src/application/WinMain.cpp @@ -14,12 +14,7 @@ #include "resource.h" #include "application.h" - -#define TEST_META_ENUM 0 - -#if TEST_META_ENUM -#include "core/Types/Enum/Enum_meta.h" -#endif +#include "version.h" HINSTANCE hInst; HWND g_hWnd; @@ -27,28 +22,6 @@ HWND g_hWnd; using namespace vg; engine::IEngine * g_engine = nullptr; -#if TEST_META_ENUM - -vg_enum(Color, vg::core::u32, - Red = 0x000000FF, - Green = 0x0000FF00, - Blue = 0x00FF0000 -); - -void TestMetaEnum() -{ - VG_DEBUGPRINT("%s\n", ((vg::core::string)Color_meta.string).c_str()); - - const auto & pairs = meta::enumPairs(); - for (auto i = 0; i < pairs.size(); ++i) - { - const auto & pair = pairs[i]; - VG_DEBUGPRINT("[#%u] %s = %u\n", i, pair.second.c_str(), pair.first); - } -} - -#endif - //-------------------------------------------------------------------------------------- LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { @@ -268,10 +241,16 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine Application * app = new Application(*g_engine); const auto version = app->GetVersion(); - core::string title = "VG Framework " + core::to_string(version.major) + "." + core::to_string(version.minor) + " " + core::Plugin::getPlatform() + "|" + core::Plugin::getConfiguration() + " - " + core::asString(engineParams.renderer.device.api); + core::string title = fmt::sprintf("VGFramework %s|%s - %s", core::Plugin::getPlatform(), core::Plugin::getConfiguration(), core::asString(engineParams.renderer.device.api)); if (engineParams.renderer.device.debugDevice) title += " (debug device)"; + title += fmt::sprintf(" - Version %u.%u", version.major, version.minor); + + #ifdef GIT_REVISION + title += fmt::sprintf(" commit %s", GIT_REVISION); + #endif + SetWindowTextA(g_hWnd, title.c_str()); // Start in play mode? diff --git a/src/version.h b/src/version.h new file mode 100644 index 000000000..7d53fc0b9 --- /dev/null +++ b/src/version.h @@ -0,0 +1,2 @@ +// This file is generated automatically +#define GIT_REVISION "70d9c2af"