[cmake] fix breakpad fetching

Signed-off-by: crueter <crueter@eden-emu.dev>
This commit is contained in:
crueter 2025-09-07 19:39:35 -04:00
parent 2ca36e1bd7
commit 92de4aee3c
Signed by: crueter
GPG key ID: 425ACD2D4830EBC6
8 changed files with 66 additions and 40 deletions

View file

@ -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_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) 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 "") set_target_properties(Qt6::Platform PROPERTIES INTERFACE_COMPILE_FEATURES "")
endif() endif()
if (YUZU_CRASH_DUMPS) # TODO: test on windows
set(BREAKPAD_VER "breakpad-c89f9dd") # if (YUZU_CRASH_DUMPS)
download_bundled_external("breakpad/" ${BREAKPAD_VER} "breakpad-win" BREAKPAD_PREFIX "c89f9dd") # 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_INCLUDE_DIR "${BREAKPAD_PREFIX}/include")
set(BREAKPAD_CLIENT_LIBRARY "${BREAKPAD_PREFIX}/lib/libbreakpad_client.lib") # set(BREAKPAD_CLIENT_LIBRARY "${BREAKPAD_PREFIX}/lib/libbreakpad_client.lib")
add_library(libbreakpad_client INTERFACE IMPORTED) # add_library(libbreakpad_client INTERFACE IMPORTED)
target_link_libraries(libbreakpad_client INTERFACE "${BREAKPAD_CLIENT_LIBRARY}") # target_link_libraries(libbreakpad_client INTERFACE "${BREAKPAD_CLIENT_LIBRARY}")
target_include_directories(libbreakpad_client INTERFACE "${BREAKPAD_CLIENT_INCLUDE_DIR}") # target_include_directories(libbreakpad_client INTERFACE "${BREAKPAD_CLIENT_INCLUDE_DIR}")
endif() # endif()
# Prefer the -pthread flag on Linux. # Prefer the -pthread flag on Linux.
set(THREADS_PREFER_PTHREAD_FLAG ON) set(THREADS_PREFER_PTHREAD_FLAG ON)

View file

@ -152,6 +152,7 @@ function(AddJsonPackage)
get_json_element("${object}" git_host git_host "") get_json_element("${object}" git_host git_host "")
get_json_element("${object}" source_subdir source_subdir "") get_json_element("${object}" source_subdir source_subdir "")
get_json_element("${object}" bundled bundled "unset") 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}" find_args find_args "")
get_json_element("${object}" raw_patches patches "") get_json_element("${object}" raw_patches patches "")
@ -206,8 +207,18 @@ function(AddJsonPackage)
# system/bundled # system/bundled
if (bundled STREQUAL "unset" AND DEFINED JSON_BUNDLED_PACKAGE) if (bundled STREQUAL "unset" AND DEFINED JSON_BUNDLED_PACKAGE)
set(bundled ${JSON_BUNDLED_PACKAGE}) set(bundled ${JSON_BUNDLED_PACKAGE})
else()
set(bundled OFF)
endif() 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( AddPackage(
NAME "${package}" NAME "${package}"
VERSION "${version}" VERSION "${version}"
@ -225,6 +236,8 @@ function(AddJsonPackage)
GIT_VERSION ${git_version} GIT_VERSION ${git_version}
GIT_HOST ${git_host} GIT_HOST ${git_host}
DOWNLOAD_ONLY ${download_only}
ARTIFACT ${artifact} ARTIFACT ${artifact}
TAG ${tag} TAG ${tag}
) )
@ -280,6 +293,8 @@ function(AddPackage)
URL URL
GIT_URL GIT_URL
DOWNLOAD_ONLY
KEY KEY
BUNDLED_PACKAGE BUNDLED_PACKAGE
FIND_PACKAGE_ARGUMENTS FIND_PACKAGE_ARGUMENTS

View file

