diff --git a/recipes/userspace-rcu/all/conandata.yml b/recipes/userspace-rcu/all/conandata.yml index 570705edb2dd6..63079c64c1840 100644 --- a/recipes/userspace-rcu/all/conandata.yml +++ b/recipes/userspace-rcu/all/conandata.yml @@ -1,4 +1,7 @@ sources: + "0.14.0": + url: "https://github.com/urcu/userspace-rcu/archive/refs/tags/v0.14.0.tar.gz" + sha256: "42fb5129a3fffe5a4b790dfe1ea3a734c69ee095fefbf649326269bba94c262d" "0.11.4": - sha256: d995598482221587ff6753d2a8da6ac74ff0fa79fbea29ccee196f295834531d - url: https://github.com/urcu/userspace-rcu/archive/refs/tags/v0.11.4.tar.gz + url: "https://github.com/urcu/userspace-rcu/archive/refs/tags/v0.11.4.tar.gz" + sha256: "d995598482221587ff6753d2a8da6ac74ff0fa79fbea29ccee196f295834531d" diff --git a/recipes/userspace-rcu/all/conanfile.py b/recipes/userspace-rcu/all/conanfile.py index ad697812f9c26..bc82bbc3b711b 100644 --- a/recipes/userspace-rcu/all/conanfile.py +++ b/recipes/userspace-rcu/all/conanfile.py @@ -1,28 +1,25 @@ import os -from conans import ConanFile, AutoToolsBuildEnvironment, tools -from conan.tools.files import get, rmdir -from conans.errors import ConanInvalidConfiguration +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.env import VirtualBuildEnv +from conan.tools.files import chdir, copy, get, rm, rmdir +from conan.tools.gnu import Autotools, AutotoolsToolchain +from conan.tools.layout import basic_layout -required_conan_version = ">=1.47.0" +required_conan_version = ">=1.53.0" class UserspaceRCUConan(ConanFile): name = "userspace-rcu" - homepage ="https://liburcu.org/" description = "Userspace RCU (read-copy-update) library" - topics = ("urcu") - url = "https://github.com/conan-io/conan-center-index" license = "LGPL-2.1" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://liburcu.org/" + topics = "urcu" - _autotools = None - - @property - def _source_subfolder(self): - return "source_subfolder" - - settings = "os", "compiler", "build_type", "arch" - + package_type = "library" + settings = "os", "arch", "compiler", "build_type" options = { "shared": [True, False], "fPIC": [True, False], @@ -31,65 +28,58 @@ def _source_subfolder(self): "shared": False, "fPIC": True, } - build_requires = ( - "libtool/2.4.6", - ) - generators = "PkgConfigDeps" + def configure(self): + self.settings.rm_safe("compiler.libcxx") + self.settings.rm_safe("compiler.cppstd") + if self.options.shared: + self.options.rm_safe("fPIC") + + def layout(self): + basic_layout(self, src_folder="src") def validate(self): if self.settings.os not in ["Linux", "FreeBSD", "Macos"]: - raise ConanInvalidConfiguration("Building for {} unsupported".format(self.settings.os)) + raise ConanInvalidConfiguration(f"Building for {self.settings.os} unsupported") + if self.version == "0.11.4" and self.settings.compiler == "apple-clang": + # Fails with "cds_hlist_add_head_rcu.c:19:10: fatal error: 'urcu/urcu-memb.h' file not found" + raise ConanInvalidConfiguration(f"{self.ref} is not compatible with apple-clang") - def configure(self): - del self.settings.compiler.libcxx - del self.settings.compiler.cppstd - if self.options.shared: - del self.options.fPIC + def build_requirements(self): + self.tool_requires("libtool/2.4.7") def source(self): - get(self, **self.conan_data["sources"][self.version], - destination=self._source_subfolder, strip_root=True) - - def _configure_autotools(self): - if self._autotools: - return self._autotools - self._autotools = AutoToolsBuildEnvironment(self) - self._autotools.libs = [] - yes_no = lambda v: "yes" if v else "no" - conf_args = [ - "--enable-shared={}".format(yes_no(self.options.shared)), - "--enable-static={}".format(yes_no(not self.options.shared)), - ] - self._autotools.configure(args=conf_args, configure_dir=self._source_subfolder) - return self._autotools + get(self, **self.conan_data["sources"][self.version], strip_root=True) + def generate(self): + env = VirtualBuildEnv(self) + env.generate() + tc = AutotoolsToolchain(self) + tc.generate() def build(self): - with tools.chdir(self._source_subfolder): - self.run("./bootstrap") - autotools = self._configure_autotools() + autotools = Autotools(self) + autotools.autoreconf() + autotools.configure() autotools.make() def package(self): - self.copy(pattern="LICENSE*", src=self._source_subfolder, dst="licenses") - autotools = self._configure_autotools() + copy(self, "LICENSE*", + src=self.source_folder, + dst=os.path.join(self.package_folder, "licenses")) + autotools = Autotools(self) autotools.install() - tools.remove_files_by_mask(os.path.join(self.package_folder, "lib"), "*.la") + rm(self, "*.la", self.package_folder, recursive=True) rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) rmdir(self, os.path.join(self.package_folder, "share")) def package_info(self): for lib_type in ["", "-bp", "-cds", "-mb", "-memb", "-qsbr", "-signal"]: - component_name = "urcu{}".format(lib_type) + component_name = f"urcu{lib_type}" self.cpp_info.components[component_name].libs = ["urcu-common", component_name] self.cpp_info.components[component_name].set_property("pkg_config_name", component_name) - self.cpp_info.components[component_name].names["pkg_config"] = component_name - # todo Remove in Conan version 1.50.0 where these are set by default for the PkgConfigDeps generator. - self.cpp_info.components[component_name].includedirs = ["include"] - self.cpp_info.components[component_name].libdirs = ["lib"] - if self.settings.os == "Linux": + if self.settings.os in ["Linux", "FreeBSD"]: self.cpp_info.components[component_name].system_libs = ["pthread"] # Some definitions needed for MB and Signal variants diff --git a/recipes/userspace-rcu/all/test_package/CMakeLists.txt b/recipes/userspace-rcu/all/test_package/CMakeLists.txt index 2afe258693778..3dbdbb9223703 100644 --- a/recipes/userspace-rcu/all/test_package/CMakeLists.txt +++ b/recipes/userspace-rcu/all/test_package/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.15) -project(test_package) +project(test_package LANGUAGES C) find_package(userspace-rcu COMPONENTS urcu REQUIRED) diff --git a/recipes/userspace-rcu/all/test_package/conanfile.py b/recipes/userspace-rcu/all/test_package/conanfile.py index 78d6ce7aad715..28dc52eddfee5 100644 --- a/recipes/userspace-rcu/all/test_package/conanfile.py +++ b/recipes/userspace-rcu/all/test_package/conanfile.py @@ -1,15 +1,23 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import cmake_layout, CMake import os -from conans import ConanFile, CMake -from conan.tools.build import cross_building class TestPackageConan(ConanFile): settings = "os", "arch", "compiler", "build_type" - generators = "cmake", "cmake_find_package_multi" + generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" + test_type = "explicit" def configure(self): - del self.settings.compiler.libcxx - del self.settings.compiler.cppstd + self.settings.rm_safe("compiler.libcxx") + self.settings.rm_safe("compiler.cppstd") + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -17,6 +25,7 @@ def build(self): cmake.build() def test(self): - if not cross_building(self): + if can_run(self): for test in ["", "-mb", "-signal"]: - self.run("test_package{}".format(test), run_environment=True) + bin_path = os.path.join(self.cpp.build.bindir, f"test_package{test}") + self.run(bin_path, env="conanrun") diff --git a/recipes/userspace-rcu/all/test_v1_package/CMakeLists.txt b/recipes/userspace-rcu/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..91630d79f4abb --- /dev/null +++ b/recipes/userspace-rcu/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.15) +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}/test_package/) diff --git a/recipes/userspace-rcu/all/test_v1_package/conanfile.py b/recipes/userspace-rcu/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..a8ac0984771ba --- /dev/null +++ b/recipes/userspace-rcu/all/test_v1_package/conanfile.py @@ -0,0 +1,23 @@ +import os + +from conans import ConanFile, CMake +from conan.tools.build import cross_building + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def configure(self): + del self.settings.compiler.libcxx + del self.settings.compiler.cppstd + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not cross_building(self): + for test in ["", "-mb", "-signal"]: + bin_path = os.path.join("bin", f"test_package{test}") + self.run(bin_path, run_environment=True) diff --git a/recipes/userspace-rcu/config.yml b/recipes/userspace-rcu/config.yml index 813707cc5417d..8246204055b2f 100644 --- a/recipes/userspace-rcu/config.yml +++ b/recipes/userspace-rcu/config.yml @@ -1,3 +1,5 @@ versions: + "0.14.0": + folder: all "0.11.4": folder: all