From 226c6bc3e2a6396167aefc7999c20d2d09c91489 Mon Sep 17 00:00:00 2001 From: theirix Date: Fri, 15 Jan 2021 23:31:32 +0300 Subject: [PATCH] (#4193) Add libnuma/2.0.14 * Add libnuma * Add patch for gcc 4.x * Fix license for libnuma Co-authored-by: Chris Mc * Copy LGPL license Co-authored-by: Chris Mc * Allow build for FreeBSD Co-authored-by: Chris Mc * 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 Co-authored-by: SpaceIm <30052553+SpaceIm@users.noreply.github.com> --- recipes/libnuma/all/conandata.yml | 8 ++ recipes/libnuma/all/conanfile.py | 80 +++++++++++++++++++ recipes/libnuma/all/patches/symver.patch | 21 +++++ .../libnuma/all/test_package/CMakeLists.txt | 8 ++ recipes/libnuma/all/test_package/conanfile.py | 17 ++++ .../libnuma/all/test_package/test_package.c | 5 ++ recipes/libnuma/config.yml | 3 + 7 files changed, 142 insertions(+) create mode 100644 recipes/libnuma/all/conandata.yml create mode 100644 recipes/libnuma/all/conanfile.py create mode 100644 recipes/libnuma/all/patches/symver.patch create mode 100644 recipes/libnuma/all/test_package/CMakeLists.txt create mode 100644 recipes/libnuma/all/test_package/conanfile.py create mode 100644 recipes/libnuma/all/test_package/test_package.c create mode 100644 recipes/libnuma/config.yml diff --git a/recipes/libnuma/all/conandata.yml b/recipes/libnuma/all/conandata.yml new file mode 100644 index 0000000000000..7c99925f01ad9 --- /dev/null +++ b/recipes/libnuma/all/conandata.yml @@ -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" diff --git a/recipes/libnuma/all/conanfile.py b/recipes/libnuma/all/conanfile.py new file mode 100644 index 0000000000000..3912d21fbcf80 --- /dev/null +++ b/recipes/libnuma/all/conanfile.py @@ -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"] diff --git a/recipes/libnuma/all/patches/symver.patch b/recipes/libnuma/all/patches/symver.patch new file mode 100644 index 0000000000000..cf1fbc1cee1a5 --- /dev/null +++ b/recipes/libnuma/all/patches/symver.patch @@ -0,0 +1,21 @@ +https://github.com/numactl/numactl/pull/95 +From 87cba5ff171744920597f68049664b721f0af112 Mon Sep 17 00:00:00 2001 +From: Scott McMillan +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 diff --git a/recipes/libnuma/all/test_package/CMakeLists.txt b/recipes/libnuma/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..34af13462f44f --- /dev/null +++ b/recipes/libnuma/all/test_package/CMakeLists.txt @@ -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}) diff --git a/recipes/libnuma/all/test_package/conanfile.py b/recipes/libnuma/all/test_package/conanfile.py new file mode 100644 index 0000000000000..1df900244a291 --- /dev/null +++ b/recipes/libnuma/all/test_package/conanfile.py @@ -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) diff --git a/recipes/libnuma/all/test_package/test_package.c b/recipes/libnuma/all/test_package/test_package.c new file mode 100644 index 0000000000000..c6cd17fd4454f --- /dev/null +++ b/recipes/libnuma/all/test_package/test_package.c @@ -0,0 +1,5 @@ +#include + +int main() { + (void)numa_available(); +} diff --git a/recipes/libnuma/config.yml b/recipes/libnuma/config.yml new file mode 100644 index 0000000000000..819ebd6fb8395 --- /dev/null +++ b/recipes/libnuma/config.yml @@ -0,0 +1,3 @@ +versions: + "2.0.14": + folder: all