mirror of
https://git.eden-emu.dev/eden-emu/eden
synced 2026-02-04 02:51:18 +01:00
[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:
@@ -8,20 +8,26 @@
|
|||||||
include(GetSCMRev)
|
include(GetSCMRev)
|
||||||
|
|
||||||
function(get_timestamp _var)
|
function(get_timestamp _var)
|
||||||
string(TIMESTAMP timestamp UTC)
|
string(TIMESTAMP timestamp UTC)
|
||||||
set(${_var} "${timestamp}" PARENT_SCOPE)
|
set(${_var} "${timestamp}" PARENT_SCOPE)
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
get_timestamp(BUILD_DATE)
|
get_timestamp(BUILD_DATE)
|
||||||
|
|
||||||
if (DEFINED GIT_RELEASE)
|
if (DEFINED GIT_RELEASE)
|
||||||
set(BUILD_VERSION "${GIT_TAG}")
|
set(BUILD_VERSION "${GIT_TAG}")
|
||||||
set(GIT_REFSPEC "${GIT_RELEASE}")
|
set(GIT_REFSPEC "${GIT_RELEASE}")
|
||||||
set(IS_DEV_BUILD false)
|
set(IS_DEV_BUILD false)
|
||||||
else()
|
else()
|
||||||
string(SUBSTRING ${GIT_COMMIT} 0 10 BUILD_VERSION)
|
string(SUBSTRING ${GIT_COMMIT} 0 10 BUILD_VERSION)
|
||||||
set(BUILD_VERSION "${BUILD_VERSION}-${GIT_REFSPEC}")
|
set(BUILD_VERSION "${BUILD_VERSION}-${GIT_REFSPEC}")
|
||||||
set(IS_DEV_BUILD true)
|
set(IS_DEV_BUILD true)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if (NIGHTLY_BUILD)
|
||||||
|
set(IS_NIGHTLY_BUILD true)
|
||||||
|
else()
|
||||||
|
set(IS_NIGHTLY_BUILD false)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(GIT_DESC ${BUILD_VERSION})
|
set(GIT_DESC ${BUILD_VERSION})
|
||||||
@@ -34,11 +40,11 @@ set(BUILD_AUTO_UPDATE_WEBSITE "https://github.com")
|
|||||||
set(BUILD_AUTO_UPDATE_API "http://api.github.com")
|
set(BUILD_AUTO_UPDATE_API "http://api.github.com")
|
||||||
|
|
||||||
if (NIGHTLY_BUILD)
|
if (NIGHTLY_BUILD)
|
||||||
set(BUILD_AUTO_UPDATE_REPO "Eden-CI/Nightly")
|
set(BUILD_AUTO_UPDATE_REPO "Eden-CI/Nightly")
|
||||||
set(REPO_NAME "Eden Nightly")
|
set(REPO_NAME "Eden Nightly")
|
||||||
else()
|
else()
|
||||||
set(BUILD_AUTO_UPDATE_REPO "eden-emulator/Releases")
|
set(BUILD_AUTO_UPDATE_REPO "eden-emulator/Releases")
|
||||||
set(REPO_NAME "Eden")
|
set(REPO_NAME "Eden")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(BUILD_ID ${GIT_REFSPEC})
|
set(BUILD_ID ${GIT_REFSPEC})
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
@@ -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[];
|
||||||
|
|||||||
@@ -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{};
|
||||||
|
|
||||||
|
}
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
Reference in New Issue
Block a user