build: If available - use the current git tag for the build metadata

This commit is contained in:
Tyler Wilding 2021-10-18 00:09:42 -04:00 committed by tellowkrinkle
parent a494e05fd9
commit c4e5a21c86
6 changed files with 65 additions and 14 deletions

2
.gitignore vendored
View File

@ -114,3 +114,5 @@ oprofile_data/
/out/build/x64-Debug (default) /out/build/x64-Debug (default)
CMakeSettings.json CMakeSettings.json
/ci-artifacts/
/out/

View File

@ -38,6 +38,7 @@ endfunction()
function(get_git_version_info) function(get_git_version_info)
set(PCSX2_WC_TIME 0) set(PCSX2_WC_TIME 0)
set(PCSX2_GIT_REV "") set(PCSX2_GIT_REV "")
set(PCSX2_GIT_TAG "")
if (GIT_FOUND AND EXISTS ${PROJECT_SOURCE_DIR}/.git) if (GIT_FOUND AND EXISTS ${PROJECT_SOURCE_DIR}/.git)
EXECUTE_PROCESS(WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} COMMAND ${GIT_EXECUTABLE} show -s --format=%ci HEAD EXECUTE_PROCESS(WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} COMMAND ${GIT_EXECUTABLE} show -s --format=%ci HEAD
OUTPUT_VARIABLE PCSX2_WC_TIME OUTPUT_VARIABLE PCSX2_WC_TIME
@ -50,6 +51,11 @@ function(get_git_version_info)
OUTPUT_VARIABLE PCSX2_GIT_REV OUTPUT_VARIABLE PCSX2_GIT_REV
OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_QUIET) ERROR_QUIET)
EXECUTE_PROCESS(WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} COMMAND ${GIT_EXECUTABLE} tag --points-at HEAD
OUTPUT_VARIABLE PCSX2_GIT_TAG
OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_QUIET)
endif() endif()
if(PCSX2_GIT_REV) if(PCSX2_GIT_REV)
set(PCSX2_VERSION_LONG "${PCSX2_GIT_REV}") set(PCSX2_VERSION_LONG "${PCSX2_GIT_REV}")
@ -69,7 +75,11 @@ function(get_git_version_info)
endfunction() endfunction()
function(write_svnrev_h) function(write_svnrev_h)
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}\"\n") if(PCSX2_GIT_TAG)
file(WRITE ${CMAKE_BINARY_DIR}/common/include/svnrev.h "#define SVN_REV ${PCSX2_WC_TIME}ll \n#define GIT_TAG \"${PCSX2_GIT_TAG}\"\n#define GIT_TAGGED_COMMIT 1\n#define GIT_REV \"\"\n")
else()
file(WRITE ${CMAKE_BINARY_DIR}/common/include/svnrev.h "#define SVN_REV ${PCSX2_WC_TIME}ll \n#define GIT_TAG \"${PCSX2_GIT_TAG}\"\n#define GIT_TAGGED_COMMIT 0\n#define GIT_REV \"${PCSX2_GIT_REV}\"\n")
endif()
endfunction() endfunction()
function(check_compiler_version version_warn version_err) function(check_compiler_version version_warn version_err)

View File

@ -26,6 +26,10 @@ FOR /F %%i IN ('"git describe 2> NUL"') do (
set GIT_REV=%%i set GIT_REV=%%i
) )
FOR /F "tokens=* USEBACKQ" %%i IN (`git tag --points-at HEAD`) DO (
set GIT_TAG=%%i
)
set REV2=%REV3: =% set REV2=%REV3: =%
set REV1=%REV2:-=% set REV1=%REV2:-=%
set REV=%REV1::=% set REV=%REV1::=%
@ -40,12 +44,24 @@ if %ERRORLEVEL% NEQ 0 (
echo #define SVN_REV_UNKNOWN > "%CD%\svnrev.h" echo #define SVN_REV_UNKNOWN > "%CD%\svnrev.h"
echo #define SVN_REV 0ll >> "%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" echo #define GIT_REV "" >> "%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 GIT_REV "" >> "%CD%\svnrev.h"
echo #define GIT_TAG "%GIT_TAG%" >> "%CD%\svnrev.h"
echo #define GIT_TAGGED_COMMIT 1 >> "%CD%\svnrev.h"
) else ( ) else (
echo #define SVN_REV %REV%ll > "%CD%\svnrev.h" 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" echo #define GIT_REV "%GIT_REV%" >> "%CD%\svnrev.h"
echo #define GIT_TAG "" >> "%CD%\svnrev.h"
echo #define GIT_TAGGED_COMMIT 0 >> "%CD%\svnrev.h"
)
) )
ENDLOCAL ENDLOCAL

