From 5596f69c0e763097ae6e7c7e7e3dfa3d3f8dd237 Mon Sep 17 00:00:00 2001 From: Gregory Hainaut Date: Tue, 8 Nov 2016 22:44:39 +0100 Subject: [PATCH] pcsx2 gui: use git desribe as version name Shorter than date and give all the useful info Require windows test close #1043 --- cmake/Pcsx2Utils.cmake | 9 +++++++-- common/vsprops/preBuild.cmd | 6 ++++++ pcsx2/gui/MainFrame.cpp | 13 ++++++------- 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/cmake/Pcsx2Utils.cmake b/cmake/Pcsx2Utils.cmake index 9901329105..64d478f2d9 100644 --- a/cmake/Pcsx2Utils.cmake +++ b/cmake/Pcsx2Utils.cmake @@ -37,6 +37,7 @@ endfunction() function(write_svnrev_h) set(PCSX2_WC_TIME 0) + set(PCSX2_GIT_REV "") if (GIT_FOUND AND EXISTS ${PROJECT_SOURCE_DIR}/.git) EXECUTE_PROCESS(WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} COMMAND ${GIT_EXECUTABLE} show -s --format=%ci HEAD OUTPUT_VARIABLE PCSX2_WC_TIME @@ -44,11 +45,15 @@ function(write_svnrev_h) # Output: "YYYY-MM-DD HH:MM:SS +HHMM" (last part is time zone, offset from UTC) string(REGEX REPLACE "[%:\\-]" "" PCSX2_WC_TIME "${PCSX2_WC_TIME}") string(REGEX REPLACE "([0-9]+) ([0-9]+).*" "\\1\\2" PCSX2_WC_TIME "${PCSX2_WC_TIME}") + + EXECUTE_PROCESS(WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} COMMAND ${GIT_EXECUTABLE} describe + OUTPUT_VARIABLE PCSX2_GIT_REV + OUTPUT_STRIP_TRAILING_WHITESPACE) endif() if ("${PCSX2_WC_TIME}" STREQUAL "") set(PCSX2_WC_TIME 0) endif() - file(WRITE ${CMAKE_BINARY_DIR}/common/include/svnrev.h "#define SVN_REV ${PCSX2_WC_TIME}ll \n#define SVN_MODS 0") + file(WRITE ${CMAKE_BINARY_DIR}/common/include/svnrev.h "#define SVN_REV ${PCSX2_WC_TIME}ll \n#define SVN_MODS 0\n#define GIT_REV \"${PCSX2_GIT_REV}\"") endfunction() function(check_compiler_version version_warn version_err) @@ -57,7 +62,7 @@ function(check_compiler_version version_warn version_err) string(STRIP "${GCC_VERSION}" GCC_VERSION) if(GCC_VERSION VERSION_LESS ${version_err}) message(FATAL_ERROR "PCSX2 doesn't support your old GCC ${GCC_VERSION}! Please upgrade it! - + The minimum supported version is ${version_err} but ${version_warn} is warmly recommended") else() if(GCC_VERSION VERSION_LESS ${version_warn}) diff --git a/common/vsprops/preBuild.cmd b/common/vsprops/preBuild.cmd index d68dd68955..f4194a6e72 100644 --- a/common/vsprops/preBuild.cmd +++ b/common/vsprops/preBuild.cmd @@ -22,6 +22,10 @@ FOR /F "tokens=1-2" %%i IN ('"git show -s --format=%%%ci HEAD 2> NUL"') do ( set REV3=%%i%%j ) +FOR /F %%i IN ('"git describe 2> NUL"') do ( + set GIT_REV=%%i +) + set REV2=%REV3: =% set REV1=%REV2:-=% set REV=%REV1::=% @@ -37,9 +41,11 @@ if %ERRORLEVEL% NEQ 0 ( echo #define SVN_REV_UNKNOWN > "%CD%\svnrev.h" echo #define SVN_REV 0ll >> "%CD%\svnrev.h" echo #define SVN_MODS 0 >> "%CD%\svnrev.h" + echo #define GIT_REV "" >> "%CD%\svnrev.h" ) else ( echo #define SVN_REV %REV%ll > "%CD%\svnrev.h" echo #define SVN_MODS 0 /* Not implemented at the moment. */ >> "%CD%\svnrev.h" + echo #define GIT_REV "%GIT_REV%" >> "%CD%\svnrev.h" ) ENDLOCAL diff --git a/pcsx2/gui/MainFrame.cpp b/pcsx2/gui/MainFrame.cpp index c142df859b..6eb4ec9be1 100644 --- a/pcsx2/gui/MainFrame.cpp +++ b/pcsx2/gui/MainFrame.cpp @@ -360,13 +360,12 @@ MainEmuFrame::MainEmuFrame(wxWindow* parent, const wxString& title) else { // beta / development editions, which feature revision number and compile date. -#ifndef DISABLE_BUILD_DATE - wintitle.Printf( L"%s %d.%d.%d-%lld%s (git) %s", pxGetAppName().c_str(), PCSX2_VersionHi, PCSX2_VersionMid, PCSX2_VersionLo, - SVN_REV, SVN_MODS ? L"m" : wxEmptyString, fromUTF8(__DATE__).c_str() ); -#else - wintitle.Printf( L"%s %d.%d.%d-%lld%s (git)", pxGetAppName().c_str(), PCSX2_VersionHi, PCSX2_VersionMid, PCSX2_VersionLo, - SVN_REV, SVN_MODS ? L"m" : wxEmptyString ); -#endif + if (strlen(GIT_REV) > 5) { + wintitle.Printf( L"%s %s", pxGetAppName().c_str(), GIT_REV); + } else { + wintitle.Printf( L"%s %d.%d.%d-%lld%s (git)", pxGetAppName().c_str(), PCSX2_VersionHi, PCSX2_VersionMid, + PCSX2_VersionLo, SVN_REV, SVN_MODS ? L"m" : wxEmptyString ); + } } SetTitle( wintitle );