-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* rdma-core: new recipe * rdma-core: add libnl dependency * rdma-core: fix libnl dependency * rdma-core: bump version to v48.0 * rdma-core: make some libraries optional * rdma-core: fix license copying * rdma-core: tidy package_info() * rdma-core: ignore driver errors in test_package.cpp * rdma-core: limit to Linux only * rdma-core: bump to 49.0
- Loading branch information
Showing
6 changed files
with
235 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: | ||
"49.0": | ||
url: "https://github.com/linux-rdma/rdma-core/releases/download/v49.0/rdma-core-49.0.tar.gz" | ||
sha256: "953546ad2b179f9ce68dc21eb1eb26003098ea1bf0f87a4baed45bcea134b2b4" |
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,133 @@ | ||
import os | ||
import re | ||
|
||
from conan import ConanFile | ||
from conan.errors import ConanInvalidConfiguration | ||
from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout, CMakeDeps | ||
from conan.tools.env import VirtualBuildEnv | ||
from conan.tools.files import get, copy, rmdir, load, save, replace_in_file | ||
from conan.tools.gnu import PkgConfigDeps | ||
|
||
required_conan_version = ">=1.53.0" | ||
|
||
class PackageConan(ConanFile): | ||
name = "rdma-core" | ||
description = ("RDMA core userspace libraries and daemons. " | ||
"Provides userspace components for the Linux Kernel's drivers/infiniband subsystem.") | ||
license = ("GPL-2.0", "Linux-OpenIB", "BSD-2-Clause") | ||
url = "https://github.com/conan-io/conan-center-index" | ||
homepage = "https://github.com/linux-rdma/rdma-core" | ||
topics = ("linux-kernel", "rdma", "infiniband", "iwarp", "roce", "kernel-rdma-drivers", | ||
"libefa", "libibmad", "libibnetdisc", "libibumad", "libibverbs", "libmana", | ||
"libmlx4", "libmlx5", "librdmacm") | ||
|
||
package_type = "shared-library" | ||
settings = "os", "arch", "compiler", "build_type" | ||
options = { | ||
"build_libefa": [True, False], | ||
"build_libibnetdisc": [True, False], | ||
"build_libmana": [True, False], | ||
"build_libmlx4": [True, False], | ||
"build_libmlx5": [True, False], | ||
"build_librdmacm": [True, False], | ||
} | ||
default_options = { | ||
"build_libefa": True, | ||
"build_libibnetdisc": True, | ||
"build_libmana": True, | ||
"build_libmlx4": True, | ||
"build_libmlx5": False, | ||
"build_librdmacm": False, | ||
} | ||
|
||
def configure(self): | ||
self.settings.rm_safe("compiler.libcxx") | ||
self.settings.rm_safe("compiler.cppstd") | ||
|
||
def layout(self): | ||
cmake_layout(self, src_folder="src") | ||
|
||
def requirements(self): | ||
self.requires("libnl/3.8.0") | ||
if self.settings.os in ["Linux", "FreeBSD"]: | ||
self.requires("libudev/system") | ||
|
||
def validate(self): | ||
if self.settings.os not in ["Linux", "FreeBSD"]: | ||
# libnl is only available on Linux | ||
raise ConanInvalidConfiguration("rdma-core is only supported on Linux") | ||
|
||
def build_requirements(self): | ||
if not self.conf.get("tools.gnu:pkg_config", default=False, check_type=str): | ||
self.tool_requires("pkgconf/2.1.0") | ||
|
||
def source(self): | ||
get(self, **self.conan_data["sources"][self.version], strip_root=True) | ||
|
||
def generate(self): | ||
tc = VirtualBuildEnv(self) | ||
tc.generate() | ||
tc = CMakeToolchain(self) | ||
# Shared libraries are built by default and even if ENABLE_STATIC is turned on, | ||
# the static libraries still have dependencies on the shared libraries. | ||
# tc.variables["ENABLE_STATIC"] = not self.options.shared | ||
tc.variables["NO_PYVERBS"] = True | ||
tc.variables["NO_MAN_PAGES"] = True | ||
tc.generate() | ||
deps = CMakeDeps(self) | ||
deps.generate() | ||
deps = PkgConfigDeps(self) | ||
deps.generate() | ||
|
||
def _patch_sources(self): | ||
# Build only the libraries and disable everything else | ||
allowed_subdirs = ["ccan", "kernel-boot", "kernel-headers", "libibmad", "libibnetdisc", "libibumad", "libibverbs", | ||
"librdmacm", "providers/efa", "providers/mana", "providers/mlx4", "providers/mlx5", "util"] | ||
allowed_subdirs = [ | ||
subdir for subdir in allowed_subdirs | ||
if self.options.get_safe(f"build_{subdir.replace('providers/', 'lib')}", True) | ||
] | ||
cmakelists_path = os.path.join(self.source_folder, "CMakeLists.txt") | ||
cmakelists_content = load(self, cmakelists_path) | ||
patched_content = re.sub(r"add_subdirectory\((?!({})\)).+\)".format("|".join(allowed_subdirs)), r"", cmakelists_content) | ||
save(self, cmakelists_path, patched_content) | ||
# Adjust the pkg-config target for libnl | ||
replace_in_file(self, cmakelists_path, "libnl-3.0 libnl-route-3.0", "libnl") | ||
|
||
def build(self): | ||
self._patch_sources() | ||
cmake = CMake(self) | ||
cmake.configure() | ||
cmake.build() | ||
|
||
def package(self): | ||
copy(self, "COPYING.*", | ||
dst=os.path.join(self.package_folder, "licenses"), | ||
src=self.source_folder) | ||
cmake = CMake(self) | ||
cmake.install() | ||
rmdir(self, 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, "etc")) | ||
|
||
def package_info(self): | ||
def _add_component(name, requires, pthread=False): | ||
if not self.options.get_safe(f"build_{name}", True): | ||
return | ||
component = self.cpp_info.components[name] | ||
component.set_property("pkg_config_name", name) | ||
component.libs = [name.replace("lib", "")] | ||
component.requires = requires + ["libudev::libudev"] | ||
if pthread and self.settings.os in ["Linux", "FreeBSD"]: | ||
component.system_libs = ["pthread"] | ||
|
||
_add_component("libefa", ["libibverbs"], pthread=True) | ||
_add_component("libibmad", ["libibumad"]) | ||
_add_component("libibnetdisc", ["libibmad", "libibumad"]) | ||
_add_component("libibumad", []) | ||
_add_component("libibverbs", ["libnl::nl", "libnl::nl-route"], pthread=True) | ||
_add_component("libmana", ["libibverbs"], pthread=True) | ||
_add_component("libmlx4", ["libibverbs"], pthread=True) | ||
_add_component("libmlx5", ["libibverbs"], pthread=True) | ||
_add_component("librdmacm", ["libibverbs", "libnl::nl", "libnl::nl-route"], pthread=True) | ||
|
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,7 @@ | ||
cmake_minimum_required(VERSION 3.15) | ||
project(test_package) | ||
|
||
find_package(rdma-core REQUIRED CONFIG) | ||
|
||
add_executable(${PROJECT_NAME} test_package.cpp) | ||
target_link_libraries(${PROJECT_NAME} PRIVATE rdma-core::libibverbs) |
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,26 @@ | ||
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 = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" | ||
test_type = "explicit" | ||
|
||
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 can_run(self): | ||
bin_path = os.path.join(self.cpp.build.bindir, "test_package") | ||
self.run(bin_path, env="conanrun") |
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,62 @@ | ||
/* | ||
* Copyright (c) 2004 Topspin Communications. All rights reserved. | ||
* | ||
* This software is available to you under a choice of one of two | ||
* licenses. You may choose to be licensed under the terms of the GNU | ||
* General Public License (GPL) Version 2, available from the file | ||
* COPYING in the main directory of this source tree, or the | ||
* OpenIB.org BSD license below: | ||
* | ||
* Redistribution and use in source and binary forms, with or | ||
* without modification, are permitted provided that the following | ||
* conditions are met: | ||
* | ||
* - Redistributions of source code must retain the above | ||
* copyright notice, this list of conditions and the following | ||
* disclaimer. | ||
* | ||
* - Redistributions in binary form must reproduce the above | ||
* copyright notice, this list of conditions and the following | ||
* disclaimer in the documentation and/or other materials | ||
* provided with the distribution. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS | ||
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN | ||
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
* SOFTWARE. | ||
*/ | ||
|
||
#include <stdio.h> | ||
|
||
#include <endian.h> | ||
|
||
#include <infiniband/verbs.h> | ||
|
||
int main(int argc, char *argv[]) | ||
{ | ||
struct ibv_device **dev_list; | ||
int num_devices, i; | ||
|
||
dev_list = ibv_get_device_list(&num_devices); | ||
if (!dev_list) { | ||
perror("Failed to get IB devices list"); | ||
return 0; | ||
} | ||
|
||
printf(" %-16s\t node GUID\n", "device"); | ||
printf(" %-16s\t----------------\n", "------"); | ||
|
||
for (i = 0; i < num_devices; ++i) { | ||
printf(" %-16s\t%016llx\n", | ||
ibv_get_device_name(dev_list[i]), | ||
(unsigned long long) be64toh(ibv_get_device_guid(dev_list[i]))); | ||
} | ||
|
||
ibv_free_device_list(dev_list); | ||
|
||
return 0; | ||
} |
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,3 @@ | ||
versions: | ||
"49.0": | ||
folder: all |