Build: Simplify Git version extraction

Get rid of SysForwardDefs.h
Use last known git tag to determine version info, if it is not a tagged commit.
This commit is contained in:
Stenzek 2024-01-07 19:36:40 +10:00 committed by Connor McLaughlin
parent 4a93ceac58
commit ff34150b15
19 changed files with 131 additions and 231 deletions

View File

@ -231,11 +231,6 @@ endif()
set(PCSX2_WARNINGS ${DEFAULT_WARNINGS}) set(PCSX2_WARNINGS ${DEFAULT_WARNINGS})
if(DISABLE_BUILD_DATE)
message(STATUS "Disabling the inclusion of the binary compile date.")
list(APPEND PCSX2_DEFS DISABLE_BUILD_DATE)
endif()
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
# MacOS-specific things # MacOS-specific things
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------

View File

@ -44,19 +44,11 @@ function(detect_compiler)
endfunction() endfunction()
function(get_git_version_info) function(get_git_version_info)
set(PCSX2_WC_TIME 0)
set(PCSX2_GIT_REV "") set(PCSX2_GIT_REV "")
set(PCSX2_GIT_TAG "") set(PCSX2_GIT_TAG "")
set(PCSX2_GIT_HASH "") set(PCSX2_GIT_HASH "")
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} describe --tags
OUTPUT_VARIABLE PCSX2_WC_TIME
OUTPUT_STRIP_TRAILING_WHITESPACE)
# 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_VARIABLE PCSX2_GIT_REV
OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_QUIET) ERROR_QUIET)
@ -83,58 +75,61 @@ function(get_git_version_info)
OUTPUT_VARIABLE PCSX2_GIT_HASH OUTPUT_VARIABLE PCSX2_GIT_HASH
OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_QUIET) ERROR_QUIET)
EXECUTE_PROCESS(WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} COMMAND ${GIT_EXECUTABLE} log -1 --format=%cd --date=local
OUTPUT_VARIABLE PCSX2_GIT_DATE
OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_QUIET)
endif() endif()
if ("${PCSX2_GIT_TAG}" MATCHES "^v([0-9]+)\\.([0-9]+)\\.([0-9]+)$") if (NOT PCSX2_GIT_REV)
string(REGEX MATCH "[0-9]+\\.[0-9]+\\.[0-9]+" PCSX2_VERSION_LONG "${PCSX2_GIT_TAG}") EXECUTE_PROCESS(WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} COMMAND ${GIT_EXECUTABLE} rev-parse --short HEAD
string(REGEX MATCH "[0-9]+\\.[0-9]+\\.[0-9]+" PCSX2_VERSION_SHORT "${PCSX2_GIT_TAG}") OUTPUT_VARIABLE PCSX2_GIT_REV
elseif(PCSX2_GIT_REV) OUTPUT_STRIP_TRAILING_WHITESPACE
set(PCSX2_VERSION_LONG "${PCSX2_GIT_REV}") ERROR_QUIET)
string(REGEX MATCH "[0-9]+\\.[0-9]+(\\.[0-9]+)?(-[a-z][a-z0-9]+)?" PCSX2_VERSION_SHORT "${PCSX2_VERSION_LONG}") if (NOT PCSX2_GIT_REV)
else() set(PCSX2_GIT_REV "Unknown")
set(PCSX2_VERSION_LONG "Unknown (git unavailable)")
set(PCSX2_VERSION_SHORT "Unknown")
endif() endif()
if ("${PCSX2_WC_TIME}" STREQUAL "")
set(PCSX2_WC_TIME 0)
endif() endif()
set(PCSX2_WC_TIME "${PCSX2_WC_TIME}" PARENT_SCOPE)
set(PCSX2_GIT_REV "${PCSX2_GIT_REV}" PARENT_SCOPE) set(PCSX2_GIT_REV "${PCSX2_GIT_REV}" PARENT_SCOPE)
set(PCSX2_GIT_TAG "${PCSX2_GIT_TAG}" PARENT_SCOPE) set(PCSX2_GIT_TAG "${PCSX2_GIT_TAG}" PARENT_SCOPE)
set(PCSX2_GIT_HASH "${PCSX2_GIT_HASH}" PARENT_SCOPE) set(PCSX2_GIT_HASH "${PCSX2_GIT_HASH}" PARENT_SCOPE)
set(PCSX2_VERSION_LONG "${PCSX2_VERSION_LONG}" PARENT_SCOPE) set(PCSX2_GIT_DATE "${PCSX2_GIT_DATE}" PARENT_SCOPE)
set(PCSX2_VERSION_SHORT "${PCSX2_VERSION_SHORT}" PARENT_SCOPE)
endfunction() endfunction()
function(write_svnrev_h) function(write_svnrev_h)
if(PCSX2_GIT_TAG)
if ("${PCSX2_GIT_TAG}" MATCHES "^v([0-9]+)\\.([0-9]+)\\.([0-9]+)$") if ("${PCSX2_GIT_TAG}" MATCHES "^v([0-9]+)\\.([0-9]+)\\.([0-9]+)$")
file(WRITE ${CMAKE_BINARY_DIR}/common/include/svnrev.h 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_TAG \"${PCSX2_GIT_TAG}\"\n"
"#define GIT_TAGGED_COMMIT 1\n" "#define GIT_TAGGED_COMMIT 1\n"
"#define GIT_TAG_HI ${CMAKE_MATCH_1}\n" "#define GIT_TAG_HI ${CMAKE_MATCH_1}\n"
"#define GIT_TAG_MID ${CMAKE_MATCH_2}\n" "#define GIT_TAG_MID ${CMAKE_MATCH_2}\n"
"#define GIT_TAG_LO ${CMAKE_MATCH_3}\n" "#define GIT_TAG_LO ${CMAKE_MATCH_3}\n"
"#define GIT_REV \"\"\n" "#define GIT_REV \"${PCSX2_GIT_TAG}\"\n"
"#define GIT_HASH \"${PCSX2_GIT_HASH}\"\n" "#define GIT_HASH \"${PCSX2_GIT_HASH}\"\n"
"#define GIT_DATE \"${PCSX2_GIT_DATE}\"\n"
) )
else() elseif ("${PCSX2_GIT_REV}" MATCHES "^v([0-9]+)\\.([0-9]+)\\.([0-9]+)")
file(WRITE ${CMAKE_BINARY_DIR}/common/include/svnrev.h 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"
"#define GIT_HASH \"${PCSX2_GIT_HASH}\"\n"
)
endif()
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_TAG \"${PCSX2_GIT_TAG}\"\n"
"#define GIT_TAGGED_COMMIT 0\n" "#define GIT_TAGGED_COMMIT 0\n"
"#define GIT_TAG_HI ${CMAKE_MATCH_1}\n"
"#define GIT_TAG_MID ${CMAKE_MATCH_2}\n"
"#define GIT_TAG_LO ${CMAKE_MATCH_3}\n"
"#define GIT_REV \"${PCSX2_GIT_REV}\"\n" "#define GIT_REV \"${PCSX2_GIT_REV}\"\n"
"#define GIT_HASH \"${PCSX2_GIT_HASH}\"\n" "#define GIT_HASH \"${PCSX2_GIT_HASH}\"\n"
"#define GIT_DATE \"${PCSX2_GIT_DATE}\"\n"
)
else()
file(WRITE ${CMAKE_BINARY_DIR}/common/include/svnrev.h
"#define GIT_TAG \"${PCSX2_GIT_TAG}\"\n"
"#define GIT_TAGGED_COMMIT 0\n"
"#define GIT_TAG_HI 0\n"
"#define GIT_TAG_MID 0\n"
"#define GIT_TAG_LO 0\n"
"#define GIT_REV \"${PCSX2_GIT_REV}\"\n"
"#define GIT_HASH \"${PCSX2_GIT_HASH}\"\n"
"#define GIT_DATE \"${PCSX2_GIT_DATE}\"\n"
) )
endif() endif()
endfunction() endfunction()

