diff --git a/.clang-format b/.clang-format index 0be5323f5b..8508426fe6 100644 --- a/.clang-format +++ b/.clang-format @@ -1,4 +1,4 @@ -# Copyright 2014 The Crashpad Authors. All rights reserved. +# Copyright 2014 The Crashpad Authors # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/.gitattributes b/.gitattributes index 9bfc20d15c..644b9e2573 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,4 +1,4 @@ -# Copyright 2019 The Crashpad Authors. All rights reserved. +# Copyright 2019 The Crashpad Authors # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 0000000000..ad4ca06325 --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1 @@ +* @getsentry/processing diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000000..c622d95638 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,81 @@ +name: Build + +on: + push: + branches: + - getsentry + pull_request: + +jobs: + build: + strategy: + fail-fast: false + matrix: + include: + - name: Ubuntu + platform: ubuntu-latest + - name: Windows (x64) + platform: windows-latest + - name: Windows (arm64) + platform: windows-latest + CMAKE_DEFINES: -DCMAKE_TOOLCHAIN_FILE=cmake/toolchains/win_arm64.cmake -A arm64 + - name: LLVM-MINGW (x64) + platform: windows-latest + MINGW: 1 + MINGW_PKG_PREFIX: x86_64-w64-mingw32 + MINGW_ASM_MASM_COMPILER: llvm-ml;-m64 + CMAKE_DEFINES: -DCRASHPAD_ZLIB_SYSTEM=OFF -DCRASHPAD_BUILD_TOOLS=OFF -G Ninja + - name: LLVM-MINGW (arm64) + platform: windows-latest + MINGW: 1 + MINGW_PKG_PREFIX: aarch64-w64-mingw32 + CMAKE_DEFINES: -DCRASHPAD_ZLIB_SYSTEM=OFF -DCRASHPAD_BUILD_TOOLS=OFF -DCMAKE_TOOLCHAIN_FILE=cmake/toolchains/mingw_arm64.cmake -G Ninja + - name: macOS + platform: macos-latest + name: ${{ matrix.name }} + runs-on: ${{ matrix.platform }} + env: + CMAKE_DEFINES: ${{ matrix.CMAKE_DEFINES }} + steps: + - uses: actions/checkout@v4 + with: + submodules: "recursive" + + - name: Installing Linux Dependencies + if: ${{ runner.os == 'Linux' }} + run: | + sudo apt update + sudo apt install zlib1g-dev libcurl4-openssl-dev libssl-dev libunwind-dev pkg-config + + - name: Installing LLVM-MINGW Dependencies + if: ${{ runner.os == 'Windows' && matrix.MINGW == '1' }} + shell: powershell + env: + MINGW_PKG_PREFIX: ${{ matrix.MINGW_PKG_PREFIX }} + MINGW_ASM_MASM_COMPILER: ${{ matrix.MINGW_ASM_MASM_COMPILER }} + run: . "cmake\scripts\install-llvm-mingw.ps1" + + - name: Build crashpad + shell: bash + run: | + echo "CMAKE_DEFINES=${CMAKE_DEFINES}" + cmake -B cmake-build -D CRASHPAD_BUILD_TOOLS=On ${CMAKE_DEFINES} + cmake --build cmake-build --parallel + + - name: Build crashpad with client-side stack traces + shell: bash + run: | + echo "CMAKE_DEFINES=${CMAKE_DEFINES}" + cmake -B cmake-build-stacks -D CRASHPAD_ENABLE_STACKTRACE=ON ${CMAKE_DEFINES} + cmake --build cmake-build-stacks --parallel + + build-ios: + name: 'iOS' + runs-on: macos-latest + steps: + - uses: actions/checkout@v4 + with: + submodules: "recursive" + - run: | + cmake -B crashpad-xcode -GXcode -DCMAKE_SYSTEM_NAME=iOS + xcodebuild build -project crashpad-xcode/crashpad.xcodeproj diff --git a/.gitignore b/.gitignore index b739477a52..aa7162e52b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ -# Copyright 2014 The Crashpad Authors. All rights reserved. +# Copyright 2014 The Crashpad Authors # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -12,6 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. +# Keep sorted + *.Makefile *.ninja *.pyc @@ -19,25 +21,25 @@ *.xcodeproj *~ .*.sw? -.cache .DS_Store +.cache .gdb_history .gdbinit /Makefile +/build/fuchsia /out /third_party/edo/edo +/third_party/fuchsia-gn-sdk /third_party/fuchsia/.cipd /third_party/fuchsia/clang /third_party/fuchsia/qemu /third_party/fuchsia/sdk /third_party/googletest/googletest +/third_party/gyp/gyp /third_party/libfuzzer /third_party/linux/.cipd /third_party/linux/clang /third_party/linux/sysroot -/third_party/lss/lss /third_party/gyp/gyp -/third_party/mini_chromium/mini_chromium -/third_party/zlib/zlib /xcodebuild tags diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000000..d183aa487d --- /dev/null +++ b/.gitmodules @@ -0,0 +1,9 @@ +[submodule "third_party/mini_chromium/mini_chromium"] + path = third_party/mini_chromium/mini_chromium + url = https://chromium.googlesource.com/chromium/mini_chromium +[submodule "third_party/zlib/zlib"] + path = third_party/zlib/zlib + url = https://chromium.googlesource.com/chromium/src/third_party/zlib +[submodule "third_party/lss/lss"] + path = third_party/lss/lss + url = https://chromium.googlesource.com/linux-syscall-support diff --git a/.gn b/.gn index d447a5537c..f2db1da269 100644 --- a/.gn +++ b/.gn @@ -1,4 +1,4 @@ -# Copyright 2017 The Crashpad Authors. All rights reserved. +# Copyright 2017 The Crashpad Authors # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -13,3 +13,4 @@ # limitations under the License. buildconfig = "//build/BUILDCONFIG.gn" +script_executable = "python3" diff --git a/.style.yapf b/.style.yapf index 8aaf9b62c7..1471bc8225 100644 --- a/.style.yapf +++ b/.style.yapf @@ -1,4 +1,4 @@ -# Copyright 2020 The Crashpad Authors. All rights reserved. +# Copyright 2020 The Crashpad Authors # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/.vpython b/.vpython3 similarity index 86% rename from .vpython rename to .vpython3 index c2001fc5df..f16930379f 100644 --- a/.vpython +++ b/.vpython3 @@ -1,4 +1,4 @@ -# Copyright 2018 The Crashpad Authors. All rights reserved. +# Copyright 2022 The Crashpad Authors # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -21,8 +21,8 @@ # This is needed for snapshot/win/end_to_end_test.py. wheel: < - name: "infra/python/wheels/pypiwin32/${vpython_platform}" - version: "version:219" + name: "infra/python/wheels/pywin32/${vpython_platform}" + version: "version:300" match_tag: < platform: "win32" > diff --git a/AUTHORS b/AUTHORS index 8dcac32388..e797d3db7c 100644 --- a/AUTHORS +++ b/AUTHORS @@ -12,3 +12,5 @@ Opera Software ASA Vewd Software AS LG Electronics, Inc. MIPS Technologies, Inc. +Darshan Sen +Ho Cheung diff --git a/BUILD.gn b/BUILD.gn index c0f8bcbc0d..8be9eee759 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright 2017 The Crashpad Authors. All rights reserved. +# Copyright 2017 The Crashpad Authors # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -17,7 +17,10 @@ import("build/test.gni") import("util/net/tls.gni") config("crashpad_config") { - include_dirs = [ "." ] + include_dirs = [ + ".", + root_gen_dir, + ] } if (crashpad_is_in_chromium || crashpad_is_in_fuchsia) { @@ -36,6 +39,9 @@ if (crashpad_is_in_chromium || crashpad_is_in_fuchsia) { if (crashpad_is_in_fuchsia) { # TODO(fuchsia:46559): Fix the leaks and remove this. deps += [ "//build/config/sanitizers:suppress-lsan.DO-NOT-USE-THIS" ] + # TODO(fxbug.dev/42059784): Remove this once the underlying issue is + # addressed. + exclude_toolchain_tags = [ "hwasan" ] } if (crashpad_is_android) { use_raw_android_executable = true @@ -64,7 +70,7 @@ if (crashpad_is_in_chromium || crashpad_is_in_fuchsia) { if (crashpad_is_in_fuchsia) { import("//build/components.gni") fuchsia_test_component("crashpad-test-component") { - manifest = "test/fuchsia_crashpad_tests.cmx" + manifest = "test/fuchsia_crashpad_tests.cml" deps = [ ":crashpad-test-resources", ":crashpad_tests", @@ -81,8 +87,8 @@ if (crashpad_is_in_chromium || crashpad_is_in_fuchsia) { test_components = [ ":crashpad-test-component" ] deps = [ - "//src/connectivity/network/dns:component-legacy", - "//src/connectivity/network/netstack:component-legacy", + "//src/connectivity/network/dns:component", + "//src/connectivity/network/netstack:component", ] test_specs = { @@ -118,11 +124,6 @@ if (crashpad_is_in_chromium || crashpad_is_in_fuchsia) { deps = _resources } - fuchsia_shell_package("crashpad-database-util") { - package_name = "crashpad_database_util" - deps = [ "tools:crashpad_database_util" ] - } - group("tests") { testonly = true diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000000..4f1c9adc4d --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,160 @@ +cmake_minimum_required(VERSION 3.12) +project(crashpad LANGUAGES C CXX) + +if(CMAKE_SYSTEM_NAME STREQUAL "Linux") + set(LINUX TRUE) +endif() + +set(CRASHPAD_MAIN_PROJECT OFF) +if(CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR) + set(CRASHPAD_MAIN_PROJECT ON) +endif() + +option(CRASHPAD_ENABLE_INSTALL "Enable crashpad installation" "${CRASHPAD_MAIN_PROJECT}") +option(CRASHPAD_ENABLE_INSTALL_DEV "Enable crashpad development installation" "${CRASHPAD_MAIN_PROJECT}") +option(CRASHPAD_ENABLE_STACKTRACE "Enable client-side stack trace recording" OFF) + +if(MSVC) + set(CRASHPAD_ZLIB_SYSTEM_DEFAULT OFF) +else() + set(CRASHPAD_ZLIB_SYSTEM_DEFAULT ON) +endif() +option(CRASHPAD_ZLIB_SYSTEM "Use system zlib library" "${CRASHPAD_ZLIB_SYSTEM_DEFAULT}") + +if(CRASHPAD_ZLIB_SYSTEM AND NOT TARGET ZLIB::ZLIB) + find_package(ZLIB REQUIRED) +endif() + +if (NOT (ANDROID OR FUCHSIA)) + add_compile_definitions(CRASHPAD_FLOCK_ALWAYS_SUPPORTED=1) +else() + add_compile_definitions(CRASHPAD_FLOCK_ALWAYS_SUPPORTED=0) +endif() + +include(GNUInstallDirs) +set(CMAKE_INSTALL_CMAKEDIR "${CMAKE_INSTALL_LIBDIR}/cmake/crashpad") + +function(crashpad_install_target) + if(CRASHPAD_ENABLE_INSTALL) + install(TARGETS ${ARGN} EXPORT crashpad_export + ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" + LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" + RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" + ) + endif() +endfunction() +function(crashpad_install_dev) + if(CRASHPAD_ENABLE_INSTALL_DEV) + install(${ARGN}) + endif() +endfunction() + +if(WIN32 AND NOT (MINGW AND "${CMAKE_SYSTEM_PROCESSOR}" MATCHES "[Aa][Rr][Mm]64")) + if("${CMAKE_SYSTEM_PROCESSOR}" MATCHES ARM64) + enable_language(ASM_MARMASM) + else() + enable_language(ASM_MASM) + endif() + + if(MINGW) + find_program(JWASM_FOUND jwasm) + if (JWASM_FOUND) + set(CMAKE_ASM_MASM_COMPILER ${JWASM_FOUND}) + execute_process(COMMAND ${CMAKE_C_COMPILER} --version OUTPUT_VARIABLE COMPILER_VERSION_OUTPUT) + if (COMPILER_VERSION_OUTPUT) + if (COMPILER_VERSION_OUTPUT MATCHES "x86_64") + set(JWASM_FLAGS -win64) + else() + set(JWASM_FLAGS -coff) + endif() + endif() + set(CMAKE_ASM_MASM_FLAGS ${CMAKE_ASM_MASM_FLAGS} ${JWASM_FLAGS}) + endif(JWASM_FOUND) + + if(NOT CMAKE_ASM_MASM_COMPILER OR CMAKE_ASM_MASM_COMPILER STREQUAL "ml" OR CMAKE_ASM_MASM_COMPILER STREQUAL "ml64") + message(WARNING "No custom ASM_MASM compiler defined via 'CMAKE_ASM_MASM_COMPILER'. Trying to use UASM...") + set(CMAKE_ASM_MASM_COMPILER "uasm") + endif() + if(NOT CMAKE_ASM_MASM_FLAGS) + set(CMAKE_ASM_MASM_FLAGS "-win64 -10") #use default compatibility flags + endif() + endif(MINGW) +else() + enable_language(ASM) +endif() + +set(CMAKE_CXX_STANDARD 20) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + +add_library(crashpad_interface INTERFACE) +target_include_directories(crashpad_interface INTERFACE + $ + $ +) +target_compile_definitions(crashpad_interface INTERFACE + CRASHPAD_LSS_SOURCE_EMBEDDED +) + +if(WIN32) + target_compile_definitions(crashpad_interface INTERFACE + NOMINMAX + UNICODE + WIN32_LEAN_AND_MEAN + _CRT_SECURE_NO_WARNINGS + _HAS_EXCEPTIONS=0 + _UNICODE + ) +endif() +if(MSVC) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /utf-8") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /utf-8") + + string(REGEX REPLACE "/[Ww][0123]" "" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}") + string(REGEX REPLACE "/[Ww][0123]" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") + target_compile_options(crashpad_interface INTERFACE + $<$:/FS> + $<$:/W4> + $<$:/WX> + $<$:/bigobj> # Support larger number of sections in obj file. + $<$:/wd4100> # Unreferenced formal parameter. + $<$:/wd4127> # Conditional expression is constant. + $<$:/wd4324> # Structure was padded due to alignment specifier. + $<$:/wd4351> # New behavior: elements of array will be default initialized. + $<$:/wd4577> # 'noexcept' used with no exception handling mode specified. + $<$:/wd4996> # 'X' was declared deprecated. + ) +elseif(MINGW) + # redirect to wmain + # FIXME: cmake 3.13 added target_link_options + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -municode") +endif() +add_library(crashpad::interface ALIAS crashpad_interface) + +add_subdirectory(compat) +add_subdirectory(minidump) +add_subdirectory(snapshot) +add_subdirectory(util) +add_subdirectory(third_party/mini_chromium) +add_subdirectory(client) + +add_subdirectory(third_party/zlib) +add_subdirectory(third_party/getopt) + +add_subdirectory(tools) +add_subdirectory(handler) + +if(CRASHPAD_ENABLE_STACKTRACE AND APPLE AND NOT IOS) + set(LIBUNWIND_ENABLE_SHARED OFF) + add_subdirectory(libunwind) + crashpad_install_target(unwind_static) +endif() + +if(CRASHPAD_ENABLE_INSTALL_DEV) + install(EXPORT crashpad_export NAMESPACE crashpad:: FILE crashpad-targets.cmake + DESTINATION "${CMAKE_INSTALL_CMAKEDIR}") + include(CMakePackageConfigHelpers) + configure_package_config_file(crashpad-config.cmake.in crashpad-config.cmake + INSTALL_DESTINATION "${CMAKE_INSTALL_CMAKEDIR}" + ) + install(FILES "${CMAKE_CURRENT_BINARY_DIR}/crashpad-config.cmake" DESTINATION "${CMAKE_INSTALL_CMAKEDIR}") +endif() diff --git a/DEPS b/DEPS index c1edb80c15..b4fe4fff5b 100644 --- a/DEPS +++ b/DEPS @@ -1,4 +1,4 @@ -# Copyright 2014 The Crashpad Authors. All rights reserved. +# Copyright 2014 The Crashpad Authors # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -14,6 +14,10 @@ vars = { 'chromium_git': 'https://chromium.googlesource.com', + 'gn_version': 'git_revision:5e19d2fb166fbd4f6f32147fbb2f497091a54ad8', + # ninja CIPD package version. + # https://chrome-infra-packages.appspot.com/p/infra/3pp/tools/ninja + 'ninja_version': 'version:2@1.8.2.chromium.3', 'pull_linux_clang': False, 'pull_win_toolchain': False, # Controls whether crashpad/build/ios/setup-ios-gn.py is run as part of @@ -25,34 +29,78 @@ vars = { deps = { 'buildtools': Var('chromium_git') + '/chromium/src/buildtools.git@' + - '9e121212d42be62a7cce38072f925f8398d11e49', + '8919328651a559f8a974641d40fe712062cc6718', + 'buildtools/clang_format/script': + Var('chromium_git') + + '/external/github.com/llvm/llvm-project/clang/tools/clang-format.git@' + + 'c912837e0d82b5ca4b6e790b573b3956d3744c1c', 'crashpad/third_party/edo/edo': { 'url': Var('chromium_git') + '/external/github.com/google/eDistantObject.git@' + - '6ffbf833173f53fcd06ecf08670a95cc01c01f72', + '727e556705278598fce683522beedbb9946bfda0', 'condition': 'checkout_ios', }, 'crashpad/third_party/googletest/googletest': Var('chromium_git') + '/external/github.com/google/googletest@' + - '11da093e0477185dbd78abaaa9f99db15be498d0', + 'af29db7ec28d6df1c7f0f745186884091e602e07', 'crashpad/third_party/lss/lss': Var('chromium_git') + '/linux-syscall-support.git@' + - '7bde79cc274d06451bf65ae82c012a5d3e476b5a', + '9719c1e1e676814c456b55f5f070eabad6709d31', 'crashpad/third_party/mini_chromium/mini_chromium': Var('chromium_git') + '/chromium/mini_chromium@' + - '0e22eed71eec97dacbe80822a14c5cd0b580d793', + 'bd56f6933f2fa021a44766ced638a18f477ef1c1', 'crashpad/third_party/libfuzzer/src': Var('chromium_git') + '/chromium/llvm-project/compiler-rt/lib/fuzzer.git@' + 'fda403cf93ecb8792cb1d061564d89a6553ca020', 'crashpad/third_party/zlib/zlib': Var('chromium_git') + '/chromium/src/third_party/zlib@' + - '13dc246a58e4b72104d35f9b1809af95221ebda7', + 'fef58692c1d7bec94c4ed3d030a45a1832a9615d', - # CIPD packages below. + # CIPD packages. + 'buildtools/linux64': { + 'packages': [ + { + 'package': 'gn/gn/linux-${{arch}}', + 'version': Var('gn_version'), + } + ], + 'dep_type': 'cipd', + 'condition': 'host_os == "linux"', + }, + 'buildtools/mac': { + 'packages': [ + { + 'package': 'gn/gn/mac-${{arch}}', + 'version': Var('gn_version'), + } + ], + 'dep_type': 'cipd', + 'condition': 'host_os == "mac"', + }, + 'buildtools/win': { + 'packages': [ + { + 'package': 'gn/gn/windows-amd64', + 'version': Var('gn_version'), + } + ], + 'dep_type': 'cipd', + 'condition': 'host_os == "win"', + }, + 'crashpad/build/fuchsia': { + 'packages': [ + { + 'package': 'chromium/fuchsia/test-scripts', + 'version': 'latest', + } + ], + 'condition': 'checkout_fuchsia', + 'dep_type': 'cipd', + }, 'crashpad/third_party/linux/clang/linux-amd64': { 'packages': [ { - 'package': 'fuchsia/clang/linux-amd64', - 'version': 'goma', + 'package': 'fuchsia/third_party/clang/linux-amd64', + 'version': 'Tpc85d1ZwSlZ6UKl2d96GRUBGNA5JKholOKe24sRDr0C', }, ], 'condition': 'checkout_linux and pull_linux_clang', @@ -61,8 +109,8 @@ deps = { 'crashpad/third_party/fuchsia/clang/mac-amd64': { 'packages': [ { - 'package': 'fuchsia/clang/mac-amd64', - 'version': 'goma', + 'package': 'fuchsia/third_party/clang/mac-amd64', + 'version': 'latest', }, ], 'condition': 'checkout_fuchsia and host_os == "mac"', @@ -71,33 +119,78 @@ deps = { 'crashpad/third_party/fuchsia/clang/linux-amd64': { 'packages': [ { - 'package': 'fuchsia/clang/linux-amd64', - 'version': 'goma', + 'package': 'fuchsia/third_party/clang/linux-amd64', + 'version': 'latest', }, ], 'condition': 'checkout_fuchsia and host_os == "linux"', 'dep_type': 'cipd' }, - 'crashpad/third_party/fuchsia/sdk/mac-amd64': { + 'crashpad/third_party/fuchsia-gn-sdk': { 'packages': [ { - 'package': 'fuchsia/sdk/gn/mac-amd64', + 'package': 'chromium/fuchsia/gn-sdk', 'version': 'latest' }, ], - 'condition': 'checkout_fuchsia and host_os == "mac"', + 'condition': 'checkout_fuchsia', 'dep_type': 'cipd' }, 'crashpad/third_party/fuchsia/sdk/linux-amd64': { 'packages': [ { - 'package': 'fuchsia/sdk/gn/linux-amd64', + 'package': 'fuchsia/sdk/core/linux-amd64', 'version': 'latest' }, ], 'condition': 'checkout_fuchsia and host_os == "linux"', 'dep_type': 'cipd' }, + # depot_tools/ninja wrapper calls third_party/ninja/{ninja, ninja.exe}. + # crashpad/third_party/ninja/ninja is another wrapper to call linux ninja + # or mac ninja. + # This allows crashpad developers to work for multiple platforms on the same + # machine. + 'crashpad/third_party/ninja': { + 'packages': [ + { + 'package': 'infra/3pp/tools/ninja/${{platform}}', + 'version': Var('ninja_version'), + } + ], + 'condition': 'host_os == "win"', + 'dep_type': 'cipd', + }, + 'crashpad/third_party/ninja/linux': { + 'packages': [ + { + 'package': 'infra/3pp/tools/ninja/${{platform}}', + 'version': Var('ninja_version'), + } + ], + 'condition': 'host_os == "linux"', + 'dep_type': 'cipd', + }, + 'crashpad/third_party/ninja/mac-amd64': { + 'packages': [ + { + 'package': 'infra/3pp/tools/ninja/mac-amd64', + 'version': Var('ninja_version'), + } + ], + 'condition': 'host_os == "mac" and host_cpu == "x64"', + 'dep_type': 'cipd', + }, + 'crashpad/third_party/ninja/mac-arm64': { + 'packages': [ + { + 'package': 'infra/3pp/tools/ninja/mac-arm64', + 'version': Var('ninja_version'), + } + ], + 'condition': 'host_os == "mac" and host_cpu == "arm64"', + 'dep_type': 'cipd', + }, 'crashpad/third_party/win/toolchain': { # This package is only updated when the solution in .gclient includes an # entry like: @@ -106,7 +199,7 @@ deps = { 'packages': [ { 'package': 'chrome_internal/third_party/sdk/windows', - 'version': 'uploaded:2018-06-13' + 'version': 'uploaded:2021-04-28' }, ], 'condition': 'checkout_win and pull_win_toolchain', @@ -125,7 +218,9 @@ hooks = [ '--no_auth', '--bucket=chromium-clang-format', '--sha1_file', - 'buildtools/mac/clang-format.sha1', + 'buildtools/mac/clang-format.{host_cpu}.sha1', + '--output', + 'buildtools/mac/clang-format', ], }, { @@ -164,12 +259,34 @@ hooks = [ 'crashpad/build/install_linux_sysroot.py', ], }, + { + # Avoid introducing unnecessary PRESUBMIT.py file from build/fuchsia. + # Never fail and ignore the error if the file does not exist. + 'name': 'Remove the PRESUBMIT.py from build/fuchsia', + 'pattern': '.', + 'condition': 'checkout_fuchsia', + 'action': [ + 'rm', + '-f', + 'crashpad/build/fuchsia/PRESUBMIT.py', + ], + }, + { + 'name': 'Generate Fuchsia Build Definitions', + 'pattern': '.', + 'condition': 'checkout_fuchsia', + 'action': [ + 'python3', + 'crashpad/build/fuchsia_envs.py', + 'crashpad/build/fuchsia/gen_build_defs.py' + ], + }, { 'name': 'setup_gn_ios', 'pattern': '.', 'condition': 'run_setup_ios_gn and checkout_ios', 'action': [ - 'python', + 'python3', 'crashpad/build/ios/setup_ios_gn.py' ], }, diff --git a/Makefile b/Makefile new file mode 100644 index 0000000000..6d88f6fc44 --- /dev/null +++ b/Makefile @@ -0,0 +1,36 @@ +SHELL := /bin/bash +PATH := $(PWD)/../depot_tools:$(PATH) + +all: + echo 'Nothing to do' && exit 1 + +build-with-gn: + gn gen out/Default + ninja -C out/Default +.PHONY: build-with-gn + +build-with-cmake: + mkdir -p cmakebuild + cd cmakebuild; cmake .. + cmake --build cmakebuild --parallel +.PHONY: build-with-cmake + +update-with-gclient: + gclient sync +.PHONY: update-with-gclient + +example: build-with-gn + g++ -g \ + -o example example.cpp \ + -I. -I./third_party/mini_chromium/mini_chromium \ + -std=c++14 \ + -L./out/Default/obj/client -lclient \ + -L./out/Default/obj/util -lutil \ + -L./out/Default/obj/third_party/mini_chromium/mini_chromium/base -lbase \ + -framework Foundation -framework Security -framework CoreText \ + -framework CoreGraphics -framework IOKit -lbsm +.PHONY: example + +gen-sentry-patch: + git format-patch --stdout master...HEAD > getsentry.patch +.PHONY: get-sentry-patch diff --git a/README.getsentry.md b/README.getsentry.md new file mode 100644 index 0000000000..c7824e1ce9 --- /dev/null +++ b/README.getsentry.md @@ -0,0 +1,71 @@ +# Sentry Modifications + +- File attachments support for MacOS and Windows. Based on changes made in + https://github.com/Youw/crashpad/, distributed with Apache 2.0 License. +- Add `throws` declaration to `memfd_create` for compatibility with different + libc versions. +- Build System Changes Listed Below. +- MinGW build support. + +# Build System Changes + +In order to minimize external dependencies, and to better integrate with +`sentry-native`, this fork replaced usage of `depo_tools` with explicit +submodules, and added CMake files for building. + +Both submodules and CMake files currently only support building on macOS and +Windows, and do only export the necessary libraries and executables to +integrate the crashpad client. + +When updating this fork, make sure to keep the files in sync, as explained +below. + +## Submodules + +For macOS and Windows support, only `third_party/mini_chromium` and +`third_party/zlib` are needed. + +The specific submodule commit hashes can be found in the `./DEPS` file. + +## CMake Integration + +To allow building crashpad with CMake, the following CMake files were created +by manually translating the `BUILD.gn` files in the same folders (and following +included files): + +- `./CMakeLists.txt` +- `./client/CMakeLists.txt` +- `./compat/CMakeLists.txt` +- `./handler/CMakeLists.txt` +- `./minidump/CMakeLists.txt` +- `./snapshot/CMakeLists.txt` +- `./third_party/getopt/CMakeLists.txt` +- `./third_party/mini_chromium/CMakeLists.txt` +- `./third_party/zlib/CMakeLists.txt` +- `./tools/CMakeLists.txt` +- `./util/CMakeLists.txt` + +The important thing here is to keep the list of source files in sync when +updating. + +## MinGW Changes + +MinGW support adds the following files which need to be kept in sync. + +- `compat/mingw/` +- `third_party/mini_chromium/utf_string_conversion_utils.mingw.cc` + +## Building for iOS + +Build support for iOS, or Xcode in general is still a work in progress. +Once complete, creating a iOS compatible Xcode project should be as easy as: + + cmake -B cmakebuild -GXcode -DCMAKE_SYSTEM_NAME=iOS + +See the [upstream CMake Docs on iOS](https://cmake.org/cmake/help/v3.17/manual/cmake-toolchains.7.html#cross-compiling-for-ios-tvos-or-watchos) for further info. + +# How To Update + +- Bump the submodules to the commit hashes specified in `./DEPS` +- Go through the changes in `BUILD.gn` files, and apply them to the + corresponding `CMakeLists.txt`. See the list above. diff --git a/README.md b/README.md index b20777bbf8..841f7fdf82 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@