Skip to content

Commit 164ead8

Browse files
committed
(conan-io#5536) sentry-crashpad: add sentry-crashpad recipe
* sentry-crashpad: add sentry-crashpad recipe * sentry-crashpad: fix 0.2.9 * sentry-crashpad: drop Apple * sentry-crashpad: require at least MSVC2017 * sentry-crashpad: copy correct license * sentry-crashpad: with_tls is only valid for Linux and Android * sentry-native: fix usage of with_tls
1 parent 84e4a65 commit 164ead8

11 files changed

+368
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
cmake_minimum_required(VERSION 2.8.11)
2+
project(cmake_wrapper)
3+
4+
include("${CMAKE_BINARY_DIR}/conanbuildinfo.cmake")
5+
conan_basic_setup()
6+
7+
add_subdirectory(source_subfolder/external/crashpad)
+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
sources:
2+
"0.4.9":
3+
url: "https://github.com/getsentry/sentry-native/releases/download/0.4.9/sentry-native.zip"
4+
sha256: "559344bad846b7868c182b22df0cd9869c31ebf46a222ac7a6588aab0211af7d"
5+
"0.4.8":
6+
url: "https://github.com/getsentry/sentry-native/releases/download/0.4.8/sentry-native.zip"
7+
sha256: "35afb62eecc5e719187c81f5c89b4e3d3c45c7b3c1597836202989fa40c79178"
8+
"0.4.7":
9+
url: "https://github.com/getsentry/sentry-native/releases/download/0.4.7/sentry-native.zip"
10+
sha256: "fb16658b250c342ed05e4d2edeff8ec806d9db758dfa188b78070bdfaf54f598"
11+
"0.4.1":
12+
url: "https://github.com/getsentry/sentry-native/releases/download/0.4.1/sentry-native.zip"
13+
sha256: "ffeec2a8aa6d2f274123cd16c62ad6d5d4c6f993e44e9e2f88210261ccb51fcc"
14+
"0.2.6":
15+
url: "https://github.com/getsentry/sentry-native/releases/download/0.2.6/sentry-native-0.2.6.zip"
16+
sha256: "0d93bd77f70a64f3681d4928dfca6b327374218a84d33ee31489114d8e4716c0"
17+
patches:
18+
"0.4.9":
19+
- patch_file: "patches/0.4.9-0001-missing-installed-headers.patch"
20+
base_path: "source_subfolder"
21+
"0.4.8":
22+
- patch_file: "patches/0.4.7-0001-missing-installed-headers.patch"
23+
base_path: "source_subfolder"
24+
"0.4.7":
25+
- patch_file: "patches/0.4.7-0001-missing-installed-headers.patch"
26+
base_path: "source_subfolder"
27+
"0.4.1":
28+
- patch_file: "patches/0.4.1-0001-missing-installed-headers.patch"
29+
base_path: "source_subfolder"
30+
"0.2.6":
31+
- patch_file: "patches/0.2.6-0001-missing-installed-headers.patch"
32+
base_path: "source_subfolder"
+132
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
import os
2+
from conans import ConanFile, CMake, tools
3+
from conans.errors import ConanInvalidConfiguration
4+
5+
required_conan_version = ">=1.28.0"
6+
7+
8+
class SentryCrashpadConan(ConanFile):
9+
name = "sentry-crashpad"
10+
description = "Crashpad is a crash-reporting system."
11+
url = "https://github.com/conan-io/conan-center-index"
12+
homepage = "https://github.com/getsentry/sentry-native"
13+
license = "Apache-2.0"
14+
topics = ("conan", "crashpad", "error-reporting", "crash-reporting")
15+
provides = "crashpad", "mini_chromium"
16+
settings = "os", "arch", "compiler", "build_type"
17+
options = {
18+
"fPIC": [True, False],
19+
"with_tls": ["openssl", False],
20+
}
21+
default_options = {
22+
"fPIC": True,
23+
"with_tls": "openssl",
24+
}
25+
exports_sources = "CMakeLists.txt", "patches/*"
26+
generators = "cmake"
27+
28+
_cmake = None
29+
30+
@property
31+
def _source_subfolder(self):
32+
return "source_subfolder"
33+
34+
def config_options(self):
35+
if self.settings.os == "Windows":
36+
del self.options.fPIC
37+
if self.settings.os not in ("Linux", "Android") or tools.Version(self.version) < "0.4":
38+
del self.options.with_tls
39+
40+
def requirements(self):
41+
self.requires("zlib/1.2.11")
42+
if self.options.get_safe("with_tls"):
43+
self.requires("openssl/1.1.1k")
44+
45+
def validate(self):
46+
if self.settings.compiler.cppstd:
47+
tools.check_min_cppstd(self, 11)
48+
49+
if tools.is_apple_os(self.settings.os):
50+
# FIXME: add Apple support
51+
raise ConanInvalidConfiguration("This recipe does not support Apple.")
52+
53+
if self.settings.os == "Linux":
54+
if self.settings.compiler == "gcc" and tools.Version(self.settings.compiler.version) < 5:
55+
# FIXME: need to test for availability of SYS_memfd_create syscall (Linux kernel >= 3.17)
56+
raise ConanInvalidConfiguration("sentry-crashpad needs SYS_memfd_create syscall support.")
57+
58+
if self.settings.compiler == "Visual Studio" and tools.Version(self.settings.compiler.version) < 15:
59+
raise ConanInvalidConfiguration("Require at least Visual Studio 2017 (15)")
60+
61+
def source(self):
62+
tools.get(**self.conan_data["sources"][self.version], destination=self._source_subfolder)
63+
64+
def _configure_cmake(self):
65+
if self._cmake:
66+
return self._cmake
67+
self._cmake = CMake(self)
68+
self._cmake.definitions["CRASHPAD_ENABLE_INSTALL"] = True
69+
self._cmake.definitions["CRASHPAD_ENABLE_INSTALL_DEV"] = True
70+
self._cmake.definitions["CRASHPAD_ZLIB_SYSTEM"] = True
71+
self._cmake.configure()
72+
return self._cmake
73+
74+
def build(self):
75+
for patch in self.conan_data.get("patches", {}).get(self.version, []):
76+
tools.patch(**patch)
77+
if tools.Version(self.version) > "0.4":
78+
openssl_repl = "find_package(OpenSSL REQUIRED)" if self.options.get_safe("with_tls") else ""
79+
tools.replace_in_file(os.path.join(self._source_subfolder, "external", "crashpad", "CMakeLists.txt"),
80+
"find_package(OpenSSL)", openssl_repl)
81+
cmake = self._configure_cmake()
82+
cmake.build()
83+
84+
def package(self):
85+
self.copy("LICENSE", dst="licenses", src=os.path.join(self._source_subfolder, "external", "crashpad"))
86+
cmake = self._configure_cmake()
87+
cmake.install()
88+
89+
tools.rmdir(os.path.join(self.package_folder, "lib", "cmake"))
90+
tools.remove_files_by_mask(os.path.join(self.package_folder, "bin"), "*.pdb")
91+
92+
def package_info(self):
93+
self.cpp_info.names["cmake_find_package"] = "crashpad"
94+
self.cpp_info.names["cmake_find_package_multi"] = "crashpad"
95+
self.cpp_info.filenames["cmake_find_package"] = "crashpad"
96+
self.cpp_info.filenames["cmake_find_package_multi"] = "crashpad"
97+
98+
self.cpp_info.components["mini_chromium"].includedirs.append(os.path.join("include", "crashpad", "mini_chromium"))
99+
self.cpp_info.components["mini_chromium"].libs = ["mini_chromium"]
100+
if self.settings.os in ("Linux", "FreeBSD"):
101+
self.cpp_info.components["mini_chromium"].system_libs.append("pthread")
102+
103+
self.cpp_info.components["compat"].includedirs.append(os.path.join("include", "crashpad"))
104+
self.cpp_info.components["compat"].libs = ["crashpad_compat"]
105+
if self.settings.os in ("Linux", "FreeBSD"):
106+
self.cpp_info.components["compat"].system_libs.append("dl")
107+
108+
self.cpp_info.components["util"].libs = ["crashpad_util"]
109+
self.cpp_info.components["util"].requires = ["compat", "mini_chromium", "zlib::zlib"]
110+
if self.settings.os in ("Linux", "FreeBSD"):
111+
self.cpp_info.components["util"].system_libs.extend(["pthread", "rt"])
112+
if self.options.get_safe("with_tls") == "openssl":
113+
self.cpp_info.components["util"].requires.append("openssl::openssl")
114+
115+
self.cpp_info.components["client"].libs = ["crashpad_client"]
116+
self.cpp_info.components["client"].requires = ["util", "mini_chromium"]
117+
118+
self.cpp_info.components["snapshot"].libs = ["crashpad_snapshot"]
119+
self.cpp_info.components["snapshot"].requires = ["client", "compat", "util", "mini_chromium"]
120+
121+
self.cpp_info.components["minidump"].libs = ["crashpad_minidump"]
122+
self.cpp_info.components["minidump"].requires = ["compat", "snapshot", "util", "mini_chromium"]
123+
124+
if tools.Version(self.version) > "0.3":
125+
self.cpp_info.components["handler"].libs = ["crashpad_handler_lib"]
126+
self.cpp_info.components["handler"].requires = ["compat", "minidump", "snapshot", "util", "mini_chromium"]
127+
128+
self.cpp_info.components["tools"].libs = ["crashpad_tools"]
129+
130+
bin_path = os.path.join(self.package_folder, "bin")
131+
self.output.info("Appending PATH environment variable: {}".format(bin_path))
132+
self.env_info.PATH.append(bin_path)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
--- external/crashpad/compat/CMakeLists.txt
2+
+++ external/crashpad/compat/CMakeLists.txt
3+
@@ -108,12 +108,13 @@
4+
endif()
5+
6+
if(LINUX OR ANDROID)
7+
- target_include_directories(crashpad_compat ${TI_YPE} "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/linux>")
8+
+ target_include_directories(crashpad_compat ${TI_TYPE} "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/linux>")
9+
+ target_link_libraries(crashpad_compat ${TI_TYPE} ${CMAKE_DL_LIBS})
10+
endif()
11+
12+
if(ANDROID)
13+
- target_include_directories(crashpad_compat ${TI_YPE} "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/android>")
14+
+ target_include_directories(crashpad_compat ${TI_TYPE} "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/android>")
15+
endif()
16+
17+
set_property(TARGET crashpad_compat PROPERTY EXPORT_NAME compat)
18+
add_library(crashpad::compat ALIAS crashpad_compat)
19+
--- external/crashpad/third_party/mini_chromium/CMakeLists.txt
20+
+++ external/crashpad/third_party/mini_chromium/CMakeLists.txt
21+
@@ -172,3 +172,7 @@
22+
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/crashpad"
23+
FILES_MATCHING PATTERN "*.h"
24+
)
25+
+crashpad_install_dev(DIRECTORY build
26+
+ DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/crashpad/mini_chromium"
27+
+ FILES_MATCHING PATTERN "*.h"
28+
+)
29+
--- external/crashpad/util/CMakeLists.txt
30+
+++ external/crashpad/util/CMakeLists.txt
31+
@@ -237,7 +237,7 @@
32+
linux/thread_info.cc
33+
linux/thread_info.h
34+
linux/traits.h
35+
- misc/capture_context_linux.S
36+
+ misc/capture_context_linux.S misc/time_linux.cc
37+
misc/paths_linux.cc
38+
posix/process_info_linux.cc
39+
process/process_memory_linux.cc
40+
@@ -353,7 +353,7 @@
41+
target_include_directories(crashpad_util PRIVATE
42+
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}>
43+
)
44+
target_link_libraries(crashpad_util
45+
PRIVATE
46+
$<BUILD_INTERFACE:crashpad_interface>
47+
PUBLIC
48+
@@ -371,6 +371,10 @@
49+
)
50+
endif()
51+
52+
+if(LINUX)
53+
+ target_link_libraries(crashpad_util PRIVATE rt pthread)
54+
+endif()
55+
+
56+
if(WIN32)
57+
target_link_libraries(crashpad_util PRIVATE user32 version winhttp)
58+
if(MSVC)
59+
@@ -395,3 +399,7 @@
60+
add_library(crashpad::util ALIAS crashpad_util)
61+
62+
crashpad_install_target(crashpad_util)
63+
+crashpad_install_dev(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/"
64+
+ DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/crashpad/util"
65+
+ FILES_MATCHING PATTERN "*.h"
66+
+)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
--- external/crashpad/third_party/mini_chromium/CMakeLists.txt
2+
+++ external/crashpad/third_party/mini_chromium/CMakeLists.txt
3+
@@ -204,3 +204,7 @@
4+
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/crashpad"
5+
FILES_MATCHING PATTERN "*.h"
6+
)
7+
+crashpad_install_dev(DIRECTORY build
8+
+ DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/crashpad/mini_chromium"
9+
+ FILES_MATCHING PATTERN "*.h"
10+
+)
11+
--- external/crashpad/util/CMakeLists.txt
12+
+++ external/crashpad/util/CMakeLists.txt
13+
@@ -438,3 +438,7 @@
14+
add_library(crashpad::util ALIAS crashpad_util)
15+
16+
crashpad_install_target(crashpad_util)
17+
+crashpad_install_dev(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/"
18+
+ DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/crashpad/util"
19+
+ FILES_MATCHING PATTERN "*.h"
20+
+)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
--- external/crashpad/third_party/mini_chromium/CMakeLists.txt
2+
+++ external/crashpad/third_party/mini_chromium/CMakeLists.txt
3+
@@ -209,3 +209,7 @@
4+
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/crashpad"
5+
FILES_MATCHING PATTERN "*.h"
6+
)
7+
+crashpad_install_dev(DIRECTORY build
8+
+ DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/crashpad/mini_chromium"
9+
+ FILES_MATCHING PATTERN "*.h"
10+
+)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
--- external/crashpad/third_party/mini_chromium/CMakeLists.txt
2+
+++ external/crashpad/third_party/mini_chromium/CMakeLists.txt
3+
@@ -207,3 +207,7 @@
4+
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/crashpad"
5+
FILES_MATCHING PATTERN "*.h"
6+
)
7+
+crashpad_install_dev(DIRECTORY build
8+
+ DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/crashpad/mini_chromium"
9+
+ FILES_MATCHING PATTERN "*.h"
10+
+)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
cmake_minimum_required(VERSION 3.1)
2+
project(test_package)
3+
4+
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
5+
conan_basic_setup(TARGETS)
6+
7+
find_package(crashpad REQUIRED CONFIG)
8+
9+
add_executable(${PROJECT_NAME} test_package.cpp)
10+
target_link_libraries(${PROJECT_NAME} PRIVATE crashpad::client)
11+
set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
from conans import ConanFile, CMake, tools
2+
import os
3+
4+
5+
class TestPackageConan(ConanFile):
6+
settings = "os", "compiler", "build_type", "arch"
7+
generators = "cmake", "cmake_find_package_multi"
8+
9+
def build(self):
10+
cmake = CMake(self)
11+
cmake.configure()
12+
cmake.build()
13+
14+
def test(self):
15+
if not tools.cross_building(self.settings):
16+
test_env_dir = "test_env"
17+
tools.mkdir(test_env_dir)
18+
bin_path = os.path.join("bin", "test_package")
19+
handler_exe = "crashpad_handler.exe" if self.settings.os == "Windows" else "crashpad_handler"
20+
handler_bin_path = os.path.join(self.deps_cpp_info["sentry-crashpad"].rootpath, "bin", handler_exe)
21+
self.run("%s %s/db %s" % (bin_path, test_env_dir, handler_bin_path), run_environment=True)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#include <map>
2+
#include <string>
3+
#include <vector>
4+
5+
#ifdef _WIN32
6+
#include <cwchar>
7+
#endif
8+
9+
#include "client/crashpad_client.h"
10+
#include "client/settings.h"
11+
12+
bool startCrashpad(const base::FilePath &db,
13+
const base::FilePath &handler) {
14+
std::string url("http://localhost");
15+
std::map<std::string, std::string> annotations;
16+
std::vector<std::string> arguments;
17+
18+
crashpad::CrashpadClient client;
19+
return client.StartHandler(
20+
handler,
21+
db,
22+
db,
23+
url,
24+
annotations,
25+
arguments,
26+
true,
27+
false
28+
);
29+
}
30+
31+
int main(int argc, char* argv[]) {
32+
if (argc != 3) {
33+
return 2;
34+
}
35+
36+
#ifdef _WIN32
37+
wchar_t ws[1024];
38+
swprintf(ws, 1024, L"%hs", argv[1]);
39+
base::FilePath db(ws);
40+
swprintf(ws, 1024, L"%hs", argv[2]);
41+
base::FilePath handler(ws);
42+
#else
43+
base::FilePath db(argv[1]);
44+
base::FilePath handler(argv[2]);
45+
#endif
46+
47+
return startCrashpad(db, handler) ? 0 : 1;
48+
}

recipes/sentry-crashpad/config.yml

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
versions:
2+
"0.4.9":
3+
folder: all
4+
"0.4.8":
5+
folder: all
6+
"0.4.7":
7+
folder: all
8+
"0.4.1":
9+
folder: all
10+
"0.2.6":
11+
folder: all

0 commit comments

Comments
 (0)