Skip to content

Commit

Permalink
(conan-io#5717) sentry-native: add option to switch crashpad dependency
Browse files Browse the repository at this point in the history
* sentry-native: add option to switch crashpad dependency

* sentry-native: fix compatibility with sentry-crashpad

* sentry-native: add missing patch
  • Loading branch information
madebr committed Jun 21, 2021
1 parent 640fc3d commit 4de1ba9
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 13 deletions.
9 changes: 6 additions & 3 deletions recipes/sentry-native/all/conandata.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,14 @@ sources:
sha256: "0d93bd77f70a64f3681d4928dfca6b327374218a84d33ee31489114d8e4716c0"
patches:
"0.4.9":
- patch_file: "patches/find-conan-qt-0.4.9.patch"
- patch_file: "patches/0.4.9-0001-find-conan-qt.patch"
base_path: "source_subfolder"
"0.4.8":
- patch_file: "patches/find-conan-qt-0.4.8.patch"
- patch_file: "patches/0.4.8-0001-find-conan-qt.patch"
base_path: "source_subfolder"
"0.4.7":
- patch_file: "patches/find-conan-qt-0.4.7.patch"
- patch_file: "patches/0.4.7-0001-find-conan-qt.patch"
base_path: "source_subfolder"
"0.2.6":
- patch_file: "patches/0.2.6-0001-remove-sentry-handler-dependency.patch"
base_path: "source_subfolder"
42 changes: 32 additions & 10 deletions recipes/sentry-native/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import os
import glob
from conans import ConanFile, CMake, tools
from conans.errors import ConanInvalidConfiguration

required_conan_version = ">=1.28.0"
required_conan_version = ">=1.33.0"


class SentryNativeConan(ConanFile):
Expand All @@ -25,13 +24,15 @@ class SentryNativeConan(ConanFile):
"backend": ["none", "inproc", "crashpad", "breakpad"],
"transport": ["none", "curl", "winhttp"],
"qt": [True, False],
"with_crashpad": ["google", "sentry"],
}
default_options = {
"shared": False,
"fPIC": True,
"backend": "inproc",
"transport": "curl",
"backend": "inproc", # overwritten in config_options
"transport": "curl", # overwritten in config_options
"qt": False,
"with_crashpad": "sentry",
}

_cmake = None
Expand All @@ -41,17 +42,36 @@ def _source_subfolder(self):
return "source_subfolder"

def config_options(self):
# FIXME: set default backend for each platform (missing breakpad recipe)
if self.settings.os == "Windows":
del self.options.fPIC

# Configure default transport
if self.settings.os == "Windows":
self.options.transport = "winhttp"
elif self.settings.os in ("FreeBSD", "Linux") or self.settings.os == "Macos": # Don't use tools.is_apple_os(os) here
self.options.transport = "curl"
else:
self.options.transport = "none"

# Configure default backend
if self.settings.os == "Windows" or self.settings.os == "Macos": # Don't use tools.is_apple_os(os) here
# FIXME: for self.version < 0.4: default backend is "breakpad" when building with MSVC for Windows xp; else: backend=none
self.options.backend = "crashpad"
elif self.settings.os in ("FreeBSD", "Linux"):
# FIXME: default backend on Linux is "breakpad"
self.options.backend = "inproc" # Should be "breakpad"
else:
self.options.backend = "inproc"

def configure(self):
if self.options.shared:
del self.options.fPIC
if self.settings.compiler.cppstd:
tools.check_min_cppstd(self, 11)
if self.options.backend == "inproc" and self.settings.os == "Windows" and tools.Version(self.version) < "0.4":
raise ConanInvalidConfiguration("The in-process backend is not supported on Windows")
if self.options.backend != "crashpad":
del self.options.with_crashpad
if self.options.transport == "winhttp" and self.settings.os != "Windows":
raise ConanInvalidConfiguration("The winhttp transport is only supported on Windows")
if tools.Version(self.version) >= "0.4.7" and self.settings.compiler == "apple-clang" and tools.Version(self.settings.compiler.version) < "10.0":
Expand All @@ -61,7 +81,10 @@ def requirements(self):
if self.options.transport == "curl":
self.requires("libcurl/7.75.0")
if self.options.backend == "crashpad":
self.requires("crashpad/cci.20210507")
if self.options.with_crashpad == "sentry":
self.requires("sentry-crashpad/{}".format(self.version))
if self.options.with_crashpad == "google":
self.requires("crashpad/cci.20210507")
elif self.options.backend == "breakpad":
raise ConanInvalidConfiguration("breakpad not available yet in CCI")
if self.options.qt:
Expand Down Expand Up @@ -97,17 +120,16 @@ def package(self):
cmake = self._configure_cmake()
cmake.install()
tools.rmdir(os.path.join(self.package_folder, "lib", "cmake"))
for pdb in glob.glob(os.path.join(self.package_folder, "bin", "*.pdb")):
os.unlink(pdb)
tools.remove_files_by_mask(os.path.join(self.package_folder, "bin"), "*pdb")

def package_info(self):
self.cpp_info.names["cmake_find_package"] = "sentry"
self.cpp_info.names["cmake_find_package_multi"] = "sentry"
self.cpp_info.libs = ["sentry"]
if self.settings.os in ("Android", "Linux"):
if self.settings.os in ("Android", "FreeBSD", "Linux"):
self.cpp_info.exelinkflags = ["-Wl,-E,--build-id=sha1"]
self.cpp_info.sharedlinkflags = ["-Wl,-E,--build-id=sha1"]
if self.settings.os == "Linux":
if self.settings.os in ("FreeBSD", "Linux"):
self.cpp_info.system_libs = ["pthread", "dl"]
elif self.settings.os == "Android":
self.cpp_info.system_libs = ["dl", "log"]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -307,7 +307,7 @@
DESTINATION "${CMAKE_INSTALL_CMAKEDIR}"
)
endif()
- add_dependencies(sentry crashpad::handler)
+ # add_dependencies(sentry crashpad::handler)
elseif(SENTRY_BACKEND_BREAKPAD)
add_subdirectory(external)
target_include_directories(sentry PRIVATE

0 comments on commit 4de1ba9

Please sign in to comment.