Skip to content

Commit

Permalink
(#4193) Add libnuma/2.0.14
Browse files Browse the repository at this point in the history
* Add libnuma

* Add patch for gcc 4.x

* Fix license for libnuma

Co-authored-by: Chris Mc <prince.chrismc@gmail.com>

* Copy LGPL license

Co-authored-by: Chris Mc <prince.chrismc@gmail.com>

* Allow build for FreeBSD

Co-authored-by: Chris Mc <prince.chrismc@gmail.com>

* libnuma supports only Linux

* Fix check for os

* Calm down KB-H007

* Ensure conan supports validate()

* Calm down KB-H007

* Do not use validate() for excluding OS

* Require lower conan version

Co-authored-by: SpaceIm <30052553+SpaceIm@users.noreply.github.com>

* Drop dead code

Co-authored-by: SpaceIm <30052553+SpaceIm@users.noreply.github.com>

* Update recipes/libnuma/all/conanfile.py

Co-authored-by: SpaceIm <30052553+SpaceIm@users.noreply.github.com>

Co-authored-by: Chris Mc <prince.chrismc@gmail.com>
Co-authored-by: SpaceIm <30052553+SpaceIm@users.noreply.github.com>
  • Loading branch information
3 people authored Jan 15, 2021
1 parent b274ded commit 226c6bc
Show file tree
Hide file tree
Showing 7 changed files with 142 additions and 0 deletions.
8 changes: 8 additions & 0 deletions recipes/libnuma/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
sources:
"2.0.14":
url: "https://github.com/numactl/numactl/releases/download/v2.0.14/numactl-2.0.14.tar.gz"
sha256: "826bd148c1b6231e1284e42a4db510207747484b112aee25ed6b1078756bcff6"
patches:
"2.0.14":
- patch_file: "patches/symver.patch"
base_path: "source_subfolder"
80 changes: 80 additions & 0 deletions recipes/libnuma/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
import os

from conans import ConanFile, AutoToolsBuildEnvironment, tools
from conans.errors import ConanInvalidConfiguration

required_conan_version = ">=1.29.1"

class LibnumaConan(ConanFile):
name = "libnuma"
description = "NUMA support for Linux."
license = "LGPL-2.1-or-later"
topics = ("conan", "numa")
homepage = "https://github.com/numactl/numactl"
url = "https://github.com/conan-io/conan-center-index"
settings = "os", "arch", "compiler", "build_type"
options = {
"shared": [True, False],
"fPIC": [True, False],
}
default_options = {
"shared": False,
"fPIC": True,
}
exports_sources = "patches/**"

_autotools = None

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

def configure(self):
if self.settings.os != "Linux":
raise ConanInvalidConfiguration("{} is only supported on Linux".format(self.name))
del self.settings.compiler.libcxx
del self.settings.compiler.cppstd
if self.options.shared:
del self.options.fPIC

def _patch_sources(self):
for patch in self.conan_data.get("patches",{}).get(self.version, []):
tools.patch(**patch)

def source(self):
tools.get(**self.conan_data["sources"][self.version])
os.rename("numactl-" + self.version, self._source_subfolder)

def _configure_autotools(self):
if self._autotools:
return self._autotools

self._autotools = AutoToolsBuildEnvironment(self)

args = []
if self.options.shared:
args.extend(["--disable-static", "--enable-shared"])
else:
args.extend(["--disable-shared", "--enable-static"])

self._autotools.configure(args=args, configure_dir=self._source_subfolder)
return self._autotools

def build(self):
self._patch_sources()
autotools = self._configure_autotools()
autotools.make()

def package(self):
self.copy("LICENSE.LGPL2.1", dst="licenses", src=self._source_subfolder)
autotools = self._configure_autotools()
autotools.install()
tools.rmdir(os.path.join(self.package_folder, "bin"))
tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig"))
tools.rmdir(os.path.join(self.package_folder, "share"))
tools.remove_files_by_mask(os.path.join(self.package_folder, "lib"), "*.la")

def package_info(self):
self.cpp_info.libs = ["numa"]
self.cpp_info.names["pkg_config"] = "numa"
self.cpp_info.system_libs = ["dl", "pthread"]
21 changes: 21 additions & 0 deletions recipes/libnuma/all/patches/symver.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
https://github.com/numactl/numactl/pull/95
From 87cba5ff171744920597f68049664b721f0af112 Mon Sep 17 00:00:00 2001
From: Scott McMillan <smcmillan@nvidia.com>
Date: Fri, 9 Oct 2020 08:56:52 -0500
Subject: [PATCH] Do not stringify SYMVER symbols

---
util.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/util.h b/util.h
index 99ada33..f2a20ac 100644
--- a/util.h
+++ b/util.h
@@ -22,5 +22,5 @@ extern char *policy_name(int policy);
#if HAVE_ATTRIBUTE_SYMVER
#define SYMVER(a,b) __attribute__ ((symver (b)))
#else
-#define SYMVER(a,b) __asm__ (".symver " #a "," #b);
+#define SYMVER(a,b) __asm__ (".symver " a "," b);
#endif
8 changes: 8 additions & 0 deletions recipes/libnuma/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
cmake_minimum_required(VERSION 3.1)
project(test_package)

include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()

add_executable(${PROJECT_NAME} test_package.c)
target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS})
17 changes: 17 additions & 0 deletions recipes/libnuma/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import os

from conans import ConanFile, CMake, tools

class TestPackageConan(ConanFile):
settings = "os", "compiler", "build_type", "arch"
generators = "cmake", "cmake_find_package"

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

def test(self):
if not tools.cross_building(self.settings):
bin_path = os.path.join("bin", "test_package")
self.run(bin_path, run_environment=True)
5 changes: 5 additions & 0 deletions recipes/libnuma/all/test_package/test_package.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#include <numa.h>

int main() {
(void)numa_available();
}
3 changes: 3 additions & 0 deletions recipes/libnuma/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
versions:
"2.0.14":
folder: all

0 comments on commit 226c6bc

Please sign in to comment.