VERY experimental Nintendo Switch 2 emulator
C++
[cmake, frontend] Fix update checker and move to self-hosted Git (#3558)
crueterf4e7fc91ba8d
diff --git a/CMakeModules/GenerateSCMRev.cmake b/CMakeModules/GenerateSCMRev.cmakeindex 678a1bf8ec..5b0adad8dd 100644--- a/CMakeModules/GenerateSCMRev.cmake+++ b/CMakeModules/GenerateSCMRev.cmake@@ -36,14 +36,17 @@ set(GIT_DESC ${BUILD_VERSION})# Also if this is a CI build, add the build name (ie: Nightly, Canary) to the scm_rev file as well# Auto-updater metadata! Must somewhat mirror GitHub API endpoint-set(BUILD_AUTO_UPDATE_WEBSITE "https://github.com")-set(BUILD_AUTO_UPDATE_API "https://api.github.com")-if (NIGHTLY_BUILD)+ set(BUILD_AUTO_UPDATE_WEBSITE "https://github.com")+ set(BUILD_AUTO_UPDATE_API "api.github.com")+ set(BUILD_AUTO_UPDATE_API_PATH "/repos/")set(BUILD_AUTO_UPDATE_REPO "Eden-CI/Nightly")set(REPO_NAME "Eden Nightly")else()- set(BUILD_AUTO_UPDATE_REPO "eden-emulator/Releases")+ set(BUILD_AUTO_UPDATE_WEBSITE "https://git.eden-emu.dev")+ set(BUILD_AUTO_UPDATE_API "git.eden-emu.dev")+ set(BUILD_AUTO_UPDATE_API_PATH "/api/v1/repos/")+ set(BUILD_AUTO_UPDATE_REPO "eden-emu/eden")set(REPO_NAME "Eden")endif()diff --git a/src/common/scm_rev.cpp.in b/src/common/scm_rev.cpp.inindex b3d9455853..cc7b092270 100644--- a/src/common/scm_rev.cpp.in+++ b/src/common/scm_rev.cpp.in@@ -20,6 +20,7 @@#define COMPILER_ID "@CXX_COMPILER@"#define BUILD_AUTO_UPDATE_WEBSITE "@BUILD_AUTO_UPDATE_WEBSITE@"#define BUILD_AUTO_UPDATE_API "@BUILD_AUTO_UPDATE_API@"+#define BUILD_AUTO_UPDATE_API_PATH "@BUILD_AUTO_UPDATE_API_PATH@"#define BUILD_AUTO_UPDATE_REPO "@BUILD_AUTO_UPDATE_REPO@"#define IS_NIGHTLY_BUILD @IS_NIGHTLY_BUILD@@@ -42,6 +43,7 @@ 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_api[] = BUILD_AUTO_UPDATE_API;+constexpr const char g_build_auto_update_api_path[] = BUILD_AUTO_UPDATE_API_PATH;constexpr const char g_build_auto_update_repo[] = BUILD_AUTO_UPDATE_REPO;} // namespace Commondiff --git a/src/common/scm_rev.h b/src/common/scm_rev.hindex 8c4338aaa8..07f941fb93 100644--- a/src/common/scm_rev.h+++ b/src/common/scm_rev.h@@ -26,6 +26,7 @@ extern const bool g_is_nightly_build;extern const char g_build_auto_update_website[];extern const char g_build_auto_update_api[];+extern const char g_build_auto_update_api_path[];extern const char g_build_auto_update_repo[];} // namespace Commondiff --git a/src/frontend_common/CMakeLists.txt b/src/frontend_common/CMakeLists.txtindex 5c248ea337..82993e45b6 100644--- a/src/frontend_common/CMakeLists.txt+++ b/src/frontend_common/CMakeLists.txt@@ -24,7 +24,7 @@ if (ENABLE_UPDATE_CHECKER)update_checker.h)if (ENABLE_OPENSSL)- target_compile_definitions(frontend_common PRIVATE CPPHTTPLIB_OPENSSL_SUPPORT)+ target_compile_definitions(frontend_common PUBLIC CPPHTTPLIB_OPENSSL_SUPPORT)target_link_libraries(frontend_common PRIVATE OpenSSL::SSL OpenSSL::Crypto)endif()diff --git a/src/frontend_common/update_checker.cpp b/src/frontend_common/update_checker.cppindex c12595185a..6b1fde720c 100644--- a/src/frontend_common/update_checker.cpp+++ b/src/frontend_common/update_checker.cpp@@ -82,8 +82,8 @@ std::optional<std::string> UpdateChecker::GetResponse(std::string url, std::stristd::optional<UpdateChecker::Update> UpdateChecker::GetLatestRelease(bool include_prereleases) {const auto update_check_url = std::string{Common::g_build_auto_update_api};- std::string update_check_path = fmt::format("/repos/{}",- std::string{Common::g_build_auto_update_repo});+ auto update_check_path = fmt::format("{}{}", std::string{Common::g_build_auto_update_api_path},+ std::string{Common::g_build_auto_update_repo});try {if (include_prereleases) { // This can return either a prerelease or a stable release,// whichever is more recent.@@ -124,14 +124,14 @@ std::optional<UpdateChecker::Update> UpdateChecker::GetLatestRelease(bool includreturn Update{latest_tag, latest_name};}- } catch (nlohmann::detail::out_of_range &) {+ } catch (nlohmann::detail::out_of_range&) {LOG_ERROR(Frontend,"Parsing JSON response from {}{} failed during update check: ""nlohmann::detail::out_of_range",update_check_url,update_check_path);return {};- } catch (nlohmann::detail::type_error &) {+ } catch (nlohmann::detail::type_error&) {LOG_ERROR(Frontend,"Parsing JSON response from {}{} failed during update check: ""nlohmann::detail::type_error",