Skip to content

Commit

Permalink
(#18955) isa-l: migrate to Conan v2
Browse files Browse the repository at this point in the history
* 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

#18955 (comment)

* isa-l: revert the addition of custom version
  • Loading branch information
valgur authored Dec 5, 2023
1 parent 93f09ea commit af1d897
Show file tree
Hide file tree
Showing 5 changed files with 129 additions and 60 deletions.
121 changes: 78 additions & 43 deletions recipes/isa-l/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,72 +1,107 @@
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],
"fPIC": [True, False],
}
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)
10 changes: 5 additions & 5 deletions recipes/isa-l/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)
27 changes: 15 additions & 12 deletions recipes/isa-l/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,26 @@
#!/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)
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)
if can_run(self):
bin_path = os.path.join(self.cpp.build.bindir, "test_package")
self.run(bin_path, env="conanrun")
8 changes: 8 additions & 0 deletions recipes/isa-l/all/test_v1_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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/)
23 changes: 23 additions & 0 deletions recipes/isa-l/all/test_v1_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit af1d897

Please sign in to comment.