From 92de4aee3c08e5583a059ce5e38fa6806d4a7b11 Mon Sep 17 00:00:00 2001 From: crueter Date: Sun, 7 Sep 2025 19:39:35 -0400 Subject: [PATCH] [cmake] fix breakpad fetching Signed-off-by: crueter --- CMakeLists.txt | 21 +++++++++++---------- CMakeModules/CPMUtil.cmake | 15 +++++++++++++++ externals/CMakeLists.txt | 17 ++++++----------- externals/cpmfile.json | 9 +++++++++ src/yuzu/CMakeLists.txt | 1 + src/yuzu/breakpad.cpp | 14 +------------- src/yuzu/breakpad.h | 15 +++++++++++++++ src/yuzu/main.cpp | 14 ++++++++------ 8 files changed, 66 insertions(+), 40 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 00dd5237be..4e68b920a3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -108,7 +108,7 @@ CMAKE_DEPENDENT_OPTION(YUZU_ROOM_STANDALONE "Enable standalone room executable" CMAKE_DEPENDENT_OPTION(YUZU_CMD "Compile the eden-cli executable" ON "ENABLE_SDL2;NOT ANDROID" OFF) -CMAKE_DEPENDENT_OPTION(YUZU_CRASH_DUMPS "Compile crash dump (Minidump) support" OFF "WIN32 OR LINUX" OFF) +CMAKE_DEPENDENT_OPTION(YUZU_CRASH_DUMPS "Compile crash dump (Minidump) support" OFF "WIN32 OR PLATFORM_LINUX OR PLATFORM_SUN" OFF) option(YUZU_ENABLE_LTO "Enable link-time optimization" OFF) @@ -658,17 +658,18 @@ if(ENABLE_QT) set_target_properties(Qt6::Platform PROPERTIES INTERFACE_COMPILE_FEATURES "") endif() -if (YUZU_CRASH_DUMPS) - set(BREAKPAD_VER "breakpad-c89f9dd") - download_bundled_external("breakpad/" ${BREAKPAD_VER} "breakpad-win" BREAKPAD_PREFIX "c89f9dd") +# TODO: test on windows +# if (YUZU_CRASH_DUMPS) +# set(BREAKPAD_VER "breakpad-c89f9dd") +# download_bundled_external("breakpad/" ${BREAKPAD_VER} "breakpad-win" BREAKPAD_PREFIX "c89f9dd") - set(BREAKPAD_CLIENT_INCLUDE_DIR "${BREAKPAD_PREFIX}/include") - set(BREAKPAD_CLIENT_LIBRARY "${BREAKPAD_PREFIX}/lib/libbreakpad_client.lib") +# set(BREAKPAD_CLIENT_INCLUDE_DIR "${BREAKPAD_PREFIX}/include") +# set(BREAKPAD_CLIENT_LIBRARY "${BREAKPAD_PREFIX}/lib/libbreakpad_client.lib") - add_library(libbreakpad_client INTERFACE IMPORTED) - target_link_libraries(libbreakpad_client INTERFACE "${BREAKPAD_CLIENT_LIBRARY}") - target_include_directories(libbreakpad_client INTERFACE "${BREAKPAD_CLIENT_INCLUDE_DIR}") -endif() +# add_library(libbreakpad_client INTERFACE IMPORTED) +# target_link_libraries(libbreakpad_client INTERFACE "${BREAKPAD_CLIENT_LIBRARY}") +# target_include_directories(libbreakpad_client INTERFACE "${BREAKPAD_CLIENT_INCLUDE_DIR}") +# endif() # Prefer the -pthread flag on Linux. set(THREADS_PREFER_PTHREAD_FLAG ON) diff --git a/CMakeModules/CPMUtil.cmake b/CMakeModules/CPMUtil.cmake index 0fa37b9765..63d26c59de 100644 --- a/CMakeModules/CPMUtil.cmake +++ b/CMakeModules/CPMUtil.cmake @@ -152,6 +152,7 @@ function(AddJsonPackage) get_json_element("${object}" git_host git_host "") get_json_element("${object}" source_subdir source_subdir "") get_json_element("${object}" bundled bundled "unset") + get_json_element("${object}" download_only download_only "unset") get_json_element("${object}" find_args find_args "") get_json_element("${object}" raw_patches patches "") @@ -206,8 +207,18 @@ function(AddJsonPackage) # system/bundled if (bundled STREQUAL "unset" AND DEFINED JSON_BUNDLED_PACKAGE) set(bundled ${JSON_BUNDLED_PACKAGE}) + else() + set(bundled OFF) endif() + # download only + if (download_only STREQUAL "unset" AND DEFINED JSON_DOWNLOAD_ONLY) + set(download_only ${JSON_DOWNLOAD_ONLY}) + else() + set(download_only OFF) + endif() + + AddPackage( NAME "${package}" VERSION "${version}" @@ -225,6 +236,8 @@ function(AddJsonPackage) GIT_VERSION ${git_version} GIT_HOST ${git_host} + DOWNLOAD_ONLY ${download_only} + ARTIFACT ${artifact} TAG ${tag} ) @@ -280,6 +293,8 @@ function(AddPackage) URL GIT_URL + DOWNLOAD_ONLY + KEY BUNDLED_PACKAGE FIND_PACKAGE_ARGUMENTS diff --git a/externals/CMakeLists.txt b/externals/CMakeLists.txt index d613201566..3e776bf43d 100644 --- a/externals/CMakeLists.txt +++ b/externals/CMakeLists.txt @@ -217,8 +217,6 @@ if (UNIX AND NOT APPLE AND NOT TARGET gamemode::headers) endif() # Breakpad -# TODO(crueter): Breakpad needs additional fetches -# https://github.com/google/breakpad/blob/main/DEPS # https://github.com/microsoft/vcpkg/blob/master/ports/breakpad/CMakeLists.txt if (YUZU_CRASH_DUMPS AND NOT TARGET libbreakpad_client) set(BREAKPAD_WIN32_DEFINES @@ -230,14 +228,8 @@ if (YUZU_CRASH_DUMPS AND NOT TARGET libbreakpad_client) _CRT_NONSTDC_NO_DEPRECATE ) - # TODO - AddPackage( - NAME breakpad - URL "google/breakpad" - SHA f80f288803 - HASH 4a87ee88cea99bd633d52a5b00135a649f1475e3b65db325a6df9c804ab82b054ad7e62419b35f6e22cc5dfbbb569214041d7ad5d10fab10106e700bb5050e1d - DOWNLOAD_ONLY YES - ) + # TODO(crueter): Can probably put all this cmake crap into the CI repo itself + AddJsonPackage(breakpad) # libbreakpad add_library(libbreakpad STATIC) @@ -280,7 +272,10 @@ if (YUZU_CRASH_DUMPS AND NOT TARGET libbreakpad_client) list(APPEND LIBBREAKPAD_CLIENT_SOURCES ${LIBBREAKPAD_COMMON_SOURCES}) list(FILTER LIBBREAKPAD_CLIENT_SOURCES EXCLUDE REGEX "/sender|/tests|/unittests|/testcases|_unittest|_test") target_sources(libbreakpad_client PRIVATE ${LIBBREAKPAD_CLIENT_SOURCES}) - target_include_directories(libbreakpad_client PRIVATE ${breakpad_SOURCE_DIR}/src) + target_include_directories(libbreakpad_client PUBLIC ${breakpad_SOURCE_DIR}/src) + + # thank you Google, very cool + target_include_directories(libbreakpad_client PUBLIC ${breakpad_SOURCE_DIR}/src/src) if (WIN32) target_link_libraries(libbreakpad_client PRIVATE wininet.lib) diff --git a/externals/cpmfile.json b/externals/cpmfile.json index f8ca528951..e29240babe 100644 --- a/externals/cpmfile.json +++ b/externals/cpmfile.json @@ -114,5 +114,14 @@ "patches": [ "0001-cmake.patch" ] + }, + "breakpad": { + "repo": "scripts/breakpad", + "git_host": "git.crueter.xyz", + "tag": "f80f288803", + "hash": "227aeb765ea4b1f723305d4465931ce94e1c91448a938fc89f0fb06dd470c28d3b85e4ca47898735ef4a90bbeb53210e3cf39a61d592adbe99b3b9c2dfa0753c", + "artifact": "breakpad.tar.zst", + "bundled": true, + "download_only": true } } diff --git a/src/yuzu/CMakeLists.txt b/src/yuzu/CMakeLists.txt index cf87d5c997..41a8dd655f 100644 --- a/src/yuzu/CMakeLists.txt +++ b/src/yuzu/CMakeLists.txt @@ -252,6 +252,7 @@ if (YUZU_CRASH_DUMPS) breakpad.h ) target_link_libraries(yuzu PRIVATE libbreakpad_client) + target_compile_definitions(yuzu PRIVATE YUZU_CRASH_DUMPS) endif() if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") diff --git a/src/yuzu/breakpad.cpp b/src/yuzu/breakpad.cpp index d7aed569b7..da01188707 100644 --- a/src/yuzu/breakpad.cpp +++ b/src/yuzu/breakpad.cpp @@ -5,19 +5,7 @@ // SPDX-License-Identifier: GPL-2.0-or-later #include -#include -#if defined(_WIN32) -#include -#elif defined(__linux__) -#include -#elif defined(__sun__) -#include -#else -#error Minidump creation not supported on this platform -#endif - -#include "common/fs/fs_paths.h" #include "common/fs/path_util.h" #include "yuzu/breakpad.h" @@ -54,7 +42,7 @@ static void PruneDumpDirectory(const std::filesystem::path& dump_path) { } } -#ifdef __linux__ +#if defined(__linux__) || defined(__sun__) [[noreturn]] bool DumpCallback(const google_breakpad::MinidumpDescriptor& descriptor, void* context, bool succeeded) { // Prevent time- and space-consuming core dumps from being generated, as we have diff --git a/src/yuzu/breakpad.h b/src/yuzu/breakpad.h index 0f911aa9c8..2fd62f30a8 100644 --- a/src/yuzu/breakpad.h +++ b/src/yuzu/breakpad.h @@ -3,8 +3,23 @@ #pragma once +#if defined(_WIN32) +#include +#elif defined(__linux__) +#include +#elif defined(__sun__) +#include +#else +#error Minidump creation not supported on this platform +#endif + namespace Breakpad { void InstallCrashHandler(); +#if defined(__linux__) || defined(__sun__) +[[noreturn]] bool DumpCallback(const google_breakpad::MinidumpDescriptor& descriptor, + void* context, + bool succeeded); +#endif } diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index 4604a7b904..854a3f4f40 100644 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp @@ -260,7 +260,9 @@ static void RemoveTitlebarFilter() { #endif #ifdef YUZU_CRASH_DUMPS -#include "yuzu/breakpad.h" +# define __STDC_FORMAT_MACROS +# include "inttypes.h" +# include "yuzu/breakpad.h" #endif using namespace Common::Literals; @@ -5050,18 +5052,18 @@ void GMainWindow::UpdateWindowTitle(std::string_view title_name, std::string_vie std::string GMainWindow::CreateTASFramesString( std::array frames) const { - std::string string = ""; + std::string frame_string = ""; size_t maxPlayerIndex = 0; for (size_t i = 0; i < frames.size(); i++) { if (frames[i] != 0) { if (maxPlayerIndex != 0) - string += ", "; + frame_string += ", "; while (maxPlayerIndex++ != i) - string += "0, "; - string += std::to_string(frames[i]); + frame_string += "0, "; + frame_string += std::to_string(frames[i]); } } - return string; + return frame_string; } QString GMainWindow::GetTasStateDescription() const {