Build: Fix revision extractor for Qt auto updater

This commit is contained in:
Connor McLaughlin 2022-05-13 01:54:02 +10:00 committed by refractionpcsx2
parent 943b513a52
commit 7f8bfb22de
3 changed files with 19 additions and 3 deletions

View File

@ -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()

View File

@ -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"
)

View File

@ -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