From 2d9b4b8e73d0a608df69a88d8e845816c09246ec Mon Sep 17 00:00:00 2001 From: theirix Date: Tue, 25 Oct 2022 01:06:49 +0300 Subject: [PATCH] (#13628) libnghttp2: add 1.50.0, bump deps * Add nghttp2 1.50.0 * Bump deps * Update for Conan 2.0 Signed-off-by: Uilian Ries * Remove extra files Signed-off-by: Uilian Ries * Use rm_safe from 1.53.0 * Revert "Use rm_safe from 1.53.0" This reverts commit 51ed2486b26c3770efd32620c8550cbbff6e96c7. * Use src for cmake_layout Co-authored-by: Jordan Williams Signed-off-by: Uilian Ries Co-authored-by: Uilian Ries Co-authored-by: Jordan Williams --- recipes/libnghttp2/all/CMakeLists.txt | 7 - recipes/libnghttp2/all/conandata.yml | 22 +-- recipes/libnghttp2/all/conanfile.py | 138 +++++++++--------- .../all/test_package/CMakeLists.txt | 11 +- .../libnghttp2/all/test_package/conanfile.py | 26 ++-- .../all/test_v1_package/CMakeLists.txt | 7 + .../all/test_v1_package/conanfile.py | 17 +++ recipes/libnghttp2/config.yml | 2 + 8 files changed, 117 insertions(+), 113 deletions(-) delete mode 100644 recipes/libnghttp2/all/CMakeLists.txt create mode 100644 recipes/libnghttp2/all/test_v1_package/CMakeLists.txt create mode 100644 recipes/libnghttp2/all/test_v1_package/conanfile.py diff --git a/recipes/libnghttp2/all/CMakeLists.txt b/recipes/libnghttp2/all/CMakeLists.txt deleted file mode 100644 index b71c882d9d33f..0000000000000 --- a/recipes/libnghttp2/all/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -cmake_minimum_required(VERSION 3.1) -project(cmake_wrapper) - -include(conanbuildinfo.cmake) -conan_basic_setup(KEEP_RPATHS) - -add_subdirectory(source_subfolder) diff --git a/recipes/libnghttp2/all/conandata.yml b/recipes/libnghttp2/all/conandata.yml index 8131565e0ca21..3925076a99152 100644 --- a/recipes/libnghttp2/all/conandata.yml +++ b/recipes/libnghttp2/all/conandata.yml @@ -1,4 +1,7 @@ sources: + "1.50.0": + url: "https://github.com/nghttp2/nghttp2/archive/v1.50.0.tar.gz" + sha256: "6de469efc8e9d47059327a6736aebe0a7d73f57e5e37ab4c4f838fb1eebd7889" "1.49.0": url: "https://github.com/nghttp2/nghttp2/archive/v1.49.0.tar.gz" sha256: "744f38f8d6e400a424bf62df449c91e3ffacbae11b5fab99e44a480f5c735ab9" @@ -29,48 +32,29 @@ sources: patches: "1.49.0": - patch_file: "patches/fix-findJemalloc.cmake" - base_path: "source_subfolder" - patch_file: "patches/fix-findLibevent.cmake" - base_path: "source_subfolder" "1.48.0": - patch_file: "patches/fix-findJemalloc.cmake" - base_path: "source_subfolder" - patch_file: "patches/fix-findLibevent.cmake" - base_path: "source_subfolder" "1.47.0": - patch_file: "patches/fix-findJemalloc.cmake" - base_path: "source_subfolder" - patch_file: "patches/fix-findLibevent.cmake" - base_path: "source_subfolder" "1.46.0": - patch_file: "patches/fix-findJemalloc.cmake" - base_path: "source_subfolder" - patch_file: "patches/fix-findLibevent.cmake" - base_path: "source_subfolder" "1.45.1": - patch_file: "patches/fix-findJemalloc.cmake" - base_path: "source_subfolder" - patch_file: "patches/fix-findLibevent.cmake" - base_path: "source_subfolder" "1.43.0": - patch_file: "patches/fix-findJemalloc.cmake" - base_path: "source_subfolder" - patch_file: "patches/fix-findLibevent.cmake" - base_path: "source_subfolder" "1.42.0": - patch_file: "patches/fix-findJemalloc.cmake" - base_path: "source_subfolder" - patch_file: "patches/fix-findLibevent.cmake" - base_path: "source_subfolder" "1.40.0": - patch_file: "patches/fix-findJemalloc.cmake" - base_path: "source_subfolder" - patch_file: "patches/fix-findLibevent.cmake" - base_path: "source_subfolder" "1.39.2": - patch_file: "patches/fix-addNghttp2IncludesPathCMake.patch" - base_path: "source_subfolder" - patch_file: "patches/fix-findJemalloc.cmake" - base_path: "source_subfolder" - patch_file: "patches/fix-findLibevent.cmake" - base_path: "source_subfolder" diff --git a/recipes/libnghttp2/all/conanfile.py b/recipes/libnghttp2/all/conanfile.py index 0029f5d21561e..b3b58ce1c61eb 100644 --- a/recipes/libnghttp2/all/conanfile.py +++ b/recipes/libnghttp2/all/conanfile.py @@ -1,9 +1,15 @@ -from conans import ConanFile, CMake, tools -from conans.errors import ConanInvalidConfiguration -import functools +from conan import ConanFile +from conan.tools.cmake import CMake, CMakeToolchain, CMakeDeps, cmake_layout +from conan.tools.gnu import PkgConfigDeps +from conan.tools.scm import Version +from conan.tools.files import export_conandata_patches, apply_conandata_patches, get, save, replace_in_file, rmdir, copy +from conan.tools.microsoft import is_msvc +from conan.tools.apple import is_apple_os +from conan.errors import ConanInvalidConfiguration import os -required_conan_version = ">=1.36.0" + +required_conan_version = ">=1.52.0" class Nghttp2Conan(ConanFile): @@ -13,7 +19,6 @@ class Nghttp2Conan(ConanFile): url = "https://github.com/conan-io/conan-center-index" homepage = "https://nghttp2.org" license = "MIT" - settings = "os", "arch", "compiler", "build_type" options = { "shared": [True, False], @@ -32,20 +37,8 @@ class Nghttp2Conan(ConanFile): "with_asio": False, } - generators = "cmake", "cmake_find_package", "pkg_config" - - @property - def _source_subfolder(self): - return "source_subfolder" - - @property - def _is_msvc(self): - return str(self.settings.compiler) in ["Visual Studio", "msvc"] - def export_sources(self): - self.copy("CMakeLists.txt") - for patch in self.conan_data.get("patches", {}).get(self.version, []): - self.copy(patch["patch_file"]) + export_conandata_patches(self) def config_options(self): if self.settings.os == "Windows": @@ -53,13 +46,25 @@ def config_options(self): def configure(self): if self.options.shared: - del self.options.fPIC + try: + del self.options.fPIC + except Exception: + pass if not (self.options.with_app or self.options.with_hpack or self.options.with_asio): - del self.settings.compiler.cppstd - del self.settings.compiler.libcxx + try: + del self.settings.compiler.cppstd + except Exception: + pass + try: + del self.settings.compiler.libcxx + except Exception: + pass if not self.options.with_app: del self.options.with_jemalloc + def layout(self): + cmake_layout(self, src_folder="src") + def requirements(self): if self.options.with_app or self.options.with_asio: self.requires("openssl/1.1.1q") @@ -68,64 +73,62 @@ def requirements(self): self.requires("libev/4.33") self.requires("libevent/2.1.12") self.requires("libxml2/2.9.14") - self.requires("zlib/1.2.12") + self.requires("zlib/1.2.13") if self.options.with_jemalloc: - self.requires("jemalloc/5.2.1") + self.requires("jemalloc/5.3.0") if self.options.with_hpack: self.requires("jansson/2.14") if self.options.with_asio: - self.requires("boost/1.79.0") + self.requires("boost/1.80.0") def validate(self): - if self.options.with_asio and self._is_msvc: + if self.info.options.with_asio and is_msvc(self): raise ConanInvalidConfiguration("Build with asio and MSVC is not supported yet, see upstream bug #589") - if self.settings.compiler == "gcc" and tools.Version(self.settings.compiler.version) < "6": - raise ConanInvalidConfiguration("gcc >= 6.0 required") + if self.info.settings.compiler == "gcc" and Version(self.settings.compiler.version) < "6": + raise ConanInvalidConfiguration(f"{self.ref} requires GCC >= 6.0") def source(self): - tools.get(**self.conan_data["sources"][self.version], - destination=self._source_subfolder, strip_root=True) - - @functools.lru_cache(1) - def _configure_cmake(self): - cmake = CMake(self) - cmake.definitions["ENABLE_SHARED_LIB"] = self.options.shared - cmake.definitions["ENABLE_STATIC_LIB"] = not self.options.shared - cmake.definitions["ENABLE_HPACK_TOOLS"] = self.options.with_hpack - cmake.definitions["ENABLE_APP"] = self.options.with_app - cmake.definitions["ENABLE_EXAMPLES"] = False - cmake.definitions["ENABLE_PYTHON_BINDINGS"] = False - cmake.definitions["ENABLE_FAILMALLOC"] = False + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["ENABLE_SHARED_LIB"] = self.options.shared + tc.variables["ENABLE_STATIC_LIB"] = not self.options.shared + tc.variables["ENABLE_HPACK_TOOLS"] = self.options.with_hpack + tc.variables["ENABLE_APP"] = self.options.with_app + tc.variables["ENABLE_EXAMPLES"] = False + tc.variables["ENABLE_PYTHON_BINDINGS"] = False + tc.variables["ENABLE_FAILMALLOC"] = False # disable unneeded auto-picked dependencies - cmake.definitions["WITH_LIBXML2"] = False - cmake.definitions["WITH_JEMALLOC"] = self.options.get_safe("with_jemalloc", False) - cmake.definitions["WITH_SPDYLAY"] = False - - cmake.definitions["ENABLE_ASIO_LIB"] = self.options.with_asio - - if tools.Version(self.version) >= "1.42.0": + tc.variables["WITH_LIBXML2"] = False + tc.variables["WITH_JEMALLOC"] = self.options.get_safe("with_jemalloc", False) + tc.variables["WITH_SPDYLAY"] = False + tc.variables["ENABLE_ASIO_LIB"] = self.options.with_asio + if Version(self.version) >= "1.42.0": # backward-incompatible change in 1.42.0 - cmake.definitions["STATIC_LIB_SUFFIX"] = "_static" - - if tools.is_apple_os(self.settings.os): + tc.variables["STATIC_LIB_SUFFIX"] = "_static" + if is_apple_os(self): # workaround for: install TARGETS given no BUNDLE DESTINATION for MACOSX_BUNDLE executable - cmake.definitions["CMAKE_MACOSX_BUNDLE"] = False + tc.cache_variables["CMAKE_MACOSX_BUNDLE"] = False + tc.generate() - cmake.configure() - return cmake + tc = CMakeDeps(self) + tc.generate() + tc = PkgConfigDeps(self) + tc.generate() def _patch_sources(self): - for patch in self.conan_data.get("patches", {}).get(self.version, []): - tools.patch(**patch) + apply_conandata_patches(self) if not self.options.shared: # easier to patch here rather than have patch 'nghttp_static_include_directories' for each version - tools.save(os.path.join(self._source_subfolder, "lib", "CMakeLists.txt"), + save(self, os.path.join(self.source_folder, "lib", "CMakeLists.txt"), "target_include_directories(nghttp2_static INTERFACE\n" "${CMAKE_CURRENT_BINARY_DIR}/includes\n" "${CMAKE_CURRENT_SOURCE_DIR}/includes)\n", append=True) target_libnghttp2 = "nghttp2" if self.options.shared else "nghttp2_static" - tools.replace_in_file(os.path.join(self._source_subfolder, "src", "CMakeLists.txt"), + replace_in_file(self, os.path.join(self.source_folder, "src", "CMakeLists.txt"), "\n" "link_libraries(\n" " nghttp2\n", @@ -133,36 +136,37 @@ def _patch_sources(self): "link_libraries(\n" " {} ${{CONAN_LIBS}}\n".format(target_libnghttp2)) if not self.options.shared: - tools.replace_in_file(os.path.join(self._source_subfolder, "src", "CMakeLists.txt"), + replace_in_file(self, os.path.join(self.source_folder, "src", "CMakeLists.txt"), "\n" " add_library(nghttp2_asio SHARED\n", "\n" " add_library(nghttp2_asio\n") - tools.replace_in_file(os.path.join(self._source_subfolder, "src", "CMakeLists.txt"), + replace_in_file(self, os.path.join(self.source_folder, "src", "CMakeLists.txt"), "\n" " target_link_libraries(nghttp2_asio\n" " nghttp2\n", "\n" " target_link_libraries(nghttp2_asio\n" - " {}\n".format(target_libnghttp2)) + f" {target_libnghttp2}\n") def build(self): self._patch_sources() - cmake = self._configure_cmake() + cmake = CMake(self) + cmake.configure() cmake.build() def package(self): - self.copy(pattern="COPYING", dst="licenses", src=self._source_subfolder) - cmake = self._configure_cmake() + copy(self, pattern="COPYING", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder) + cmake = CMake(self) cmake.install() - tools.rmdir(os.path.join(self.package_folder, "share")) - tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) + rmdir(self, os.path.join(self.package_folder, "share")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) def package_info(self): self.cpp_info.components["nghttp2"].set_property("pkg_config_name", "libnghttp2") - suffix = "_static" if tools.Version(self.version) > "1.39.2" and not self.options.shared else "" + suffix = "_static" if Version(self.version) > "1.39.2" and not self.options.shared else "" self.cpp_info.components["nghttp2"].libs = [f"nghttp2{suffix}"] - if self._is_msvc and not self.options.shared: + if is_msvc(self) and not self.options.shared: self.cpp_info.components["nghttp2"].defines.append("NGHTTP2_STATICLIB") if self.options.with_asio: diff --git a/recipes/libnghttp2/all/test_package/CMakeLists.txt b/recipes/libnghttp2/all/test_package/CMakeLists.txt index db17f433a0df2..eb7f9cd8b9769 100644 --- a/recipes/libnghttp2/all/test_package/CMakeLists.txt +++ b/recipes/libnghttp2/all/test_package/CMakeLists.txt @@ -1,11 +1,8 @@ -cmake_minimum_required(VERSION 3.1) -project(test_package) - -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup(TARGETS) +cmake_minimum_required(VERSION 3.8) +project(test_package CXX) find_package(libnghttp2 REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} libnghttp2::libnghttp2) -set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 14) +target_link_libraries(${PROJECT_NAME} PRIVATE libnghttp2::libnghttp2) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_14) diff --git a/recipes/libnghttp2/all/test_package/conanfile.py b/recipes/libnghttp2/all/test_package/conanfile.py index 697dfef261b53..a9fb96656f203 100644 --- a/recipes/libnghttp2/all/test_package/conanfile.py +++ b/recipes/libnghttp2/all/test_package/conanfile.py @@ -1,19 +1,19 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import cmake_layout, CMake import os class TestPackageConan(ConanFile): settings = "os", "arch", "compiler", "build_type" - generators = "cmake", "cmake_find_package_multi" + generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" + test_type = "explicit" - def build_requirements(self): - if self.settings.os == "Macos" and self.settings.arch == "armv8": - # Workaround for CMake bug with error message: - # Attempting to use @rpath without CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG being - # set. This could be because you are using a Mac OS X version less than 10.5 - # or because CMake's platform configuration is corrupt. - # FIXME: Remove once CMake on macOS/M1 CI runners is upgraded. - self.build_requires("cmake/3.22.0") + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -21,6 +21,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/libnghttp2/all/test_v1_package/CMakeLists.txt b/recipes/libnghttp2/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..a7596ce0a8b97 --- /dev/null +++ b/recipes/libnghttp2/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package/ ${CMAKE_CURRENT_BINARY_DIR}/binary_dir/) diff --git a/recipes/libnghttp2/all/test_v1_package/conanfile.py b/recipes/libnghttp2/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/libnghttp2/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/libnghttp2/config.yml b/recipes/libnghttp2/config.yml index 0d99bd0a335ce..a0683e79679b0 100644 --- a/recipes/libnghttp2/config.yml +++ b/recipes/libnghttp2/config.yml @@ -1,4 +1,6 @@ versions: + "1.50.0": + folder: all "1.49.0": folder: all "1.48.0":