View File

@ -381,7 +381,16 @@ SocketIPC::IPCBuffer SocketIPC::ParseCommand(char* buf, char* ret_buffer, u32 bu
case MsgVersion: case MsgVersion:
{ {
char version[256] = {}; char version[256] = {};
sprintf(version, "PCSX2 %u.%u.%u-%lld %s", PCSX2_VersionHi, PCSX2_VersionMid, PCSX2_VersionLo, SVN_REV, SVN_MODS ? "(modded)" : ""); if (GIT_TAGGED_COMMIT) // Nightly builds
{
// tagged commit - more modern implementation of dev build versioning
// - there is no need to include the commit - that is associated with the tag, git is implied
sprintf(version, "PCSX2 Nightly - %s", GIT_TAG);
}
else
{
sprintf(version, "PCSX2 %u.%u.%u-%lld", PCSX2_VersionHi, PCSX2_VersionMid, PCSX2_VersionLo, SVN_REV);
}
version[255] = 0x00; version[255] = 0x00;
if (!SafetyChecks(buf_cnt, 0, ret_cnt, 256, buf_size)) if (!SafetyChecks(buf_cnt, 0, ret_cnt, 256, buf_size))
goto error; goto error;

View File

@ -156,13 +156,21 @@ void SysLogMachineCaps()
{ {
if ( !PCSX2_isReleaseVersion ) if ( !PCSX2_isReleaseVersion )
{ {
Console.WriteLn(Color_StrongGreen, "\nPCSX2 %u.%u.%u-%lld %s" if (GIT_TAGGED_COMMIT) // Nightly builds
{
// tagged commit - more modern implementation of dev build versioning
// - there is no need to include the commit - that is associated with the tag,
// - git is implied and the tag is timestamped
Console.WriteLn(Color_StrongGreen, "\nPCSX2 Nightly - %s", GIT_TAG);
} else {
Console.WriteLn(Color_StrongGreen, "\nPCSX2 %u.%u.%u-%lld"
#ifndef DISABLE_BUILD_DATE #ifndef DISABLE_BUILD_DATE
"- compiled on " __DATE__ "- compiled on " __DATE__
#endif #endif
, PCSX2_VersionHi, PCSX2_VersionMid, PCSX2_VersionLo, ,
SVN_REV, SVN_MODS ? "(modded)" : "" PCSX2_VersionHi, PCSX2_VersionMid, PCSX2_VersionLo,
); SVN_REV);
}
} }
else { // shorter release version string else { // shorter release version string
Console.WriteLn(Color_StrongGreen, "PCSX2 %u.%u.%u-%lld" Console.WriteLn(Color_StrongGreen, "PCSX2 %u.%u.%u-%lld"

View File

@ -621,6 +621,12 @@ MainEmuFrame::MainEmuFrame(wxWindow* parent, const wxString& title)
// stable releases, with a simple title. // stable releases, with a simple title.
wintitle.Printf(L"%s %d.%d.%d", pxGetAppName().c_str(), PCSX2_VersionHi, PCSX2_VersionMid, PCSX2_VersionLo); wintitle.Printf(L"%s %d.%d.%d", pxGetAppName().c_str(), PCSX2_VersionHi, PCSX2_VersionMid, PCSX2_VersionLo);
} }
else if (GIT_TAGGED_COMMIT) // Nightly builds
{
// tagged commit - more modern implementation of dev build versioning
// - there is no need to include the commit - that is associated with the tag, git is implied
wintitle.Printf(L"%s Nightly - %s", pxGetAppName().c_str(), GIT_TAG);
}
else else
{ {
// beta / development editions, which feature revision number and compile date. // beta / development editions, which feature revision number and compile date.
@ -630,8 +636,8 @@ MainEmuFrame::MainEmuFrame(wxWindow* parent, const wxString& title)
} }
else else
{ {
wintitle.Printf(L"%s %d.%d.%d-%lld%s (git)", pxGetAppName().c_str(), PCSX2_VersionHi, PCSX2_VersionMid, wintitle.Printf(L"%s %d.%d.%d-%lld (git)", pxGetAppName().c_str(), PCSX2_VersionHi, PCSX2_VersionMid,
PCSX2_VersionLo, SVN_REV, SVN_MODS ? L"m" : wxEmptyString); PCSX2_VersionLo, SVN_REV);
} }
} }