From 5ad571844d139a28af2745fb4e653f04fffad07e Mon Sep 17 00:00:00 2001 From: Eric Riff <57375845+ericriff@users.noreply.github.com> Date: Thu, 15 Jul 2021 04:32:29 -0300 Subject: [PATCH] (#6294) Build sentry-native with CXX 14 * Build sentry-native with CXX 14 since sentry-crashpad, one of its possible dependencies, exposes CXX 14 code on its headers. This will be addressed in upstream sentry-native https://github.com/getsentry/sentry-native/issues/574 * Support breakpad and sentry-breakpad as backends * Add minimum compiler version check / raise. * Add pkgconf as build_requirement if breakpad is set as backend --- recipes/sentry-native/all/conandata.yml | 10 ++++- recipes/sentry-native/all/conanfile.py | 41 ++++++++++++++++--- ....2.6-0002-set-cmake-cxx-standard-14.patch} | 2 +- .../all/patches/0.4.10-0002-CXX-14.patch | 14 +++++++ .../all/patches/0.4.7-0002-CXX-14.patch | 14 +++++++ .../all/patches/0.4.8-0002-CXX-14.patch | 14 +++++++ .../all/patches/0.4.9-0002-CXX-14.patch | 14 +++++++ .../all/test_package/CMakeLists.txt | 2 +- 8 files changed, 103 insertions(+), 8 deletions(-) rename recipes/sentry-native/all/patches/{0.2.6-0002-set-cmake-cxx-standard-11.patch => 0.2.6-0002-set-cmake-cxx-standard-14.patch} (91%) create mode 100644 recipes/sentry-native/all/patches/0.4.10-0002-CXX-14.patch create mode 100644 recipes/sentry-native/all/patches/0.4.7-0002-CXX-14.patch create mode 100644 recipes/sentry-native/all/patches/0.4.8-0002-CXX-14.patch create mode 100644 recipes/sentry-native/all/patches/0.4.9-0002-CXX-14.patch diff --git a/recipes/sentry-native/all/conandata.yml b/recipes/sentry-native/all/conandata.yml index cddf62ef025ab..2b0a952903a12 100644 --- a/recipes/sentry-native/all/conandata.yml +++ b/recipes/sentry-native/all/conandata.yml @@ -21,17 +21,25 @@ patches: "0.4.10": - patch_file: "patches/0.4.10-0001-find-conan-qt.patch" base_path: "source_subfolder" + - patch_file: "patches/0.4.10-0002-CXX-14.patch" + base_path: "source_subfolder" "0.4.9": - patch_file: "patches/0.4.9-0001-find-conan-qt.patch" base_path: "source_subfolder" + - patch_file: "patches/0.4.9-0002-CXX-14.patch" + base_path: "source_subfolder" "0.4.8": - patch_file: "patches/0.4.8-0001-find-conan-qt.patch" base_path: "source_subfolder" + - patch_file: "patches/0.4.8-0002-CXX-14.patch" + base_path: "source_subfolder" "0.4.7": - patch_file: "patches/0.4.7-0001-find-conan-qt.patch" base_path: "source_subfolder" + - patch_file: "patches/0.4.7-0002-CXX-14.patch" + base_path: "source_subfolder" "0.2.6": - patch_file: "patches/0.2.6-0001-remove-sentry-handler-dependency.patch" base_path: "source_subfolder" - - patch_file: "patches/0.2.6-0002-set-cmake-cxx-standard-11.patch" + - patch_file: "patches/0.2.6-0002-set-cmake-cxx-standard-14.patch" base_path: "source_subfolder" diff --git a/recipes/sentry-native/all/conanfile.py b/recipes/sentry-native/all/conanfile.py index c7ff296c1cb8a..81e149f87280e 100644 --- a/recipes/sentry-native/all/conanfile.py +++ b/recipes/sentry-native/all/conanfile.py @@ -16,7 +16,7 @@ class SentryNativeConan(ConanFile): topics = ("conan", "breakpad", "crashpad", "error-reporting", "crash-reporting") exports_sources = ["CMakeLists.txt", "patches/*"] - generators = "cmake", "cmake_find_package" + generators = "cmake", "cmake_find_package", "pkg_config" settings = "os", "arch", "compiler", "build_type" options = { "shared": [True, False], @@ -25,6 +25,7 @@ class SentryNativeConan(ConanFile): "transport": ["none", "curl", "winhttp"], "qt": [True, False], "with_crashpad": ["google", "sentry"], + "with_breakpad": ["google", "sentry"], } default_options = { "shared": False, @@ -33,6 +34,8 @@ class SentryNativeConan(ConanFile): "transport": "curl", # overwritten in config_options "qt": False, "with_crashpad": "sentry", + "with_breakpad": "sentry", + } _cmake = None @@ -41,6 +44,15 @@ class SentryNativeConan(ConanFile): def _source_subfolder(self): return "source_subfolder" + @property + def _minimum_compilers_version(self): + return { + "Visual Studio": "15", + "gcc": "5", + "clang": "3.4", + "apple-clang": "5.1", + } + def config_options(self): if self.settings.os == "Windows": del self.options.fPIC @@ -58,8 +70,9 @@ def config_options(self): # 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" + self.options.backend = "breakpad" + elif self.settings.os == "Android": + self.options.backend = "inproc" else: self.options.backend = "inproc" @@ -67,16 +80,30 @@ def configure(self): if self.options.shared: del self.options.fPIC if self.settings.compiler.cppstd: - tools.check_min_cppstd(self, 11) + tools.check_min_cppstd(self, 14) + + minimum_version = self._minimum_compilers_version.get(str(self.settings.compiler), False) + if not minimum_version: + self.output.warn("Compiler is unknown. Assuming it supports C++14.") + elif tools.Version(self.settings.compiler.version) < minimum_version: + raise ConanInvalidConfiguration("Build requires support for C++14. Minimum version for {} is {}" + .format(str(self.settings.compiler), minimum_version)) + 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.backend != "breakpad": + del self.options.with_breakpad 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": raise ConanInvalidConfiguration("apple-clang < 10.0 not supported") + def build_requirements(self): + if self.options.backend == "breakpad": + self.build_requires("pkgconf/1.7.4") + def requirements(self): if self.options.transport == "curl": self.requires("libcurl/7.75.0") @@ -86,7 +113,10 @@ def requirements(self): 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.with_breakpad == "sentry": + self.requires("sentry-breakpad/{}".format(self.version)) + if self.options.with_breakpad == "google": + self.requires("breakpad/cci.20210521") if self.options.qt: self.requires("qt/5.15.2") self.requires("openssl/1.1.1k") @@ -102,6 +132,7 @@ def _configure_cmake(self): self._cmake = CMake(self) self._cmake.definitions["SENTRY_BACKEND"] = self.options.backend self._cmake.definitions["SENTRY_CRASHPAD_SYSTEM"] = True + self._cmake.definitions["SENTRY_BREAKPAD_SYSTEM"] = True self._cmake.definitions["SENTRY_ENABLE_INSTALL"] = True self._cmake.definitions["SENTRY_TRANSPORT"] = self.options.transport self._cmake.definitions["SENTRY_PIC"] = self.options.get_safe("fPIC", True) diff --git a/recipes/sentry-native/all/patches/0.2.6-0002-set-cmake-cxx-standard-11.patch b/recipes/sentry-native/all/patches/0.2.6-0002-set-cmake-cxx-standard-14.patch similarity index 91% rename from recipes/sentry-native/all/patches/0.2.6-0002-set-cmake-cxx-standard-11.patch rename to recipes/sentry-native/all/patches/0.2.6-0002-set-cmake-cxx-standard-14.patch index d062025163bb3..c6ec8ddfc9472 100644 --- a/recipes/sentry-native/all/patches/0.2.6-0002-set-cmake-cxx-standard-11.patch +++ b/recipes/sentry-native/all/patches/0.2.6-0002-set-cmake-cxx-standard-14.patch @@ -7,7 +7,7 @@ index c41d902..4793e9b 100644 endif() +if(NOT CMAKE_CXX_STANDARD) -+ set(CMAKE_CXX_STANDARD 11) ++ set(CMAKE_CXX_STANDARD 14) +endif() + include(GNUInstallDirs) diff --git a/recipes/sentry-native/all/patches/0.4.10-0002-CXX-14.patch b/recipes/sentry-native/all/patches/0.4.10-0002-CXX-14.patch new file mode 100644 index 0000000000000..34b3b00506093 --- /dev/null +++ b/recipes/sentry-native/all/patches/0.4.10-0002-CXX-14.patch @@ -0,0 +1,14 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 696d270..006bf68 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -30,7 +30,7 @@ + endif() + + if(NOT CMAKE_CXX_STANDARD) +- set(CMAKE_CXX_STANDARD 11) ++ set(CMAKE_CXX_STANDARD 14) + endif() + + include(GNUInstallDirs) + diff --git a/recipes/sentry-native/all/patches/0.4.7-0002-CXX-14.patch b/recipes/sentry-native/all/patches/0.4.7-0002-CXX-14.patch new file mode 100644 index 0000000000000..34b3b00506093 --- /dev/null +++ b/recipes/sentry-native/all/patches/0.4.7-0002-CXX-14.patch @@ -0,0 +1,14 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 696d270..006bf68 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -30,7 +30,7 @@ + endif() + + if(NOT CMAKE_CXX_STANDARD) +- set(CMAKE_CXX_STANDARD 11) ++ set(CMAKE_CXX_STANDARD 14) + endif() + + include(GNUInstallDirs) + diff --git a/recipes/sentry-native/all/patches/0.4.8-0002-CXX-14.patch b/recipes/sentry-native/all/patches/0.4.8-0002-CXX-14.patch new file mode 100644 index 0000000000000..34b3b00506093 --- /dev/null +++ b/recipes/sentry-native/all/patches/0.4.8-0002-CXX-14.patch @@ -0,0 +1,14 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 696d270..006bf68 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -30,7 +30,7 @@ + endif() + + if(NOT CMAKE_CXX_STANDARD) +- set(CMAKE_CXX_STANDARD 11) ++ set(CMAKE_CXX_STANDARD 14) + endif() + + include(GNUInstallDirs) + diff --git a/recipes/sentry-native/all/patches/0.4.9-0002-CXX-14.patch b/recipes/sentry-native/all/patches/0.4.9-0002-CXX-14.patch new file mode 100644 index 0000000000000..34b3b00506093 --- /dev/null +++ b/recipes/sentry-native/all/patches/0.4.9-0002-CXX-14.patch @@ -0,0 +1,14 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 696d270..006bf68 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -30,7 +30,7 @@ + endif() + + if(NOT CMAKE_CXX_STANDARD) +- set(CMAKE_CXX_STANDARD 11) ++ set(CMAKE_CXX_STANDARD 14) + endif() + + include(GNUInstallDirs) + diff --git a/recipes/sentry-native/all/test_package/CMakeLists.txt b/recipes/sentry-native/all/test_package/CMakeLists.txt index 142b41397dd63..2f94c645a3640 100644 --- a/recipes/sentry-native/all/test_package/CMakeLists.txt +++ b/recipes/sentry-native/all/test_package/CMakeLists.txt @@ -8,4 +8,4 @@ find_package(sentry REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.cpp) target_link_libraries(${PROJECT_NAME} sentry::sentry) -set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) +set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 14)