-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* (#11578) userspace-rcu: Add Userspace RCU recipe. * Remove fPIC option when building Shared Object. * Remove unused compiler flag. * Improve support for GCC < 9 * Limit linkage to required libraries. * Adjust architecture options for Macos * New "model" option * Remove Macos support for now. * Address review comments. * Keep symlinks for shared objects. * Use components instead of option for selecting library. * test_package now consumes only a single component. * Use cpp_info defines attribute instead of cxxflags.
- Loading branch information
Showing
8 changed files
with
936 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
sources: | ||
"0.11.4": | ||
sha256: d995598482221587ff6753d2a8da6ac74ff0fa79fbea29ccee196f295834531d | ||
url: https://github.com/urcu/userspace-rcu/archive/refs/tags/v0.11.4.tar.gz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
import os | ||
|
||
from conans import ConanFile, AutoToolsBuildEnvironment, tools | ||
from conans.errors import ConanInvalidConfiguration | ||
from conan.tools.gnu.pkgconfigdeps.pc_files_creator import get_pc_files_and_content | ||
|
||
required_conan_version = ">=1.33.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" | ||
|
||
settings = "os", "compiler", "build_type", "arch" | ||
|
||
options = { | ||
"shared": [True, False], | ||
"fPIC": [True, False], | ||
} | ||
default_options = { | ||
"shared": False, | ||
"fPIC": True, | ||
} | ||
build_requires = ( | ||
"libtool/2.4.6", | ||
) | ||
|
||
generators = "PkgConfigDeps" | ||
|
||
def validate(self): | ||
if self.settings.os not in ["Linux", "FreeBSD"]: | ||
raise ConanInvalidConfiguration("Only Linux/FreeBSD supported") | ||
|
||
def configure(self): | ||
del self.settings.compiler.libcxx | ||
del self.settings.compiler.cppstd | ||
if self.options.shared: | ||
del self.options.fPIC | ||
|
||
def source(self): | ||
tools.get(**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 | ||
|
||
|
||
def build(self): | ||
with tools.chdir(self._source_subfolder): | ||
self.run("./bootstrap") | ||
autotools = self._configure_autotools() | ||
autotools.make() | ||
|
||
def package(self): | ||
self.copy(pattern="LICENSE*", src=self._source_subfolder, dst="licenses") | ||
autotools = self._configure_autotools() | ||
autotools.install() | ||
|
||
tools.remove_files_by_mask(os.path.join(self.package_folder, "lib"), "*.la") | ||
tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) | ||
tools.rmdir(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) | ||
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"] | ||
|
||
# Some definitions needed for MB and Signal variants | ||
self.cpp_info.components["urcu-mb"].defines = ["RCU_MB"] | ||
self.cpp_info.components["urcu-signal"].defines = ["RCU_SIGNAL"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
cmake_minimum_required(VERSION 3.15) | ||
project(test_package) | ||
|
||
find_package(userspace-rcu COMPONENTS urcu REQUIRED) | ||
|
||
set(TEST_SRC test_urcu_fork.c tap.c) | ||
|
||
add_executable(${PROJECT_NAME} ${TEST_SRC}) | ||
target_link_libraries(${PROJECT_NAME} userspace-rcu::urcu) | ||
|
||
add_executable(${PROJECT_NAME}-mb ${TEST_SRC}) | ||
target_link_libraries(${PROJECT_NAME}-mb userspace-rcu::urcu-mb) | ||
|
||
add_executable(${PROJECT_NAME}-signal ${TEST_SRC}) | ||
target_link_libraries(${PROJECT_NAME}-signal userspace-rcu::urcu-signal) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
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"]: | ||
self.run("test_package{}".format(test), run_environment=True) |
Oops, something went wrong.