forked from chromium/crashpad
-
Notifications
You must be signed in to change notification settings - Fork 51
build: Add CMake files for crashpad #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
0b0064b
build: add CMake files for crashpad
Swatinem da600dd
add explicit submodule for mini_chromium
Swatinem c12bab9
make cmake builds work on windows
Swatinem 1f43a25
review feedback, add separate getsentry README
Swatinem ea681b9
better document changes, add update instructions
Swatinem File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| [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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| cmake_minimum_required(VERSION 3.0) | ||
| project(crashpad LANGUAGES C CXX) | ||
|
|
||
| if(WIN32) | ||
| enable_language(ASM_MASM) | ||
| else() | ||
| enable_language(ASM) | ||
| endif() | ||
|
|
||
| set(CMAKE_CXX_STANDARD 14) | ||
| set(CMAKE_CXX_STANDARD_REQUIRED True) | ||
|
|
||
| if(CMAKE_SYSTEM_NAME STREQUAL "Linux") | ||
| set(LINUX TRUE) | ||
| endif() | ||
|
|
||
| include_directories("${CMAKE_CURRENT_SOURCE_DIR}") | ||
| include_directories("${CMAKE_CURRENT_SOURCE_DIR}/third_party/mini_chromium/mini_chromium") | ||
|
|
||
| # These should really be in `compat`, but we want them for the whole project | ||
| if(APPLE) | ||
| include_directories(SYSTEM "compat/mac") | ||
| else() | ||
| include_directories(PUBLIC "compat/non_mac") | ||
| endif() | ||
|
|
||
| if(LINUX OR ANDROID) | ||
| include_directories(SYSTEM "compat/linux") | ||
| endif() | ||
| if(ANDROID) | ||
| include_directories(SYSTEM "compat/android") | ||
| endif() | ||
|
|
||
| if(WIN32) | ||
| include_directories(SYSTEM "compat/win") | ||
| else() | ||
| include_directories(PUBLIC "compat/non_win") | ||
| endif() | ||
|
|
||
| if(NOT LINUX AND NOT ANDROID) | ||
| include_directories(SYSTEM "compat/non_elf") | ||
| endif() | ||
|
|
||
| if(WIN32) | ||
| add_definitions( | ||
| /DNOMINMAX | ||
| /DUNICODE | ||
| /DWIN32_LEAN_AND_MEAN | ||
| /D_CRT_SECURE_NO_WARNINGS | ||
| /D_HAS_EXCEPTIONS=0 | ||
| /D_UNICODE | ||
| /FS | ||
| /W4 | ||
| /WX | ||
| /Zi | ||
| /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. | ||
| ) | ||
| endif() | ||
|
|
||
| add_subdirectory(client) | ||
| add_subdirectory(compat) | ||
| add_subdirectory(handler) | ||
| add_subdirectory(minidump) | ||
| add_subdirectory(snapshot) | ||
| add_subdirectory(tools) | ||
| add_subdirectory(util) | ||
| add_subdirectory(third_party/mini_chromium) | ||
|
|
||
| if(WIN32) | ||
| add_subdirectory(third_party/getopt) | ||
| add_subdirectory(third_party/zlib) | ||
| endif() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| # 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 | ||
|
|
||
| # 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/lib/CMakeLists.txt` | ||
| - `./tools/CMakeLists.txt` | ||
| - `./util/CMakeLists.txt` | ||
|
|
||
| The important thing here is to keep the list of source files in sync when | ||
| updating. | ||
|
|
||
| # 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. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| list(APPEND CLIENT_SOURCES | ||
| annotation.cc | ||
| annotation.h | ||
| annotation_list.cc | ||
| annotation_list.h | ||
| crash_report_database.cc | ||
| crash_report_database.h | ||
| crashpad_client.h | ||
| crashpad_info.cc | ||
| crashpad_info.h | ||
| prune_crash_reports.cc | ||
| prune_crash_reports.h | ||
| settings.cc | ||
| settings.h | ||
| simple_address_range_bag.h | ||
| simple_string_dictionary.h | ||
| simulate_crash.h | ||
| ) | ||
|
|
||
| if(APPLE) | ||
| list(APPEND CLIENT_SOURCES | ||
| crash_report_database_mac.mm | ||
| crashpad_client_mac.cc | ||
| simulate_crash_mac.cc | ||
| simulate_crash_mac.h | ||
| ) | ||
| endif() | ||
|
|
||
| if(LINUX OR ANDROID) | ||
| list(APPEND CLIENT_SOURCES | ||
| crashpad_client_linux.cc | ||
| simulate_crash_linux.h | ||
| client_argv_handling.cc | ||
| client_argv_handling.h | ||
| crashpad_info_note.S | ||
| crash_report_database_generic.cc | ||
| ) | ||
| endif() | ||
|
|
||
| if(WIN32) | ||
| list(APPEND CLIENT_SOURCES | ||
| crash_report_database_win.cc | ||
| crashpad_client_win.cc | ||
| simulate_crash_win.h | ||
| ) | ||
| endif() | ||
|
|
||
| add_library(crashpad_client STATIC ${CLIENT_SOURCES}) | ||
| target_link_libraries(crashpad_client | ||
| crashpad_compat | ||
| crashpad_util | ||
| mini_chromium | ||
| ) | ||
|
|
||
| if(WIN32) | ||
| target_link_libraries(crashpad_client "rpcrt4") | ||
| target_compile_options(crashpad_client PUBLIC "/wd4201") | ||
| endif() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,89 @@ | ||
| list(APPEND COMPAT_SOURCES "") | ||
|
|
||
| if(APPLE) | ||
| list(APPEND COMPAT_SOURCES | ||
| mac/AvailabilityMacros.h | ||
| mac/kern/exc_resource.h | ||
| mac/mach-o/loader.h | ||
| mac/mach/mach.h | ||
| mac/sys/resource.h | ||
| ) | ||
| else() | ||
| list(APPEND COMPAT_SOURCES | ||
| non_mac/mach-o/loader.h | ||
| non_mac/mach/mach.h | ||
| non_mac/mach/machine.h | ||
| non_mac/mach/vm_prot.h | ||
| ) | ||
| endif() | ||
|
|
||
| if(LINUX OR ANDROID) | ||
| list(APPEND COMPAT_SOURCES | ||
| linux/signal.h | ||
| linux/sys/mman.cc | ||
| linux/sys/mman.h | ||
| linux/sys/ptrace.h | ||
| linux/sys/user.h | ||
| ) | ||
| endif() | ||
|
|
||
| if(ANDROID) | ||
| list(APPEND COMPAT_SOURCES | ||
| android/android/api-level.cc | ||
| android/android/api-level.h | ||
| android/dlfcn_internal.cc | ||
| android/dlfcn_internal.h | ||
| android/elf.h | ||
| android/linux/elf.h | ||
| android/linux/prctl.h | ||
| android/linux/ptrace.h | ||
| android/sched.h | ||
| android/sys/epoll.cc | ||
| android/sys/epoll.h | ||
| android/sys/mman.cc | ||
| android/sys/mman.h | ||
| android/sys/syscall.h | ||
| android/sys/user.h | ||
| ) | ||
| endif() | ||
|
|
||
| if(WIN32) | ||
| list(APPEND COMPAT_SOURCES | ||
| win/getopt.h | ||
| win/strings.cc | ||
| win/strings.h | ||
| win/sys/types.h | ||
| win/time.cc | ||
| win/time.h | ||
| win/winbase.h | ||
| win/winnt.h | ||
| win/winternl.h | ||
| ) | ||
| else() | ||
| list(APPEND COMPAT_SOURCES | ||
| non_win/dbghelp.h | ||
| non_win/minwinbase.h | ||
| non_win/timezoneapi.h | ||
| non_win/verrsrc.h | ||
| non_win/windows.h | ||
| non_win/winnt.h | ||
| ) | ||
| endif() | ||
|
|
||
| if(NOT LINUX AND NOT ANDROID) | ||
| list(APPEND COMPAT_SOURCES | ||
| non_elf/elf.h | ||
| ) | ||
| endif() | ||
|
|
||
| if(APPLE) | ||
| add_library(crashpad_compat INTERFACE) | ||
| list(TRANSFORM COMPAT_SOURCES PREPEND "${CMAKE_CURRENT_SOURCE_DIR}/") | ||
| target_sources(crashpad_compat INTERFACE ${COMPAT_SOURCES}) | ||
| else() | ||
| add_library(crashpad_compat STATIC ${COMPAT_SOURCES}) | ||
| endif() | ||
|
|
||
| if(WIN32) | ||
| target_link_libraries(crashpad_compat getopt) | ||
| endif() |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.