Misc: Minimise the amount of work done when svnrev.h is updated
Some checks failed
🐧 Linux Builds / AppImage (push) Has been cancelled
🐧 Linux Builds / Flatpak (push) Has been cancelled
🍎 MacOS Builds / Defaults (push) Has been cancelled
🖥️ Windows Builds / Lint VS Project Files (push) Has been cancelled
🖥️ Windows Builds / CMake (push) Has been cancelled
🖥️ Windows Builds / SSE4 (push) Has been cancelled
🖥️ Windows Builds / AVX2 (push) Has been cancelled
🌎 Update Base Translation / Update Base Translation (push) Has been cancelled
📦 Publish Flathub Release / Check if release is needed (push) Has been cancelled
📦 Publish Flathub Release / Build and publish Flatpak (push) Has been cancelled

This commit is contained in:
chaoticgd 2024-11-08 22:08:01 +00:00 committed by Ty
parent 959be142ed
commit eeb919325e
19 changed files with 121 additions and 90 deletions

View File

@ -7,8 +7,8 @@
#include "QtProgressCallback.h"
#include "QtUtils.h"
#include "pcsx2/BuildVersion.h"
#include "pcsx2/Host.h"
#include "svnrev.h"
#include "updater/UpdaterExtractor.h"
@ -47,12 +47,6 @@
// Interval at which HTTP requests are polled.
static constexpr u32 HTTP_POLL_INTERVAL = 10;
// Logic to detect whether we can use the auto updater.
// We use tagged commit, because this gets set on nightly builds.
#if (defined(_WIN32) || defined(__linux__) || defined(__APPLE__)) && GIT_TAGGED_COMMIT
#define AUTO_UPDATER_SUPPORTED 1
#if defined(_WIN32)
#define UPDATE_PLATFORM_STR "Windows"
#elif defined(__linux__)
@ -69,10 +63,6 @@ static constexpr u32 HTTP_POLL_INTERVAL = 10;
#define UPDATE_ADDITIONAL_TAGS "SSE4"
#endif
#endif
#ifdef AUTO_UPDATER_SUPPORTED
#define LATEST_RELEASE_URL "https://api.pcsx2.net/v1/%1Releases?pageSize=1"
#define CHANGES_URL "https://api.github.com/repos/PCSX2/pcsx2/compare/%1...%2"
@ -87,8 +77,6 @@ static const char* UPDATE_TAGS[] = {"stable", "nightly"};
#define DEFAULT_UPDATER_CHANNEL "nightly"
#endif
#endif
AutoUpdaterDialog::AutoUpdaterDialog(QWidget* parent /* = nullptr */)
: QDialog(parent)
{
@ -109,7 +97,11 @@ AutoUpdaterDialog::~AutoUpdaterDialog() = default;
bool AutoUpdaterDialog::isSupported()
{
#ifdef AUTO_UPDATER_SUPPORTED
// Logic to detect whether we can use the auto updater.
// We use tagged commit, because this gets set on nightly builds.
if (!BuildVersion::GitTaggedCommit)
return false;
#ifdef __linux__
// For Linux, we need to check whether we're running from the appimage.
if (!std::getenv("APPIMAGE"))
@ -119,10 +111,9 @@ bool AutoUpdaterDialog::isSupported()
}
return true;
#else
#elif defined(_WIN32) || defined(__APPLE__)
// Windows, MacOS - always supported.
return true;
#endif
#else
return false;
#endif
@ -130,39 +121,36 @@ bool AutoUpdaterDialog::isSupported()
QStringList AutoUpdaterDialog::getTagList()
{
#ifdef AUTO_UPDATER_SUPPORTED
if (!isSupported())
return QStringList();
return QStringList(std::begin(UPDATE_TAGS), std::end(UPDATE_TAGS));
#else
return QStringList();
#endif
}
std::string AutoUpdaterDialog::getDefaultTag()
{
#ifdef AUTO_UPDATER_SUPPORTED
if (!isSupported())
return {};
return DEFAULT_UPDATER_CHANNEL;
#else
return {};
#endif
}
QString AutoUpdaterDialog::getCurrentVersion()
{
return QStringLiteral(GIT_TAG);
return QString(BuildVersion::GitTag);
}
QString AutoUpdaterDialog::getCurrentVersionDate()
{
return QStringLiteral(GIT_DATE);
return QString(BuildVersion::GitDate);
}
QString AutoUpdaterDialog::getCurrentUpdateTag() const
{
#ifdef AUTO_UPDATER_SUPPORTED
if (!isSupported())
return QString();
return QString::fromStdString(Host::GetBaseStringSettingValue("AutoUpdater", "UpdateTag", DEFAULT_UPDATER_CHANNEL));
#else
return QString();
#endif
}
void AutoUpdaterDialog::reportError(const char* msg, ...)
@ -215,18 +203,21 @@ void AutoUpdaterDialog::queueUpdateCheck(bool display_message)
{
m_display_messages = display_message;
#ifdef AUTO_UPDATER_SUPPORTED
if (!ensureHttpReady())
if (isSupported())
{
if (!ensureHttpReady())
{
emit updateCheckCompleted();
return;
}
m_http->CreateRequest(QStringLiteral(LATEST_RELEASE_URL).arg(getCurrentUpdateTag()).toStdString(),
std::bind(&AutoUpdaterDialog::getLatestReleaseComplete, this, std::placeholders::_1, std::placeholders::_3));
}
else
{
emit updateCheckCompleted();
return;
}
m_http->CreateRequest(QStringLiteral(LATEST_RELEASE_URL).arg(getCurrentUpdateTag()).toStdString(),
std::bind(&AutoUpdaterDialog::getLatestReleaseComplete, this, std::placeholders::_1, std::placeholders::_3));
#else
emit updateCheckCompleted();
#endif
}
void AutoUpdaterDialog::getLatestReleaseComplete(s32 status_code, std::vector<u8> data)
@ -236,7 +227,9 @@ void AutoUpdaterDialog::getLatestReleaseComplete(s32 status_code, std::vector<u8
cpuinfo_initialize();
#endif
#ifdef AUTO_UPDATER_SUPPORTED
if (!isSupported())
return;
bool found_update_info = false;
if (status_code == HTTPDownloader::HTTP_STATUS_OK)
@ -373,23 +366,25 @@ void AutoUpdaterDialog::getLatestReleaseComplete(s32 status_code, std::vector<u8
checkIfUpdateNeeded();
emit updateCheckCompleted();
#endif
}
void AutoUpdaterDialog::queueGetChanges()
{
#ifdef AUTO_UPDATER_SUPPORTED
if (!ensureHttpReady())
if (!isSupported() || !ensureHttpReady())
return;
m_http->CreateRequest(QStringLiteral(CHANGES_URL).arg(GIT_HASH).arg(m_latest_version).toStdString(),
m_http->CreateRequest(QStringLiteral(CHANGES_URL).arg(BuildVersion::GitHash).arg(m_latest_version).toStdString(),
std::bind(&AutoUpdaterDialog::getChangesComplete, this, std::placeholders::_1, std::placeholders::_3));
#endif
}
void AutoUpdaterDialog::getChangesComplete(s32 status_code, std::vector<u8> data)
{
#ifdef AUTO_UPDATER_SUPPORTED
if (!isSupported())
{
m_ui.downloadAndInstall->setEnabled(true);
return;
}
if (status_code == HTTPDownloader::HTTP_STATUS_OK)
{
QJsonParseError parse_error;
@ -456,7 +451,6 @@ void AutoUpdaterDialog::getChangesComplete(s32 status_code, std::vector<u8> data
{
reportError("Failed to download change list: %d", status_code);
}
#endif
m_ui.downloadAndInstall->setEnabled(true);
}
@ -542,10 +536,10 @@ void AutoUpdaterDialog::checkIfUpdateNeeded()
const QString last_checked_version(
QString::fromStdString(Host::GetBaseStringSettingValue("AutoUpdater", "LastVersion")));
Console.WriteLn(Color_StrongGreen, "Current version: %s", GIT_TAG);
Console.WriteLn(Color_StrongGreen, "Current version: %s", BuildVersion::GitTag);
Console.WriteLn(Color_StrongYellow, "Latest version: %s", m_latest_version.toUtf8().constData());
Console.WriteLn(Color_StrongOrange, "Last checked version: %s", last_checked_version.toUtf8().constData());
if (m_latest_version == GIT_TAG || m_latest_version == last_checked_version)
if (m_latest_version == BuildVersion::GitTag || m_latest_version == last_checked_version)
{
Console.WriteLn(Color_StrongGreen, "No update needed.");
@ -787,7 +781,7 @@ void AutoUpdaterDialog::cleanupAfterUpdate()
static QString UpdateVersionNumberInName(QString name, QStringView new_version)
{
QString current_version_string = QStringLiteral(GIT_TAG);
QString current_version_string(BuildVersion::GitTag);
QStringView current_version = current_version_string;
if (!current_version.empty() && !new_version.empty() && current_version[0] == 'v' && new_version[0] == 'v')
{

View File

@ -19,7 +19,6 @@
#include "Settings/MemoryCardCreateDialog.h"
#include "Tools/InputRecording/InputRecordingViewer.h"
#include "Tools/InputRecording/NewInputRecordingDlg.h"
#include "svnrev.h"
#include "pcsx2/Achievements.h"
#include "pcsx2/CDVD/CDVDcommon.h"

View File

@ -10,10 +10,10 @@
#include "QtProgressCallback.h"
#include "QtUtils.h"
#include "SetupWizardDialog.h"
#include "svnrev.h"
#include "pcsx2/CDVD/CDVDcommon.h"
#include "pcsx2/Achievements.h"
#include "pcsx2/BuildVersion.h"
#include "pcsx2/CDVD/CDVD.h"
#include "pcsx2/Counters.h"
#include "pcsx2/DebugTools/Debug.h"
@ -1468,7 +1468,7 @@ bool Host::RequestResetSettings(bool folders, bool core, bool controllers, bool
QString QtHost::GetAppNameAndVersion()
{
return QStringLiteral("PCSX2 " GIT_REV);
return QString("PCSX2 %1").arg(BuildVersion::GitRev);
}
QString QtHost::GetAppConfigSuffix()

View File

@ -4,6 +4,7 @@
#define IMGUI_DEFINE_MATH_OPERATORS
#include "Achievements.h"
#include "BuildVersion.h"
#include "CDVD/CDVD.h"
#include "Elfheader.h"
#include "Host.h"
@ -16,7 +17,6 @@
#include "Memory.h"
#include "SaveState.h"
#include "VMManager.h"
#include "svnrev.h"
#include "vtlb.h"
#include "common/Assertions.h"
@ -3039,7 +3039,7 @@ void Achievements::SwitchToRAIntegration()
void Achievements::RAIntegration::InitializeRAIntegration(void* main_window_handle)
{
RA_InitClient((HWND)main_window_handle, "PCSX2", GIT_TAG);
RA_InitClient((HWND)main_window_handle, "PCSX2", BuildVersion::GitTag);
RA_SetUserAgentDetail(Host::GetHTTPUserAgent().c_str());
RA_InstallSharedFunctions(RACallbackIsActive, RACallbackCauseUnpause, RACallbackCausePause, RACallbackRebuildMenu,

16
pcsx2/BuildVersion.cpp Normal file
View File

@ -0,0 +1,16 @@
// SPDX-FileCopyrightText: 2002-2024 PCSX2 Dev Team
// SPDX-License-Identifier: GPL-3.0+
#include "svnrev.h"
namespace BuildVersion
{
const char* GitTag = GIT_TAG;
bool GitTaggedCommit = GIT_TAGGED_COMMIT;
int GitTagHi = GIT_TAG_HI;
int GitTagMid = GIT_TAG_MID;
int GitTagLo = GIT_TAG_LO;
const char* GitRev = GIT_REV;
const char* GitHash = GIT_HASH;
const char* GitDate = GIT_DATE;
} // namespace BuildVersion

18
pcsx2/BuildVersion.h Normal file
View File

@ -0,0 +1,18 @@
// SPDX-FileCopyrightText: 2002-2024 PCSX2 Dev Team
// SPDX-License-Identifier: GPL-3.0+
#pragma once
// This file provides the same information as svnrev.h except you don't need to
// recompile each object file using it when said information is updated.
namespace BuildVersion
{
extern const char* GitTag;
extern bool GitTaggedCommit;
extern int GitTagHi;
extern int GitTagMid;
extern int GitTagLo;
extern const char* GitRev;
extern const char* GitHash;
extern const char* GitDate;
} // namespace BuildVersion

View File

@ -54,6 +54,7 @@ endif(WIN32)
# Main pcsx2 source
set(pcsx2Sources
Achievements.cpp
BuildVersion.cpp
Cache.cpp
COP0.cpp
COP2.cpp
@ -140,6 +141,7 @@ set(pcsx2Sources
# Main pcsx2 header
set(pcsx2Headers
Achievements.h
BuildVersion.h
Cache.h
Common.h
Config.h

View File

@ -10,6 +10,7 @@
#include "GS/Renderers/Vulkan/VKShaderCache.h"
#include "GS/Renderers/Vulkan/VKSwapChain.h"
#include "BuildVersion.h"
#include "Host.h"
#include "common/Console.h"
@ -103,16 +104,15 @@ VkInstance GSDeviceVK::CreateVulkanInstance(const WindowInfo& wi, OptionalExtens
if (!SelectInstanceExtensions(&enabled_extensions, wi, oe, enable_debug_utils))
return VK_NULL_HANDLE;
// Remember to manually update this every release. We don't pull in svnrev.h here, because
// it's only the major/minor version, and rebuilding the file every time something else changes
// is unnecessary.
VkApplicationInfo app_info = {};
app_info.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO;
app_info.pNext = nullptr;
app_info.pApplicationName = "PCSX2";
app_info.applicationVersion = VK_MAKE_VERSION(1, 7, 0);
app_info.applicationVersion = VK_MAKE_VERSION(
BuildVersion::GitTagHi, BuildVersion::GitTagMid, BuildVersion::GitTagLo);
app_info.pEngineName = "PCSX2";
app_info.engineVersion = VK_MAKE_VERSION(1, 7, 0);
app_info.engineVersion = VK_MAKE_VERSION(
BuildVersion::GitTagHi, BuildVersion::GitTagMid, BuildVersion::GitTagLo);
app_info.apiVersion = VK_API_VERSION_1_1;
VkInstanceCreateInfo instance_create_info = {};

View File

@ -1,12 +1,12 @@
// SPDX-FileCopyrightText: 2002-2024 PCSX2 Dev Team
// SPDX-License-Identifier: GPL-3.0+
#include "BuildVersion.h"
#include "GS.h"
#include "GS/Renderers/HW/GSTextureReplacements.h"
#include "Host.h"
#include "LayeredSettingsInterface.h"
#include "VMManager.h"
#include "svnrev.h"
#include "common/Assertions.h"
#include "common/CrashHandler.h"
@ -159,7 +159,7 @@ bool Host::ConfirmFormattedMessage(const std::string_view title, const char* for
std::string Host::GetHTTPUserAgent()
{
return fmt::format("PCSX2 " GIT_REV " ({})", GetOSVersionString());
return fmt::format("PCSX2 {} ({})", BuildVersion::GitRev, GetOSVersionString());
}
std::unique_lock<std::mutex> Host::GetSettingsLock()

View File

@ -3,6 +3,7 @@
#define IMGUI_DEFINE_MATH_OPERATORS
#include "BuildVersion.h"
#include "CDVD/CDVDcommon.h"
#include "GS/Renderers/Common/GSDevice.h"
#include "GS/Renderers/Common/GSTexture.h"
@ -23,7 +24,6 @@
#include "USB/USB.h"
#include "VMManager.h"
#include "ps2/BiosTools.h"
#include "svnrev.h"
#include "common/Console.h"
#include "common/Error.h"
@ -6633,7 +6633,7 @@ void FullscreenUI::DrawAboutWindow()
"This allows you to play PS2 games on your PC, with many additional features and benefits."));
ImGui::NewLine();
ImGui::TextWrapped(FSUI_CSTR("Version: %s"), GIT_REV);
ImGui::TextWrapped(FSUI_CSTR("Version: %s"), BuildVersion::GitRev);
ImGui::NewLine();
ImGui::TextWrapped("%s",

View File

@ -1,6 +1,7 @@
// SPDX-FileCopyrightText: 2002-2024 PCSX2 Dev Team
// SPDX-License-Identifier: GPL-3.0+
#include "BuildVersion.h"
#include "Config.h"
#include "Counters.h"
#include "GS.h"
@ -24,7 +25,6 @@
#include "SIO/Pad/PadBase.h"
#include "USB/USB.h"
#include "VMManager.h"
#include "svnrev.h"
#include "cpuinfo.h"
#include "common/BitUtils.h"
@ -170,7 +170,7 @@ __ri void ImGuiManager::DrawPerformanceOverlay(float& position_y, float scale, f
if (GSConfig.OsdShowVersion)
{
text.append_format("{}PCSX2 {}", first ? "" : " | ", GIT_REV);
text.append_format("{}PCSX2 {}", first ? "" : " | ", BuildVersion::GitRev);
}
if (!text.empty())

View File

@ -1,13 +1,13 @@
// SPDX-FileCopyrightText: 2002-2024 PCSX2 Dev Team
// SPDX-License-Identifier: GPL-3.0+
#include "BuildVersion.h"
#include "Common.h"
#include "Host.h"
#include "Memory.h"
#include "Elfheader.h"
#include "PINE.h"
#include "VMManager.h"
#include "svnrev.h"
#include <atomic>
#include <cstdio>
@ -607,14 +607,12 @@ PINEServer::IPCBuffer PINEServer::ParseCommand(std::span<u8> buf, std::vector<u8
{
if (!VMManager::HasValidVM())
goto error;
static constexpr const char* version = "PCSX2 " GIT_REV;
static constexpr u32 size = sizeof(version) + 1;
u32 size = strlen(BuildVersion::GitRev) + 7;
if (!SafetyChecks(buf_cnt, 0, ret_cnt, size + 4, buf_size)) [[unlikely]]
goto error;
ToResultVector(ret_buffer, size, ret_cnt);
ret_cnt += 4;
memcpy(&ret_buffer[ret_cnt], version, size);
snprintf(reinterpret_cast<char*>(&ret_buffer[ret_cnt]), size, "PCSX2 %s", BuildVersion::GitRev);
ret_cnt += size;
break;
}

View File

@ -3,13 +3,10 @@
#include "InputRecordingFile.h"
#include "BuildVersion.h"
#include "Utilities/InputRecordingLogger.h"
#include "common/FileSystem.h"
#include "common/StringUtil.h"
#include "DebugTools/Debug.h"
#include "MemoryTypes.h"
#include "svnrev.h"
#include <fmt/format.h>
@ -23,7 +20,7 @@ void InputRecordingFile::InputRecordingFileHeader::init() noexcept
void InputRecordingFile::setEmulatorVersion()
{
StringUtil::Strlcpy(m_header.m_emulatorVersion, "PCSX2-" GIT_REV, sizeof(m_header.m_emulatorVersion));
snprintf(m_header.m_emulatorVersion, sizeof(m_header.m_emulatorVersion), "PCSX2-%s", BuildVersion::GitRev);
}
void InputRecordingFile::setAuthor(const std::string& _author)

View File

@ -20,8 +20,6 @@
#include "Host.h"
#include "IconsPromptFont.h"
#include "svnrev.h"
#include "fmt/core.h"
#include <map>
@ -1075,4 +1073,4 @@ bool FileMcd_DeleteCard(const std::string_view name)
}
return true;
}
}

View File

@ -21,8 +21,6 @@
#include "ryml_std.hpp"
#include "ryml.hpp"
#include "svnrev.h"
#include <sstream>
#include <mutex>
#include <optional>
@ -2380,4 +2378,4 @@ bool FolderMemoryCardAggregator::ReIndex(uint slot, const bool enableFiltering,
SetFiltering(enableFiltering);
m_lastKnownFilter = filter;
return false;
}
}

View File

@ -2,6 +2,7 @@
// SPDX-License-Identifier: GPL-3.0+
#include "Achievements.h"
#include "BuildVersion.h"
#include "CDVD/CDVD.h"
#include "COP0.h"
#include "Cache.h"
@ -27,7 +28,6 @@
#include "VMManager.h"
#include "VUmicro.h"
#include "ps2/BiosTools.h"
#include "svnrev.h"
#include "common/Error.h"
#include "common/FileSystem.h"
@ -972,11 +972,14 @@ static bool SaveState_AddToZip(zip_t* zf, ArchiveEntryList* srclist, SaveStateSc
VersionIndicator* vi = static_cast<VersionIndicator*>(std::malloc(sizeof(VersionIndicator)));
vi->save_version = g_SaveVersion;
#if GIT_TAGGED_COMMIT
StringUtil::Strlcpy(vi->version, GIT_TAG, std::size(vi->version));
#else
StringUtil::Strlcpy(vi->version, "Unknown", std::size(vi->version));
#endif
if (BuildVersion::GitTaggedCommit)
{
StringUtil::Strlcpy(vi->version, BuildVersion::GitTag, std::size(vi->version));
}
else
{
StringUtil::Strlcpy(vi->version, "Unknown", std::size(vi->version));
}
zip_source_t* const zs = zip_source_buffer(zf, vi, sizeof(*vi), 1);
if (!zs)

View File

@ -2,6 +2,7 @@
// SPDX-License-Identifier: GPL-3.0+
#include "Achievements.h"
#include "BuildVersion.h"
#include "CDVD/CDVD.h"
#include "CDVD/IsoReader.h"
#include "Counters.h"
@ -40,7 +41,6 @@
#include "Vif_Dynarec.h"
#include "VMManager.h"
#include "ps2/BiosTools.h"
#include "svnrev.h"
#include "common/Console.h"
#include "common/Error.h"
@ -2490,7 +2490,7 @@ void LogGPUCapabilities()
void VMManager::LogCPUCapabilities()
{
Console.WriteLn(Color_StrongGreen, "PCSX2 " GIT_REV);
Console.WriteLn(Color_StrongGreen, "PCSX2 %s", BuildVersion::GitRev);
Console.WriteLnFmt("Savestate version: 0x{:x}\n", g_SaveVersion);
Console.WriteLn();

View File

@ -419,6 +419,7 @@
<ExcludedFromBuild Condition="'$(Platform)'!='x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="ps2\BiosTools.cpp" />
<ClCompile Include="BuildVersion.cpp" />
<ClCompile Include="Counters.cpp" />
<ClCompile Include="FiFo.cpp" />
<ClCompile Include="Hw.cpp" />
@ -865,6 +866,7 @@
<ClInclude Include="Elfheader.h" />
<ClInclude Include="CDVD\IsoFileFormats.h" />
<ClInclude Include="resource.h" />
<ClInclude Include="BuildVersion.h" />
<ClInclude Include="Common.h" />
<ClInclude Include="Config.h" />
<ClInclude Include="SaveState.h" />

View File

@ -1292,6 +1292,9 @@
<ClCompile Include="Pcsx2Config.cpp">
<Filter>Misc</Filter>
</ClCompile>
<ClCompile Include="BuildVersion.cpp">
<Filter>Misc</Filter>
</ClCompile>
<ClCompile Include="Counters.cpp">
<Filter>System\Ps2\EmotionEngine\Hardware</Filter>
</ClCompile>
@ -2244,6 +2247,9 @@
<ClInclude Include="ps2\pgif.h">
<Filter>System\Ps2\Iop</Filter>
</ClInclude>
<ClInclude Include="BuildVersion.h">
<Filter>Misc</Filter>
</ClInclude>
<ClInclude Include="Counters.h">
<Filter>System\Ps2\EmotionEngine\Hardware</Filter>
</ClInclude>