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: migrate to Conan v2 #18949

Merged
merged 5 commits into from
Jun 13, 2024
Merged
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
7 changes: 5 additions & 2 deletions recipes/userspace-rcu/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -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"
94 changes: 42 additions & 52 deletions recipes/userspace-rcu/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -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

Check warning on line 6 in recipes/userspace-rcu/all/conanfile.py

View workflow job for this annotation

GitHub Actions / Lint changed conanfile.py (v2 migration)

Unused chdir imported from conan.tools.files
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],
Expand All @@ -31,65 +28,58 @@
"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
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
23 changes: 16 additions & 7 deletions recipes/userspace-rcu/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,31 @@
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)
cmake.configure()
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")
8 changes: 8 additions & 0 deletions recipes/userspace-rcu/all/test_v1_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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/)
23 changes: 23 additions & 0 deletions recipes/userspace-rcu/all/test_v1_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -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)
2 changes: 2 additions & 0 deletions recipes/userspace-rcu/config.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
versions:
"0.14.0":
folder: all
"0.11.4":
folder: all