View File

@ -6,6 +6,9 @@
#include "common/Threading.h" #include "common/Threading.h"
#include "common/Assertions.h" #include "common/Assertions.h"
#include "common/RedtapeWindows.h" #include "common/RedtapeWindows.h"
#include <memory>
#include <mmsystem.h> #include <mmsystem.h>
#include <process.h> #include <process.h>
#include <timeapi.h> #include <timeapi.h>

View File

@ -18,12 +18,15 @@ IF EXIST "%ProgramFiles%\Git\bin\git.exe" SET "GITPATH=%ProgramFiles%\Git\bin"
IF EXIST "%ProgramW6432%\Git\bin\git.exe" SET "GITPATH=%ProgramW6432%\Git\bin" IF EXIST "%ProgramW6432%\Git\bin\git.exe" SET "GITPATH=%ProgramW6432%\Git\bin"
IF DEFINED GITPATH SET "PATH=%PATH%;%GITPATH%" IF DEFINED GITPATH SET "PATH=%PATH%;%GITPATH%"
FOR /F "tokens=1-2" %%i IN ('"git show -s --format=%%%ci HEAD 2> NUL"') do ( git describe --tags > NUL 2>NUL
set REV3=%%i%%j if !ERRORLEVEL! EQU 0 (
) FOR /F %%i IN ('"git describe --tags 2> NUL"') do (
FOR /F %%i IN ('"git describe 2> NUL"') do (
set GIT_REV=%%i set GIT_REV=%%i
)
) else (
FOR /F %%i IN ('"git rev-parse --short HEAD 2> NUL"') do (
set GIT_REV=%%i
)
) )
FOR /F "tokens=* USEBACKQ" %%i IN (`git tag --points-at HEAD`) DO ( FOR /F "tokens=* USEBACKQ" %%i IN (`git tag --points-at HEAD`) DO (
@ -34,11 +37,11 @@ FOR /F "tokens=* USEBACKQ" %%i IN (`git rev-parse HEAD`) DO (
set GIT_HASH=%%i set GIT_HASH=%%i
) )
set REV2=%REV3: =% FOR /F "tokens=* USEBACKQ" %%i IN (`git log -1 "--format=%%cd" "--date=local"`) DO (
set REV1=%REV2:-=% set GIT_DATE=%%i
set REV=%REV1::=% )
SET SIGNATURELINE=// H[%GIT_HASH%] T[%GIT_TAG%] SET SIGNATURELINE=// R[%GIT_REV%] H[%GIT_HASH%] T[%GIT_TAG%]
SET /P EXISTINGLINE=<"%CD%\svnrev.h" SET /P EXISTINGLINE=<"%CD%\svnrev.h"
IF "%EXISTINGLINE%"=="%SIGNATURELINE%" ( IF "%EXISTINGLINE%"=="%SIGNATURELINE%" (
@ -48,45 +51,36 @@ IF "%EXISTINGLINE%"=="%SIGNATURELINE%" (
ECHO Updating "%CD%\svnrev.h"... ECHO Updating "%CD%\svnrev.h"...
echo %SIGNATURELINE%> "%CD%\svnrev.h" echo %SIGNATURELINE%> "%CD%\svnrev.h"
git show -s > NUL 2>&1 echo #define GIT_HASH "%GIT_HASH%" >> "%CD%\svnrev.h"
if %ERRORLEVEL% NEQ 0 ( echo #define GIT_TAG "%GIT_TAG%" >> "%CD%\svnrev.h"
echo Automatic version detection unavailable. echo #define GIT_DATE "%GIT_DATE%" >> "%CD%\svnrev.h"
echo If you want to have the version string print correctly,
echo make sure your Git.exe is in the default installation directory,
echo or in your PATH.
echo You can safely ignore this message - a dummy string will be printed.
echo #define SVN_REV_UNKNOWN >> "%CD%\svnrev.h" echo %GIT_TAG%|FINDSTR /R "^v[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*$" > NUL
echo #define SVN_REV 0ll >> "%CD%\svnrev.h" if !ERRORLEVEL! EQU 0 (
echo #define GIT_REV "" >> "%CD%\svnrev.h" echo #define GIT_REV "%GIT_TAG%" >> "%CD%\svnrev.h"
echo #define GIT_HASH "" >> "%CD%\svnrev.h" echo #define GIT_TAGGED_COMMIT 1 >> "%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 %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
if !ERRORLEVEL! EQU 0 (
FOR /F "tokens=1,2,3 delims=v." %%a in ("%GIT_TAG%") DO ( FOR /F "tokens=1,2,3 delims=v." %%a in ("%GIT_TAG%") DO (
echo #define GIT_TAG_HI %%a >> "%CD%\svnrev.h" echo #define GIT_TAG_HI %%a >> "%CD%\svnrev.h"
echo #define GIT_TAG_MID %%b >> "%CD%\svnrev.h" echo #define GIT_TAG_MID %%b >> "%CD%\svnrev.h"
echo #define GIT_TAG_LO %%c >> "%CD%\svnrev.h" echo #define GIT_TAG_LO %%c >> "%CD%\svnrev.h"
) )
) ) else (
:: Local branches
echo #define GIT_TAGGED_COMMIT 1 >> "%CD%\svnrev.h"
) else (
echo #define SVN_REV %REV%ll >> "%CD%\svnrev.h"
echo #define GIT_REV "%GIT_REV%" >> "%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" echo #define GIT_TAGGED_COMMIT 0 >> "%CD%\svnrev.h"
echo %GIT_REV%|FINDSTR /R "^v[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]-*" > NUL
if !ERRORLEVEL! EQU 0 (
FOR /F "tokens=1,2,3 delims=v." %%a in ("%GIT_REV%") DO (
echo #define GIT_TAG_HI %%a >> "%CD%\svnrev.h"
echo #define GIT_TAG_MID %%b >> "%CD%\svnrev.h"
FOR /F "tokens=1 delims=-" %%d in ("%%c%") DO (
echo #define GIT_TAG_LO %%d >> "%CD%\svnrev.h"
)
)
) else (
echo #define GIT_TAG_HI 0 >> "%CD%\svnrev.h"
echo #define GIT_TAG_MID 0 >> "%CD%\svnrev.h"
echo #define GIT_TAG_LO 0 >> "%CD%\svnrev.h"
) )
) )

View File

@ -1,7 +1,7 @@
// SPDX-FileCopyrightText: 2002-2023 PCSX2 Dev Team // SPDX-FileCopyrightText: 2002-2023 PCSX2 Dev Team
// SPDX-License-Identifier: LGPL-3.0+ // SPDX-License-Identifier: LGPL-3.0+
#include "pcsx2/SysForwardDefs.h" #include "pcsx2/SupportURLs.h"
#include "AboutDialog.h" #include "AboutDialog.h"
#include "QtHost.h" #include "QtHost.h"

View File

@ -8,7 +8,6 @@
#include "QtUtils.h" #include "QtUtils.h"
#include "pcsx2/Host.h" #include "pcsx2/Host.h"
#include "pcsx2/SysForwardDefs.h"
#include "svnrev.h" #include "svnrev.h"
#include "updater/UpdaterExtractor.h" #include "updater/UpdaterExtractor.h"
@ -50,7 +49,7 @@ static constexpr u32 HTTP_POLL_INTERVAL = 10;
// Logic to detect whether we can use the auto updater. // Logic to detect whether we can use the auto updater.
// We use tagged commit, because this gets set on nightly builds. // We use tagged commit, because this gets set on nightly builds.
#if (defined(_WIN32) || defined(__linux__) || defined(__APPLE__)) && defined(GIT_TAG_LO) #if (defined(_WIN32) || defined(__linux__) || defined(__APPLE__)) && GIT_TAGGED_COMMIT
#define AUTO_UPDATER_SUPPORTED 1 #define AUTO_UPDATER_SUPPORTED 1
@ -149,9 +148,7 @@ QString AutoUpdaterDialog::getCurrentVersion()
QString AutoUpdaterDialog::getCurrentVersionDate() QString AutoUpdaterDialog::getCurrentVersionDate()
{ {
// 20220403235450ll return QStringLiteral(GIT_DATE);
const QDateTime current_build_date(QDateTime::fromString(QStringLiteral("%1").arg(SVN_REV), "yyyyMMddhhmmss"));
return current_build_date.toString();
} }
QString AutoUpdaterDialog::getCurrentUpdateTag() const QString AutoUpdaterDialog::getCurrentUpdateTag() const

View File

@ -29,7 +29,6 @@
#include "pcsx2/Input/InputManager.h" #include "pcsx2/Input/InputManager.h"
#include "pcsx2/MTGS.h" #include "pcsx2/MTGS.h"
#include "pcsx2/PerformanceMetrics.h" #include "pcsx2/PerformanceMetrics.h"
#include "pcsx2/SysForwardDefs.h"
#include "pcsx2/VMManager.h" #include "pcsx2/VMManager.h"
#include "common/Assertions.h" #include "common/Assertions.h"
@ -1337,24 +1336,7 @@ bool Host::RequestResetSettings(bool folders, bool core, bool controllers, bool
QString QtHost::GetAppNameAndVersion() QString QtHost::GetAppNameAndVersion()
{ {
QString ret;
if constexpr (!PCSX2_isReleaseVersion && GIT_TAGGED_COMMIT)
{
ret = QStringLiteral("PCSX2 Nightly - " GIT_TAG);
}
else if constexpr (PCSX2_isReleaseVersion)
{
#define APPNAME_STRINGIZE(x) #x
ret = QStringLiteral(
"PCSX2 " APPNAME_STRINGIZE(PCSX2_VersionHi) "." APPNAME_STRINGIZE(PCSX2_VersionMid) "." APPNAME_STRINGIZE(PCSX2_VersionLo));
#undef APPNAME_STRINGIZE
}
else
{
return QStringLiteral("PCSX2 " GIT_REV); return QStringLiteral("PCSX2 " GIT_REV);
}
return ret;
} }
QString QtHost::GetAppConfigSuffix() QString QtHost::GetAppConfigSuffix()

View File

@ -193,8 +193,8 @@ set(pcsx2Headers
SIO/Memcard/MemoryCardFolder.h SIO/Memcard/MemoryCardFolder.h
SIO/Memcard/MemoryCardProtocol.h SIO/Memcard/MemoryCardProtocol.h
SPR.h SPR.h
SupportURLs.h
StateWrapper.h StateWrapper.h
SysForwardDefs.h
Vif_Dma.h Vif_Dma.h
Vif.h Vif.h
Vif_Unpack.h Vif_Unpack.h

View File

@ -5,7 +5,6 @@
#include "GS/Renderers/HW/GSTextureReplacements.h" #include "GS/Renderers/HW/GSTextureReplacements.h"
#include "Host.h" #include "Host.h"
#include "LayeredSettingsInterface.h" #include "LayeredSettingsInterface.h"
#include "SysForwardDefs.h"
#include "VMManager.h" #include "VMManager.h"
#include "svnrev.h" #include "svnrev.h"
@ -160,15 +159,7 @@ bool Host::ConfirmFormattedMessage(const std::string_view& title, const char* fo
std::string Host::GetHTTPUserAgent() std::string Host::GetHTTPUserAgent()
{ {
std::string ret; return fmt::format("PCSX2 " GIT_REV " ({})", GetOSVersionString());
if (!PCSX2_isReleaseVersion && GIT_TAGGED_COMMIT)
ret = fmt::format("PCSX2 Nightly - {} ({})", GIT_TAG, GetOSVersionString());
else if (!PCSX2_isReleaseVersion)
ret = fmt::format("PCSX2 {} ({})", GIT_REV, GetOSVersionString());
else
ret = fmt::format("PCSX2 {}.{}.{}-{} ({})", PCSX2_VersionHi, PCSX2_VersionMid, PCSX2_VersionLo, SVN_REV, GetOSVersionString());
return ret;
} }
std::unique_lock<std::mutex> Host::GetSettingsLock() std::unique_lock<std::mutex> Host::GetSettingsLock()

View File

@ -17,7 +17,7 @@
#include "Input/InputManager.h" #include "Input/InputManager.h"
#include "MTGS.h" #include "MTGS.h"
#include "Patch.h" #include "Patch.h"
#include "SysForwardDefs.h" #include "SupportURLs.h"
#include "USB/USB.h" #include "USB/USB.h"
#include "VMManager.h" #include "VMManager.h"
#include "ps2/BiosTools.h" #include "ps2/BiosTools.h"

View File

@ -4,7 +4,6 @@
#include "Common.h" #include "Common.h"
#include "Memory.h" #include "Memory.h"
#include "Elfheader.h" #include "Elfheader.h"
#include "SysForwardDefs.h"
#include "PINE.h" #include "PINE.h"
#include "VMManager.h" #include "VMManager.h"
#include "svnrev.h" #include "svnrev.h"
@ -16,6 +15,8 @@
#include <sys/types.h> #include <sys/types.h>
#include <thread> #include <thread>
#include "fmt/format.h"
#if _WIN32 #if _WIN32
#define read_portable(a, b, c) (recv(a, (char*)b, c, 0)) #define read_portable(a, b, c) (recv(a, (char*)b, c, 0))
#define write_portable(a, b, c) (send(a, (const char*)b, c, 0)) #define write_portable(a, b, c) (send(a, (const char*)b, c, 0))
@ -48,8 +49,6 @@
#include <unistd.h> #include <unistd.h>
#endif #endif
#include "fmt/format.h"
#define PINE_EMULATOR_NAME "pcsx2" #define PINE_EMULATOR_NAME "pcsx2"
#ifdef _WIN32 #ifdef _WIN32
@ -607,23 +606,14 @@ PINEServer::IPCBuffer PINEServer::ParseCommand(std::span<u8> buf, std::vector<u8
{ {
if (!VMManager::HasValidVM()) if (!VMManager::HasValidVM())
goto error; goto error;
std::string version;
if (GIT_TAGGED_COMMIT) // Nightly builds static constexpr const char* version = "PCSX2 " GIT_REV;
{ static constexpr u32 size = sizeof(version) + 1;
// 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
version = fmt::format("PCSX2 Nightly - {}", GIT_TAG);
}
else
{
version = fmt::format("PCSX2 {}.{}.{}-{}", PCSX2_VersionHi, PCSX2_VersionMid, PCSX2_VersionLo, SVN_REV);
}
const u32 size = version.size() + 1;
if (!SafetyChecks(buf_cnt, 0, ret_cnt, size + 4, buf_size)) [[unlikely]] if (!SafetyChecks(buf_cnt, 0, ret_cnt, size + 4, buf_size)) [[unlikely]]
goto error; goto error;
ToResultVector(ret_buffer, size, ret_cnt); ToResultVector(ret_buffer, size, ret_cnt);
ret_cnt += 4; ret_cnt += 4;
memcpy(&ret_buffer[ret_cnt], version.c_str(), size); memcpy(&ret_buffer[ret_cnt], version, size);
ret_cnt += size; ret_cnt += size;
break; break;
} }

View File

@ -9,7 +9,6 @@
#include "DebugTools/Debug.h" #include "DebugTools/Debug.h"
#include "MemoryTypes.h" #include "MemoryTypes.h"
#include "svnrev.h" #include "svnrev.h"
#include "SysForwardDefs.h"
#include <fmt/format.h> #include <fmt/format.h>
@ -23,13 +22,7 @@ void InputRecordingFile::InputRecordingFileHeader::init() noexcept
void InputRecordingFile::setEmulatorVersion() void InputRecordingFile::setEmulatorVersion()
{ {
std::string emuVersion; StringUtil::Strlcpy(m_header.m_emulatorVersion, "PCSX2-" GIT_REV, sizeof(m_header.m_emulatorVersion));
if (!PCSX2_isReleaseVersion && GIT_TAGGED_COMMIT)
emuVersion = fmt::format("PCSX2-Nightly-{}", GIT_TAG);
else
emuVersion = fmt::format("PCSX2-{}.{}.{}", PCSX2_VersionHi, PCSX2_VersionMid, PCSX2_VersionLo);
StringUtil::Strlcpy(m_header.m_emulatorVersion, emuVersion.c_str(), sizeof(m_header.m_emulatorVersion));
} }
void InputRecordingFile::setAuthor(const std::string& _author) void InputRecordingFile::setAuthor(const std::string& _author)

View File

@ -30,9 +30,9 @@
<key>CFBundlePackageType</key> <key>CFBundlePackageType</key>
<string>APPL</string> <string>APPL</string>
<key>CFBundleShortVersionString</key> <key>CFBundleShortVersionString</key>
<string>${PCSX2_VERSION_SHORT}</string> <string>${PCSX2_GIT_REV}</string>
<key>CFBundleVersion</key> <key>CFBundleVersion</key>
<string>${PCSX2_VERSION_LONG}</string> <string>${PCSX2_GIT_REV}</string>
<key>NSHumanReadableCopyright</key> <key>NSHumanReadableCopyright</key>
<string>Licensed under GPL version 3</string> <string>Licensed under GPL version 3</string>
<key>LSMinimumSystemVersion</key> <key>LSMinimumSystemVersion</key>

10
pcsx2/SupportURLs.h Normal file
View File

@ -0,0 +1,10 @@
// SPDX-FileCopyrightText: 2002-2024 PCSX2 Dev Team
// SPDX-License-Identifier: LGPL-3.0+
#pragma once
#define PCSX2_WEBSITE_URL "https://pcsx2.net/"
#define PCSX2_FORUMS_URL "https://forums.pcsx2.net/"
#define PCSX2_GITHUB_URL "https://github.com/PCSX2/pcsx2"
#define PCSX2_LICENSE_URL "https://github.com/PCSX2/pcsx2/blob/master/pcsx2/Docs/License.txt"
#define PCSX2_DISCORD_URL "https://discord.com/invite/TCz3t9k"

View File

@ -1,33 +0,0 @@
// SPDX-FileCopyrightText: 2002-2023 PCSX2 Dev Team
// SPDX-License-Identifier: LGPL-3.0+
#pragma once
#define PCSX2_VersionHi 1
#define PCSX2_VersionMid 7
#define PCSX2_VersionLo 0
#define STRINGIZE2(s) #s
#define STRINGIZE(s) STRINGIZE2(s)
#define VER_FILE_DESCRIPTION_STR "PCSX2 PS2 Emulator"
#define VER_FILE_VERSION PCSX2_VersionHi, PCSX2_VersionMid, PCSX2_VersionLo, 0
#define VER_FILE_VERSION_STR STRINGIZE(PCSX2_VersionHi) \
"." STRINGIZE(PCSX2_VersionMid) \
"." STRINGIZE(PCSX2_VersionLo) \
"." STRINGIZE(0) \
#define VER_PRODUCTNAME_STR "PCSX2"
#define VER_PRODUCT_VERSION VER_FILE_VERSION
#define VER_PRODUCT_VERSION_STR VER_FILE_VERSION_STR
#define VER_ORIGINAL_FILENAME_STR VER_PRODUCTNAME_STR ".exe"
#define VER_INTERNAL_NAME_STR VER_ORIGINAL_FILENAME_STR
#define VER_COPYRIGHT_STR "Copyright (C) 2022"
#define PCSX2_WEBSITE_URL "https://pcsx2.net/"
#define PCSX2_FORUMS_URL "https://forums.pcsx2.net/"
#define PCSX2_GITHUB_URL "https://github.com/PCSX2/pcsx2"
#define PCSX2_LICENSE_URL "https://github.com/PCSX2/pcsx2/blob/master/pcsx2/Docs/License.txt"
#define PCSX2_DISCORD_URL "https://discord.com/invite/TCz3t9k"
static const bool PCSX2_isReleaseVersion = 0;

View File

@ -36,7 +36,6 @@
#include "SIO/Sio0.h" #include "SIO/Sio0.h"
#include "SIO/Sio2.h" #include "SIO/Sio2.h"
#include "SPU2/spu2.h" #include "SPU2/spu2.h"
#include "SysForwardDefs.h"
#include "USB/USB.h" #include "USB/USB.h"
#include "VMManager.h" #include "VMManager.h"
#include "ps2/BiosTools.h" #include "ps2/BiosTools.h"
@ -2219,38 +2218,9 @@ bool VMManager::IsLoadableFileName(const std::string_view& path)
void VMManager::LogCPUCapabilities() void VMManager::LogCPUCapabilities()
{ {
if (!PCSX2_isReleaseVersion) Console.WriteLn(Color_StrongGreen, "PCSX2 " GIT_REV);
{
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, "PCSX2 Nightly - %s Compiled on %s", GIT_TAG, __DATE__);
}
else
{
Console.WriteLn(Color_StrongGreen, "PCSX2 %u.%u.%u-%lld"
#ifndef DISABLE_BUILD_DATE
"- compiled on " __DATE__
#endif
,
PCSX2_VersionHi, PCSX2_VersionMid, PCSX2_VersionLo,
SVN_REV);
}
}
else
{ // shorter release version string
Console.WriteLn(Color_StrongGreen, "PCSX2 %u.%u.%u-%lld"
#ifndef DISABLE_BUILD_DATE
"- compiled on " __DATE__
#endif
,
PCSX2_VersionHi, PCSX2_VersionMid, PCSX2_VersionLo,
SVN_REV);
}
Console.WriteLnFmt("Savestate version: 0x{:x}\n", g_SaveVersion); Console.WriteLnFmt("Savestate version: 0x{:x}\n", g_SaveVersion);
Console.WriteLn();
Console.WriteLn(Color_StrongBlack, "Host Machine Init:"); Console.WriteLn(Color_StrongBlack, "Host Machine Init:");

View File

@ -672,6 +672,7 @@
<ClInclude Include="PrecompiledHeader.h" /> <ClInclude Include="PrecompiledHeader.h" />
<ClInclude Include="ps2\pgif.h" /> <ClInclude Include="ps2\pgif.h" />
<ClInclude Include="StateWrapper.h" /> <ClInclude Include="StateWrapper.h" />
<ClInclude Include="SupportURLs.h" />
<ClInclude Include="USB\deviceproxy.h" /> <ClInclude Include="USB\deviceproxy.h" />
<ClInclude Include="USB\qemu-usb\desc.h" /> <ClInclude Include="USB\qemu-usb\desc.h" />
<ClInclude Include="USB\qemu-usb\hid.h" /> <ClInclude Include="USB\qemu-usb\hid.h" />

View File

@ -2323,6 +2323,7 @@
<ClInclude Include="SIO\Pad\PadPopn.h"> <ClInclude Include="SIO\Pad\PadPopn.h">
<Filter>System\Ps2\Iop\SIO\PAD</Filter> <Filter>System\Ps2\Iop\SIO\PAD</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="SupportURLs.h" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<CustomBuildStep Include="rdebug\deci2.h"> <CustomBuildStep Include="rdebug\deci2.h">

View File

@ -1,8 +1,24 @@
// Microsoft Visual C++ generated resource script. // Microsoft Visual C++ generated resource script.
// //
#include "../SysForwardDefs.h"
#include "svnrev.h" #include "svnrev.h"
#define STRINGIZE2(s) #s
#define STRINGIZE(s) STRINGIZE2(s)
#define VER_FILE_DESCRIPTION_STR "PCSX2 PS2 Emulator"
#define VER_FILE_VERSION GIT_TAG_HI, GIT_TAG_MID, GIT_TAG_LO, 0
#define VER_FILE_VERSION_STR STRINGIZE(GIT_TAG_HI) \
"." STRINGIZE(GIT_TAG_MID) \
"." STRINGIZE(GIT_TAG_LO) \
"." STRINGIZE(0)
#define VER_PRODUCTNAME_STR "PCSX2"
#define VER_PRODUCT_VERSION VER_FILE_VERSION
#define VER_PRODUCT_VERSION_STR VER_FILE_VERSION_STR
#define VER_ORIGINAL_FILENAME_STR VER_PRODUCTNAME_STR ".exe"
#define VER_INTERNAL_NAME_STR VER_ORIGINAL_FILENAME_STR
#define VER_COPYRIGHT_STR "Copyright (C) 2024"
#define APSTUDIO_READONLY_SYMBOLS #define APSTUDIO_READONLY_SYMBOLS
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// //
@ -52,13 +68,8 @@ END
// //
VS_VERSION_INFO VERSIONINFO VS_VERSION_INFO VERSIONINFO
#if PCSX2_isReleaseVersion == false && GIT_TAGGED_COMMIT && defined(GIT_TAG_HI)
FILEVERSION GIT_TAG_HI, GIT_TAG_MID, GIT_TAG_LO, 0
PRODUCTVERSION GIT_TAG_HI, GIT_TAG_MID, GIT_TAG_LO, 0
#else
FILEVERSION VER_FILE_VERSION FILEVERSION VER_FILE_VERSION
PRODUCTVERSION VER_PRODUCT_VERSION PRODUCTVERSION VER_PRODUCT_VERSION
#endif
FILEFLAGSMASK 0x3fL FILEFLAGSMASK 0x3fL
#ifdef _DEBUG #ifdef _DEBUG
FILEFLAGS 0x1L FILEFLAGS 0x1L