[frontend] Fix nightly update checker (#3444)

Splitting

Signed-off-by: crueter <crueter@eden-emu.dev>
Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/3444
This commit is contained in:
crueter
2026-02-01 20:38:02 +01:00
parent a5f1c2bcb0
commit 5113f503d1
8 changed files with 82 additions and 43 deletions

View File

@@ -24,6 +24,12 @@ else()
set(IS_DEV_BUILD true) set(IS_DEV_BUILD true)
endif() endif()
if (NIGHTLY_BUILD)
set(IS_NIGHTLY_BUILD true)
else()
set(IS_NIGHTLY_BUILD false)
endif()
set(GIT_DESC ${BUILD_VERSION}) set(GIT_DESC ${BUILD_VERSION})
# Generate cpp with Git revision from template # Generate cpp with Git revision from template

View File

@@ -1615,22 +1615,14 @@ JNIEXPORT jboolean JNICALL Java_org_yuzu_yuzu_1emu_NativeLibrary_isNightlyBuild(
#endif #endif
} }
#ifdef ENABLE_UPDATE_CHECKER #ifdef ENABLE_UPDATE_CHECKER
JNIEXPORT jobjectArray JNICALL Java_org_yuzu_yuzu_1emu_NativeLibrary_checkForUpdate( JNIEXPORT jobjectArray JNICALL Java_org_yuzu_yuzu_1emu_NativeLibrary_checkForUpdate(
JNIEnv* env, JNIEnv* env,
jobject obj) { jobject obj) {
const bool is_prerelease = ((strstr(Common::g_build_version, "pre-alpha") != nullptr) || std::optional<UpdateChecker::Update> release = UpdateChecker::GetUpdate();
(strstr(Common::g_build_version, "alpha") != nullptr) || if (!release) return nullptr;
(strstr(Common::g_build_version, "beta") != nullptr) ||
(strstr(Common::g_build_version, "rc") != nullptr));
const std::optional<UpdateChecker::Update> release =
UpdateChecker::GetLatestRelease(is_prerelease);
if (!release || release->tag == Common::g_build_version) {
return nullptr;
}
const std::string tag = release->tag; const std::string tag = release->tag;
const std::string name = release->name; const std::string name = release->name;

View File

@@ -21,6 +21,7 @@
#define BUILD_AUTO_UPDATE_WEBSITE "@BUILD_AUTO_UPDATE_WEBSITE@" #define BUILD_AUTO_UPDATE_WEBSITE "@BUILD_AUTO_UPDATE_WEBSITE@"
#define BUILD_AUTO_UPDATE_API "@BUILD_AUTO_UPDATE_API@" #define BUILD_AUTO_UPDATE_API "@BUILD_AUTO_UPDATE_API@"
#define BUILD_AUTO_UPDATE_REPO "@BUILD_AUTO_UPDATE_REPO@" #define BUILD_AUTO_UPDATE_REPO "@BUILD_AUTO_UPDATE_REPO@"
#define IS_NIGHTLY_BUILD @IS_NIGHTLY_BUILD@
namespace Common { namespace Common {
@@ -35,7 +36,9 @@ constexpr const char g_build_id[] = BUILD_ID;
constexpr const char g_title_bar_format_idle[] = TITLE_BAR_FORMAT_IDLE; constexpr const char g_title_bar_format_idle[] = TITLE_BAR_FORMAT_IDLE;
constexpr const char g_title_bar_format_running[] = TITLE_BAR_FORMAT_RUNNING; constexpr const char g_title_bar_format_running[] = TITLE_BAR_FORMAT_RUNNING;
constexpr const char g_compiler_id[] = COMPILER_ID; constexpr const char g_compiler_id[] = COMPILER_ID;
constexpr const bool g_is_dev_build = IS_DEV_BUILD; constexpr const bool g_is_dev_build = IS_DEV_BUILD;
constexpr const bool g_is_nightly_build = IS_NIGHTLY_BUILD;
constexpr const char g_build_auto_update_website[] = BUILD_AUTO_UPDATE_WEBSITE; constexpr const char g_build_auto_update_website[] = BUILD_AUTO_UPDATE_WEBSITE;
constexpr const char g_build_auto_update_api[] = BUILD_AUTO_UPDATE_API; constexpr const char g_build_auto_update_api[] = BUILD_AUTO_UPDATE_API;

View File

@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project // SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
// SPDX-License-Identifier: GPL-3.0-or-later // SPDX-License-Identifier: GPL-3.0-or-later
// SPDX-FileCopyrightText: 2014 Citra Emulator Project // SPDX-FileCopyrightText: 2014 Citra Emulator Project
@@ -20,7 +20,10 @@ extern const char g_title_bar_format_idle[];
extern const char g_title_bar_format_running[]; extern const char g_title_bar_format_running[];
extern const char g_shader_cache_version[]; extern const char g_shader_cache_version[];
extern const char g_compiler_id[]; extern const char g_compiler_id[];
extern const bool g_is_dev_build; extern const bool g_is_dev_build;
extern const bool g_is_nightly_build;
extern const char g_build_auto_update_website[]; extern const char g_build_auto_update_website[];
extern const char g_build_auto_update_api[]; extern const char g_build_auto_update_api[];
extern const char g_build_auto_update_repo[]; extern const char g_build_auto_update_repo[];

View File

@@ -5,10 +5,13 @@
// Licensed under GPLv2 or any later version // Licensed under GPLv2 or any later version
// Refer to the license.txt file included. // Refer to the license.txt file included.
#include "update_checker.h" #include <boost/algorithm/string/classification.hpp>
#include <boost/algorithm/string/split.hpp>
#include <fmt/format.h>
#include "common/logging/log.h" #include "common/logging/log.h"
#include "common/scm_rev.h" #include "common/scm_rev.h"
#include <fmt/format.h> #include "update_checker.h"
#include <httplib.h> #include <httplib.h>
@@ -137,3 +140,42 @@ std::optional<UpdateChecker::Update> UpdateChecker::GetLatestRelease(bool includ
return {}; return {};
} }
} }
std::optional<UpdateChecker::Update> UpdateChecker::GetUpdate() {
const bool is_prerelease = ((strstr(Common::g_build_version, "pre-alpha") != NULL) ||
(strstr(Common::g_build_version, "alpha") != NULL) ||
(strstr(Common::g_build_version, "beta") != NULL) ||
(strstr(Common::g_build_version, "rc") != NULL));
const std::optional<UpdateChecker::Update> latest_release_tag =
UpdateChecker::GetLatestRelease(is_prerelease);
if (!latest_release_tag)
goto empty;
{
std::string tag, build;
if (Common::g_is_nightly_build) {
std::vector<std::string> result;
boost::split(result, latest_release_tag->tag, boost::is_any_of("."));
if (result.size() != 2)
goto empty;
tag = result[1];
boost::split(result, std::string{Common::g_build_version}, boost::is_any_of("-"));
if (result.empty())
goto empty;
build = result[0];
} else {
tag = latest_release_tag->tag;
build = Common::g_build_version;
}
if (tag != build)
return latest_release_tag.value();
}
empty:
return UpdateChecker::Update{};
}

View File

@@ -19,4 +19,5 @@ typedef struct {
std::optional<std::string> GetResponse(std::string url, std::string path); std::optional<std::string> GetResponse(std::string url, std::string path);
std::optional<Update> GetLatestRelease(bool include_prereleases); std::optional<Update> GetLatestRelease(bool include_prereleases);
std::optional<Update> GetUpdate();
} // namespace UpdateChecker } // namespace UpdateChecker

View File

@@ -2,6 +2,7 @@
// SPDX-License-Identifier: GPL-3.0-or-later // SPDX-License-Identifier: GPL-3.0-or-later
// Qt on macOS doesn't define VMA shit // Qt on macOS doesn't define VMA shit
#include <boost/algorithm/string/split.hpp>
#include "qt_common/qt_string_lookup.h" #include "qt_common/qt_string_lookup.h"
#if defined(QT_STATICPLUGIN) && !defined(__APPLE__) #if defined(QT_STATICPLUGIN) && !defined(__APPLE__)
#undef VMA_IMPLEMENTATION #undef VMA_IMPLEMENTATION
@@ -516,17 +517,8 @@ MainWindow::MainWindow(bool has_broken_vulkan)
#ifdef ENABLE_UPDATE_CHECKER #ifdef ENABLE_UPDATE_CHECKER
if (UISettings::values.check_for_updates) { if (UISettings::values.check_for_updates) {
update_future = QtConcurrent::run([]() -> UpdateChecker::Update { update_future = QtConcurrent::run([]() -> std::optional<UpdateChecker::Update> {
const bool is_prerelease = ((strstr(Common::g_build_version, "pre-alpha") != NULL) || return UpdateChecker::GetUpdate();
(strstr(Common::g_build_version, "alpha") != NULL) ||
(strstr(Common::g_build_version, "beta") != NULL) ||
(strstr(Common::g_build_version, "rc") != NULL));
const std::optional<UpdateChecker::Update> latest_release_tag =
UpdateChecker::GetLatestRelease(is_prerelease);
if (latest_release_tag && latest_release_tag->tag != Common::g_build_version) {
return latest_release_tag.value();
}
return UpdateChecker::Update{};
}); });
update_watcher.connect(&update_watcher, &QFutureWatcher<QString>::finished, this, update_watcher.connect(&update_watcher, &QFutureWatcher<QString>::finished, this,
&MainWindow::OnEmulatorUpdateAvailable); &MainWindow::OnEmulatorUpdateAvailable);
@@ -4020,8 +4012,8 @@ void MainWindow::OnCaptureScreenshot() {
#ifdef ENABLE_UPDATE_CHECKER #ifdef ENABLE_UPDATE_CHECKER
void MainWindow::OnEmulatorUpdateAvailable() { void MainWindow::OnEmulatorUpdateAvailable() {
UpdateChecker::Update version = update_future.result(); std::optional<UpdateChecker::Update> version = update_future.result();
if (version.tag.empty()) if (!version)
return; return;
QMessageBox update_prompt(this); QMessageBox update_prompt(this);
@@ -4030,14 +4022,14 @@ void MainWindow::OnEmulatorUpdateAvailable() {
update_prompt.addButton(QMessageBox::Yes); update_prompt.addButton(QMessageBox::Yes);
update_prompt.addButton(QMessageBox::Ignore); update_prompt.addButton(QMessageBox::Ignore);
update_prompt.setText( update_prompt.setText(
tr("Download %1?").arg(QString::fromStdString(version.name))); tr("Download %1?").arg(QString::fromStdString(version->name)));
update_prompt.exec(); update_prompt.exec();
if (update_prompt.button(QMessageBox::Yes) == update_prompt.clickedButton()) { if (update_prompt.button(QMessageBox::Yes) == update_prompt.clickedButton()) {
auto const full_url = fmt::format("{}/{}/releases/tag/", auto const full_url = fmt::format("{}/{}/releases/tag/",
std::string{Common::g_build_auto_update_website}, std::string{Common::g_build_auto_update_website},
std::string{Common::g_build_auto_update_repo} std::string{Common::g_build_auto_update_repo}
); );
QDesktopServices::openUrl(QUrl(QString::fromStdString(full_url + version.tag))); QDesktopServices::openUrl(QUrl(QString::fromStdString(full_url + version->tag)));
} }
} }
#endif #endif

View File

@@ -472,8 +472,8 @@ private:
std::shared_ptr<InputCommon::InputSubsystem> input_subsystem; std::shared_ptr<InputCommon::InputSubsystem> input_subsystem;
#ifdef ENABLE_UPDATE_CHECKER #ifdef ENABLE_UPDATE_CHECKER
QFuture<UpdateChecker::Update> update_future; QFuture<std::optional<UpdateChecker::Update>> update_future;
QFutureWatcher<UpdateChecker::Update> update_watcher; QFutureWatcher<std::optional<UpdateChecker::Update>> update_watcher;
#endif #endif
MultiplayerState* multiplayer_state = nullptr; MultiplayerState* multiplayer_state = nullptr;