From 91b4ec44691be5c393bb40fa928b0b9a3e1264ee Mon Sep 17 00:00:00 2001 From: qimiko <25387744+qimiko@users.noreply.github.com> Date: Fri, 2 Feb 2024 02:40:07 -0700 Subject: [PATCH] add breakpad package to cmakelists --- CMakeLists.txt | 2 ++ loader/CMakeLists.txt | 61 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index e13d5632..314e2d81 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,6 +10,8 @@ if (GEODE_BUILDING_DOCS) set(GEODE_DONT_BUILD_TEST_MODS On) endif() +option(GEODE_ANDROID_USE_BREAKPAD "Enables the use of the Breakpad library for crash dumps." ON) + # Read version file(READ VERSION GEODE_VERSION) string(STRIP "${GEODE_VERSION}" GEODE_VERSION) diff --git a/loader/CMakeLists.txt b/loader/CMakeLists.txt index 58d6ac6a..7d97d71f 100644 --- a/loader/CMakeLists.txt +++ b/loader/CMakeLists.txt @@ -125,6 +125,61 @@ if (WIN32) set(SOURCES ${SOURCES} ${CMAKE_CURRENT_BINARY_DIR}/info.rc) endif() + +if (ANDROID AND GEODE_ANDROID_USE_BREAKPAD) + CPMAddPackage( + NAME "Breakpad" + VERSION "2023.06.01" + GIT_REPOSITORY "https://chromium.googlesource.com/breakpad/breakpad.git" + ) + + if (Breakpad_ADDED) + include(FetchContent) + + FetchContent_Declare(lss + GIT_REPOSITORY https://chromium.googlesource.com/linux-syscall-support.git + GIT_TAG v2022.10.12 + SOURCE_DIR ${Breakpad_BINARY_DIR}/src/third_party/lss + ) + + FetchContent_MakeAvailable(lss) + + add_library(Breakpad STATIC + ${Breakpad_SOURCE_DIR}/src/client/linux/crash_generation/crash_generation_client.cc + ${Breakpad_SOURCE_DIR}/src/client/linux/dump_writer_common/thread_info.cc + ${Breakpad_SOURCE_DIR}/src/client/linux/dump_writer_common/ucontext_reader.cc + ${Breakpad_SOURCE_DIR}/src/client/linux/handler/exception_handler.cc + ${Breakpad_SOURCE_DIR}/src/client/linux/handler/minidump_descriptor.cc + ${Breakpad_SOURCE_DIR}/src/client/linux/log/log.cc + ${Breakpad_SOURCE_DIR}/src/client/linux/microdump_writer/microdump_writer.cc + ${Breakpad_SOURCE_DIR}/src/client/linux/minidump_writer/linux_dumper.cc + ${Breakpad_SOURCE_DIR}/src/client/linux/minidump_writer/linux_ptrace_dumper.cc + ${Breakpad_SOURCE_DIR}/src/client/linux/minidump_writer/minidump_writer.cc + ${Breakpad_SOURCE_DIR}/src/client/linux/minidump_writer/pe_file.cc + ${Breakpad_SOURCE_DIR}/src/client/minidump_file_writer.cc + ${Breakpad_SOURCE_DIR}/src/common/convert_UTF.cc + ${Breakpad_SOURCE_DIR}/src/common/md5.cc + ${Breakpad_SOURCE_DIR}/src/common/string_conversion.cc + ${Breakpad_SOURCE_DIR}/src/common/linux/breakpad_getcontext.S + ${Breakpad_SOURCE_DIR}/src/common/linux/elfutils.cc + ${Breakpad_SOURCE_DIR}/src/common/linux/file_id.cc + ${Breakpad_SOURCE_DIR}/src/common/linux/guid_creator.cc + ${Breakpad_SOURCE_DIR}/src/common/linux/linux_libc_support.cc + ${Breakpad_SOURCE_DIR}/src/common/linux/memory_mapped_file.cc + ${Breakpad_SOURCE_DIR}/src/common/linux/safe_readlink.cc + ) + + target_include_directories(Breakpad PUBLIC + ${Breakpad_SOURCE_DIR}/src/common/android/include/ + ${Breakpad_SOURCE_DIR}/src/ + ${Breakpad_SOURCE_DIR}/src/common/android/include/ + + # add lss headers + ${Breakpad_BINARY_DIR}/src/ + ) + endif() +endif() + add_library(${PROJECT_NAME} SHARED ${SOURCES}) target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_20) @@ -170,6 +225,12 @@ endif() if (ANDROID) # needed to define some opengl functions target_link_libraries(${PROJECT_NAME} EGL) + + if (GEODE_ANDROID_USE_BREAKPAD) + target_compile_definitions(${PROJECT_NAME} PRIVATE -DGEODE_USE_BREAKPAD) + enable_language(ASM) + target_link_libraries(${PROJECT_NAME} Breakpad) + endif() endif() target_include_directories(${PROJECT_NAME} PRIVATE