Skip to content

Commit

Permalink
isa-l: add Windows support
Browse files Browse the repository at this point in the history
  • Loading branch information
valgur committed Aug 3, 2023
1 parent 4b079ac commit 6f1d32c
Showing 1 changed file with 32 additions and 30 deletions.
62 changes: 32 additions & 30 deletions recipes/isa-l/all/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@

from conan import ConanFile
from conan.errors import ConanInvalidConfiguration
from conan.tools.files import chdir, collect_libs, copy, get
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 = "compression"

package_type = "library"
settings = "os", "arch", "compiler", "build_type"
options = {
Expand All @@ -28,6 +28,10 @@ class LibisalConan(ConanFile):
"fPIC": True,
}

def config_options(self):
if self.settings.os == "Windows":
del self.options.fPIC

def configure(self):
self.settings.rm_safe("compiler.libcxx")
self.settings.rm_safe("compiler.cppstd")
Expand All @@ -40,54 +44,52 @@ def layout(self):
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 build_requirements(self):
self.tool_requires("libtool/2.4.7")
self.tool_requires("nasm/2.15.05")
if self.settings.os != "Windows":
self.tool_requires("libtool/2.4.7")

def source(self):
get(self, **self.conan_data["sources"][self.version], strip_root=True)

def generate(self):
tc = AutotoolsToolchain(self)
tc.generate()
if is_msvc(self):
tc = NMakeToolchain(self)
tc.generate()
else:
tc = AutotoolsToolchain(self)
tc.generate()

def build(self):
with chdir(self, self.source_folder):
autotools = Autotools(self)
autotools.autoreconf()
autotools.configure()
autotools.make()
if is_msvc(self):
replace_in_file(self, "Makefile.nmake",
" static" if self.options.shared else " dll", "")
self.run("nmake /f Makefile.nmake")
else:
autotools = Autotools(self)
autotools.configure()
autotools.make()

def package(self):
copy(self, "LICENSE",
src=self.source_folder,
dst=os.path.join(self.package_folder, "licenses"))
dst=os.path.join(self.package_folder, "licenses"),
src=self.source_folder)
copy(self, "*/isa-l.h",
src=self.source_folder,
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)
if self.options.shared:
copy(self, "*.dll",
dst=os.path.join(self.package_folder, "bin"),
src=self.source_folder,
keep_path=False)
copy(self, "*.so*",
dst=os.path.join(self.package_folder, "lib"),
src=self.source_folder,
keep_path=False)
copy(self, "*.dylib",
dst=os.path.join(self.package_folder, "lib"),
src=self.source_folder,
keep_path=False)
else:
copy(self, "*.a",
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)
Expand Down

0 comments on commit 6f1d32c

Please sign in to comment.