From 7f8bfb22de04e0f25016605068d856a3556d6bab Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Fri, 13 May 2022 01:54:02 +1000 Subject: [PATCH] Build: Fix revision extractor for Qt auto updater --- cmake/Pcsx2Utils.cmake | 10 ++++++++++ common/vsprops/preBuild.cmd | 10 ++++++++-- pcsx2-qt/AutoUpdaterDialog.cpp | 2 +- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/cmake/Pcsx2Utils.cmake b/cmake/Pcsx2Utils.cmake index 6a70b906af..c87f305fbe 100644 --- a/cmake/Pcsx2Utils.cmake +++ b/cmake/Pcsx2Utils.cmake @@ -39,6 +39,7 @@ function(get_git_version_info) set(PCSX2_WC_TIME 0) set(PCSX2_GIT_REV "") set(PCSX2_GIT_TAG "") + set(PCSX2_GIT_HASH "") 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 @@ -56,6 +57,11 @@ function(get_git_version_info) OUTPUT_VARIABLE PCSX2_GIT_TAG OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_QUIET) + + EXECUTE_PROCESS(WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} COMMAND ${GIT_EXECUTABLE} rev-parse HEAD + OUTPUT_VARIABLE PCSX2_GIT_HASH + OUTPUT_STRIP_TRAILING_WHITESPACE + ERROR_QUIET) endif() if ("${PCSX2_GIT_TAG}" MATCHES "^v([0-9]+)\\.([0-9]+)\\.([0-9]+)$") string(REGEX MATCH "[0-9]+\\.[0-9]+\\.[0-9]+" PCSX2_VERSION_LONG "${PCSX2_GIT_TAG}") @@ -74,6 +80,7 @@ function(get_git_version_info) set(PCSX2_WC_TIME "${PCSX2_WC_TIME}" PARENT_SCOPE) set(PCSX2_GIT_REV "${PCSX2_GIT_REV}" PARENT_SCOPE) set(PCSX2_GIT_TAG "${PCSX2_GIT_TAG}" PARENT_SCOPE) + set(PCSX2_GIT_HASH "${PCSX2_GIT_HASH}" PARENT_SCOPE) set(PCSX2_VERSION_LONG "${PCSX2_VERSION_LONG}" PARENT_SCOPE) set(PCSX2_VERSION_SHORT "${PCSX2_VERSION_SHORT}" PARENT_SCOPE) endfunction() @@ -89,6 +96,7 @@ function(write_svnrev_h) "#define GIT_TAG_MID ${CMAKE_MATCH_2}\n" "#define GIT_TAG_LO ${CMAKE_MATCH_3}\n" "#define GIT_REV \"\"\n" + "#define GIT_HASH \"${PCSX2_GIT_HASH}\"\n" ) else() file(WRITE ${CMAKE_BINARY_DIR}/common/include/svnrev.h @@ -96,6 +104,7 @@ function(write_svnrev_h) "#define GIT_TAG \"${PCSX2_GIT_TAG}\"\n" "#define GIT_TAGGED_COMMIT 1\n" "#define GIT_REV \"\"\n" + "#define GIT_HASH \"${PCSX2_GIT_HASH}\"\n" ) endif() else() @@ -104,6 +113,7 @@ function(write_svnrev_h) "#define GIT_TAG \"${PCSX2_GIT_TAG}\"\n" "#define GIT_TAGGED_COMMIT 0\n" "#define GIT_REV \"${PCSX2_GIT_REV}\"\n" + "#define GIT_HASH \"${PCSX2_GIT_HASH}\"\n" ) endif() endfunction() diff --git a/common/vsprops/preBuild.cmd b/common/vsprops/preBuild.cmd index 885cdf3a37..17e7a79afa 100644 --- a/common/vsprops/preBuild.cmd +++ b/common/vsprops/preBuild.cmd @@ -30,6 +30,10 @@ FOR /F "tokens=* USEBACKQ" %%i IN (`git tag --points-at HEAD`) DO ( set GIT_TAG=%%i ) +FOR /F "tokens=* USEBACKQ" %%i IN (`git rev-parse HEAD`) DO ( + set GIT_HASH=%%i +) + set REV2=%REV3: =% set REV1=%REV2:-=% set REV=%REV1::=% @@ -45,15 +49,16 @@ if %ERRORLEVEL% NEQ 0 ( echo #define SVN_REV_UNKNOWN > "%CD%\svnrev.h" echo #define SVN_REV 0ll >> "%CD%\svnrev.h" echo #define GIT_REV "" >> "%CD%\svnrev.h" + echo #define GIT_HASH "" >> "%CD%\svnrev.h" echo #define GIT_TAG "" >> "%CD%\svnrev.h" echo #define GIT_TAGGED_COMMIT 0 >> "%CD%\svnrev.h" ) else ( :: Support New Tagged Release Model if [%GIT_TAG%] NEQ [] ( echo Detected that the current commit is tagged, using that! - echo #define SVN_REV_UNKNOWN > "%CD%\svnrev.h" - echo #define SVN_REV 0ll >> "%CD%\svnrev.h" + echo #define SVN_REV %REV%ll > "%CD%\svnrev.h" echo #define GIT_REV "" >> "%CD%\svnrev.h" + echo #define GIT_HASH "%GIT_HASH%" >> "%CD%\svnrev.h" echo #define GIT_TAG "%GIT_TAG%" >> "%CD%\svnrev.h" echo %GIT_TAG%|FINDSTR /R "^v[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*$" > NUL @@ -69,6 +74,7 @@ if %ERRORLEVEL% NEQ 0 ( ) else ( echo #define SVN_REV %REV%ll > "%CD%\svnrev.h" echo #define GIT_REV "%GIT_REV%" >> "%CD%\svnrev.h" + echo #define GIT_HASH "%GIT_HASH%" >> "%CD%\svnrev.h" echo #define GIT_TAG "" >> "%CD%\svnrev.h" echo #define GIT_TAGGED_COMMIT 0 >> "%CD%\svnrev.h" ) diff --git a/pcsx2-qt/AutoUpdaterDialog.cpp b/pcsx2-qt/AutoUpdaterDialog.cpp index 0c0e76690e..bc877bcdc6 100644 --- a/pcsx2-qt/AutoUpdaterDialog.cpp +++ b/pcsx2-qt/AutoUpdaterDialog.cpp @@ -68,7 +68,7 @@ static const char* UPDATE_TAGS[] = {"stable", "nightly"}; // Bit annoying, because PCSX2_isReleaseVersion is a bool, but whatever. -#define SCM_RELEASE_TAG (PCSX2_isReleaseVersion ? "stable" : "nightly") +#define THIS_RELEASE_TAG (PCSX2_isReleaseVersion ? "stable" : "nightly") #endif