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 7f8c307
Showing 1 changed file with 30 additions and 29 deletions.
59 changes: 30 additions & 29 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,8 +44,6 @@ 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")
Expand All @@ -51,43 +53,42 @@ 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 7f8c307

Please sign in to comment.