@ -217,8 +217,6 @@ if (UNIX AND NOT APPLE AND NOT TARGET gamemode::headers)
endif() endif()
# Breakpad # 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 # https://github.com/microsoft/vcpkg/blob/master/ports/breakpad/CMakeLists.txt
if (YUZU_CRASH_DUMPS AND NOT TARGET libbreakpad_client) if (YUZU_CRASH_DUMPS AND NOT TARGET libbreakpad_client)
set(BREAKPAD_WIN32_DEFINES set(BREAKPAD_WIN32_DEFINES
@ -230,14 +228,8 @@ if (YUZU_CRASH_DUMPS AND NOT TARGET libbreakpad_client)
_CRT_NONSTDC_NO_DEPRECATE _CRT_NONSTDC_NO_DEPRECATE
) )
# TODO # TODO(crueter): Can probably put all this cmake crap into the CI repo itself
AddPackage( AddJsonPackage(breakpad)
NAME breakpad
URL "google/breakpad"
SHA f80f288803
HASH 4a87ee88cea99bd633d52a5b00135a649f1475e3b65db325a6df9c804ab82b054ad7e62419b35f6e22cc5dfbbb569214041d7ad5d10fab10106e700bb5050e1d
DOWNLOAD_ONLY YES
)
# libbreakpad # libbreakpad
add_library(libbreakpad STATIC) 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(APPEND LIBBREAKPAD_CLIENT_SOURCES ${LIBBREAKPAD_COMMON_SOURCES})
list(FILTER LIBBREAKPAD_CLIENT_SOURCES EXCLUDE REGEX "/sender|/tests|/unittests|/testcases|_unittest|_test") list(FILTER LIBBREAKPAD_CLIENT_SOURCES EXCLUDE REGEX "/sender|/tests|/unittests|/testcases|_unittest|_test")
target_sources(libbreakpad_client PRIVATE ${LIBBREAKPAD_CLIENT_SOURCES}) 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) if (WIN32)
target_link_libraries(libbreakpad_client PRIVATE wininet.lib) target_link_libraries(libbreakpad_client PRIVATE wininet.lib)

View file

@ -114,5 +114,14 @@
"patches": [ "patches": [
"0001-cmake.patch" "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
} }
} }

View file

@ -252,6 +252,7 @@ if (YUZU_CRASH_DUMPS)
breakpad.h breakpad.h
) )
target_link_libraries(yuzu PRIVATE libbreakpad_client) target_link_libraries(yuzu PRIVATE libbreakpad_client)
target_compile_definitions(yuzu PRIVATE YUZU_CRASH_DUMPS)
endif() endif()
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")

View file

@ -5,19 +5,7 @@
// SPDX-License-Identifier: GPL-2.0-or-later // SPDX-License-Identifier: GPL-2.0-or-later
#include <algorithm> #include <algorithm>
#include <ranges>
#if defined(_WIN32)
#include <client/windows/handler/exception_handler.h>
#elif defined(__linux__)
#include <client/linux/handler/exception_handler.h>
#elif defined(__sun__)
#include <client/solaris/handler/exception_handler.h>
#else
#error Minidump creation not supported on this platform
#endif
#include "common/fs/fs_paths.h"
#include "common/fs/path_util.h" #include "common/fs/path_util.h"
#include "yuzu/breakpad.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, [[noreturn]] bool DumpCallback(const google_breakpad::MinidumpDescriptor& descriptor, void* context,
bool succeeded) { bool succeeded) {
// Prevent time- and space-consuming core dumps from being generated, as we have // Prevent time- and space-consuming core dumps from being generated, as we have

View file

@ -3,8 +3,23 @@
#pragma once #pragma once
#if defined(_WIN32)
#include <client/windows/handler/exception_handler.h>
#elif defined(__linux__)
#include <client/linux/handler/exception_handler.h>
#elif defined(__sun__)
#include <client/solaris/handler/exception_handler.h>
#else
#error Minidump creation not supported on this platform
#endif
namespace Breakpad { namespace Breakpad {
void InstallCrashHandler(); void InstallCrashHandler();
#if defined(__linux__) || defined(__sun__)
[[noreturn]] bool DumpCallback(const google_breakpad::MinidumpDescriptor& descriptor,
void* context,
bool succeeded);
#endif
} }

View file

@ -260,7 +260,9 @@ static void RemoveTitlebarFilter() {
#endif #endif
#ifdef YUZU_CRASH_DUMPS #ifdef YUZU_CRASH_DUMPS
#include "yuzu/breakpad.h" # define __STDC_FORMAT_MACROS
# include "inttypes.h"
# include "yuzu/breakpad.h"
#endif #endif
using namespace Common::Literals; using namespace Common::Literals;
@ -5050,18 +5052,18 @@ void GMainWindow::UpdateWindowTitle(std::string_view title_name, std::string_vie
std::string GMainWindow::CreateTASFramesString( std::string GMainWindow::CreateTASFramesString(
std::array<size_t, InputCommon::TasInput::PLAYER_NUMBER> frames) const { std::array<size_t, InputCommon::TasInput::PLAYER_NUMBER> frames) const {
std::string string = ""; std::string frame_string = "";
size_t maxPlayerIndex = 0; size_t maxPlayerIndex = 0;
for (size_t i = 0; i < frames.size(); i++) { for (size_t i = 0; i < frames.size(); i++) {
if (frames[i] != 0) { if (frames[i] != 0) {
if (maxPlayerIndex != 0) if (maxPlayerIndex != 0)
string += ", "; frame_string += ", ";
while (maxPlayerIndex++ != i) while (maxPlayerIndex++ != i)
string += "0, "; frame_string += "0, ";
string += std::to_string(frames[i]); frame_string += std::to_string(frames[i]);
} }
} }
return string; return frame_string;
} }
QString GMainWindow::GetTasStateDescription() const { QString GMainWindow::GetTasStateDescription() const {