From af1d897b1e604879cf3d36437f2eba9537debf46 Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Tue, 5 Dec 2023 22:24:10 +0200 Subject: [PATCH] (#18955) isa-l: migrate to Conan v2 * isa-l: migrate to Conan v2 * isa-l: add Windows support * isa-l: add autoreconf call * isa-l: add new cci.20230818 version for armv8 support * isa-l: armv8 is not supported https://github.com/conan-io/conan-center-index/pull/18955#issuecomment-1790028151 * isa-l: revert the addition of custom version --- recipes/isa-l/all/conanfile.py | 121 +++++++++++------- recipes/isa-l/all/test_package/CMakeLists.txt | 10 +- recipes/isa-l/all/test_package/conanfile.py | 27 ++-- .../isa-l/all/test_v1_package/CMakeLists.txt | 8 ++ .../isa-l/all/test_v1_package/conanfile.py | 23 ++++ 5 files changed, 129 insertions(+), 60 deletions(-) create mode 100644 recipes/isa-l/all/test_v1_package/CMakeLists.txt create mode 100644 recipes/isa-l/all/test_v1_package/conanfile.py diff --git a/recipes/isa-l/all/conanfile.py b/recipes/isa-l/all/conanfile.py index 56f45edf048a4..09af37c4cc900 100644 --- a/recipes/isa-l/all/conanfile.py +++ b/recipes/isa-l/all/conanfile.py @@ -1,17 +1,24 @@ -from conans import ConanFile, AutoToolsBuildEnvironment, tools -from conans.errors import ConanInvalidConfiguration - import os -required_conan_version = ">=1.33.0" +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.env import VirtualBuildEnv +from conan.tools.files import chdir, collect_libs, copy, get, replace_in_file +from conan.tools.gnu import Autotools, AutotoolsToolchain +from conan.tools.layout import basic_layout +from conan.tools.microsoft import is_msvc, NMakeToolchain + +required_conan_version = ">=1.53.0" + class LibisalConan(ConanFile): name = "isa-l" description = "Intel's Intelligent Storage Acceleration Library" - license = "BSD-3" + license = "BSD-3-Clause" url = "https://github.com/conan-io/conan-center-index" homepage = "https://github.com/intel/isa-l" - topics = ("isa-l", "compression") + topics = "compression" + package_type = "library" settings = "os", "arch", "compiler", "build_type" options = { "shared": [True, False], @@ -19,54 +26,82 @@ class LibisalConan(ConanFile): } default_options = { "shared": False, - "fPIC" :True + "fPIC": True, } - build_requires = ( - "libtool/2.4.6", - "nasm/2.15.05", - ) - - @property - def _source_subfolder(self): - return "source_subfolder" - def validate(self): - if self.settings.arch not in [ "x86", "x86_64", "armv8" ]: - raise ConanInvalidConfiguration("CPU Architecture not supported") - if self.settings.os not in ["Linux", "FreeBSD"]: - raise ConanInvalidConfiguration("Only Linux and FreeBSD builds are supported") + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC 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") if self.options.shared: - del self.options.fPIC + self.options.rm_safe("fPIC") + + def layout(self): + basic_layout(self, src_folder="src") + + def validate(self): + if self.settings.arch not in ["x86", "x86_64"]: + raise ConanInvalidConfiguration(f"{self.settings.arch} architecture is not supported") + if self.version == "2.30.0" and self.settings.arch == "armv8": + raise ConanInvalidConfiguration(f"Version {self.version} does not support armv8") + + def build_requirements(self): + self.tool_requires("nasm/2.15.05") + if self.settings.os != "Windows": + self.tool_requires("libtool/2.4.7") def source(self): - tools.get(**self.conan_data["sources"][self.version], destination=self._source_subfolder, strip_root=True) + get(self, **self.conan_data["sources"][self.version], strip_root=True) + + def generate(self): + env = VirtualBuildEnv(self) + env.generate() + if is_msvc(self): + tc = NMakeToolchain(self) + tc.generate() + else: + tc = AutotoolsToolchain(self) + # ./configure bugs out if $AS executable has an absolute path + env = tc.environment() + env.define("AS", "nasm") + tc.generate(env) def build(self): - with tools.chdir(self._source_subfolder): - self.run("./autogen.sh") - env_build = AutoToolsBuildEnvironment(self) - extra_args = list() - if self.options.shared: - extra_args.extend(('--enable-static=no',)) + with chdir(self, self.source_folder): + if is_msvc(self): + replace_in_file(self, "Makefile.nmake", + " static" if self.options.shared else " dll", "") + self.run("nmake /f Makefile.nmake") else: - extra_args.extend(('--enable-shared=no',)) - env_build.configure(".", args=extra_args, build=False, host=False, target=False) - env_build.make() + autotools = Autotools(self) + autotools.autoreconf() + autotools.configure() + autotools.make() def package(self): - self.copy("LICENSE", src=self._source_subfolder, dst="licenses") - self.copy("*/isa-l.h", dst="include/isa-l", keep_path=False) - self.copy("*.h", dst="include/isa-l", src="%s/include" % (self._source_subfolder) , keep_path=False) - if self.options.shared: - self.copy("*.dll", dst="bin", keep_path=False) - self.copy("*.so*", dst="lib", keep_path=False, symlinks=True) - self.copy("*.dylib", dst="lib", keep_path=False) - else: - self.copy("*.a", dst="lib", keep_path=False) + copy(self, "LICENSE", + dst=os.path.join(self.package_folder, "licenses"), + src=self.source_folder) + copy(self, "*/isa-l.h", + dst=os.path.join(self.package_folder, "include/isa-l"), + src=self.source_folder, + keep_path=False) + copy(self, "*.h", + dst=os.path.join(self.package_folder, "include/isa-l"), + src=os.path.join(self.source_folder, "include"), + keep_path=False) + copy(self, "*.dll", + dst=os.path.join(self.package_folder, "bin"), + src=self.source_folder, + keep_path=False) + for pattern in ["*.so*", "*.dylib", "*.lib", "*.a"]: + copy(self, pattern, + dst=os.path.join(self.package_folder, "lib"), + src=self.source_folder, + keep_path=False) def package_info(self): - self.cpp_info.libs = tools.collect_libs(self) + self.cpp_info.libs = collect_libs(self) diff --git a/recipes/isa-l/all/test_package/CMakeLists.txt b/recipes/isa-l/all/test_package/CMakeLists.txt index 196188113685c..9e88b9de0b709 100644 --- a/recipes/isa-l/all/test_package/CMakeLists.txt +++ b/recipes/isa-l/all/test_package/CMakeLists.txt @@ -1,8 +1,8 @@ -cmake_minimum_required(VERSION 3.1) -project(test_package) +cmake_minimum_required(VERSION 3.15) +project(test_package LANGUAGES CXX) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +find_package(isa-l REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) +target_link_libraries(${PROJECT_NAME} PRIVATE isa-l::isa-l) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/isa-l/all/test_package/conanfile.py b/recipes/isa-l/all/test_package/conanfile.py index e1f2192537436..ef5d7042163ec 100644 --- a/recipes/isa-l/all/test_package/conanfile.py +++ b/recipes/isa-l/all/test_package/conanfile.py @@ -1,16 +1,19 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -from conans import ConanFile, CMake, tools, RunEnvironment -from conan.tools.build import cross_building +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import cmake_layout, CMake import os -import subprocess -import re class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + 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) @@ -18,6 +21,6 @@ def build(self): cmake.build() def test(self): - if not cross_building(self): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindir, "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/isa-l/all/test_v1_package/CMakeLists.txt b/recipes/isa-l/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..91630d79f4abb --- /dev/null +++ b/recipes/isa-l/all/test_v1_package/CMakeLists.txt @@ -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/) diff --git a/recipes/isa-l/all/test_v1_package/conanfile.py b/recipes/isa-l/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..9d2678d8486a0 --- /dev/null +++ b/recipes/isa-l/all/test_v1_package/conanfile.py @@ -0,0 +1,23 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +from conans import ConanFile, CMake, tools, RunEnvironment +from conan.tools.build import cross_building +import os +import subprocess +import re + + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True)