Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

userspace-rcu: support conan v2 #20811

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions recipes/userspace-rcu/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
sources:
"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"
98 changes: 45 additions & 53 deletions recipes/userspace-rcu/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,28 +1,24 @@
from conan import ConanFile
from conan.errors import ConanInvalidConfiguration
from conan.tools.build import cross_building
from conan.tools.env import Environment, VirtualBuildEnv, VirtualRunEnv
from conan.tools.files import copy, get, rm, rmdir, chdir
from conan.tools.gnu import Autotools, AutotoolsToolchain, AutotoolsDeps, PkgConfigDeps
from conan.tools.layout import basic_layout
from conan.tools.apple import is_apple_os
import os

from conans import ConanFile, AutoToolsBuildEnvironment, tools
from conan.tools.files import get, rmdir
from conans.errors import ConanInvalidConfiguration

required_conan_version = ">=1.47.0"

required_conan_version = ">=1.54.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"

_autotools = None

@property
def _source_subfolder(self):
return "source_subfolder"

url = "https://github.com/conan-io/conan-center-index"
homepage ="https://liburcu.org/"
topics = ("urcu")
package_type = "library"
settings = "os", "compiler", "build_type", "arch"

options = {
"shared": [True, False],
"fPIC": [True, False],
Expand All @@ -31,52 +27,52 @@ def _source_subfolder(self):
"shared": False,
"fPIC": True,
}
build_requires = (
"libtool/2.4.6",
)

generators = "PkgConfigDeps"

def validate(self):
if self.settings.os not in ["Linux", "FreeBSD", "Macos"]:
raise ConanInvalidConfiguration("Building for {} unsupported".format(self.settings.os))

def configure(self):
del self.settings.compiler.libcxx
del self.settings.compiler.cppstd
if self.options.shared:
del self.options.fPIC
self.options.rm_safe("fPIC")
self.settings.rm_safe("compiler.libcxx")
self.settings.rm_safe("compiler.cppstd")

def source(self):
get(self, **self.conan_data["sources"][self.version],
destination=self._source_subfolder, strip_root=True)
def layout(self):
basic_layout(self, src_folder="src")

def validate(self):
if self.settings.os not in ["Linux", "FreeBSD"] and not is_apple_os(self):
raise ConanInvalidConfiguration(f"{self.ref} doesn't support {self.settings.os} building")

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
def build_requirements(self):
self.tool_requires("libtool/2.4.7")

def source(self):
get(self, **self.conan_data["sources"][self.version], strip_root=True)

def generate(self):
env = VirtualBuildEnv(self)
env.generate()
if not cross_building(self):
env = VirtualRunEnv(self)
env.generate(scope="build")
tc = AutotoolsToolchain(self)
tc.generate()
pkgdeps = PkgConfigDeps(self)
pkgdeps.generate()
autodeps = AutotoolsDeps(self)
autodeps.generate()

def build(self):
with tools.chdir(self._source_subfolder):
with chdir(self, self.source_folder):
self.run("./bootstrap")
autotools = self._configure_autotools()
autotools = Autotools(self)
autotools.configure()
autotools.make()

def package(self):
self.copy(pattern="LICENSE*", src=self._source_subfolder, dst="licenses")
autotools = self._configure_autotools()
copy(self, pattern="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", os.path.join(self.package_folder, "lib"))
rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig"))
rmdir(self, os.path.join(self.package_folder, "share"))

Expand All @@ -85,10 +81,6 @@ def package_info(self):
component_name = "urcu{}".format(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":
self.cpp_info.components[component_name].system_libs = ["pthread"]

Expand Down
2 changes: 1 addition & 1 deletion recipes/userspace-rcu/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)

Expand Down
22 changes: 13 additions & 9 deletions recipes/userspace-rcu/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,26 @@
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
def layout(self):
cmake_layout(self)

def requirements(self):
self.requires(self.tested_reference_str)

def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()

def test(self):
if not cross_building(self):
for test in ["", "-mb", "-signal"]:
self.run("test_package{}".format(test), run_environment=True)
if can_run(self):
bin_path = os.path.join(self.cpp.build.bindir, "test_package")
self.run(bin_path, env="conanrun")