[DO-983][DO-985] add tiff and zstd packages (!14)

Co-authored-by: aleksandr.vodyanov <aleksandr.vodyanov@avroid.tech>
Reviewed-on: https://git.avroid.tech/Conan/conan_build/pulls/14
This commit is contained in:
Aleksandr Vodyanov
2024-12-26 16:03:17 +03:00
parent 70e3dea3f3
commit 60445ac09e
55 changed files with 1662 additions and 86 deletions

View File

@@ -0,0 +1,44 @@
sources:
"1.14":
url: "https://github.com/ebiggers/libdeflate/archive/refs/tags/v1.14.tar.gz"
sha256: "89e7df898c37c3427b0f39aadcf733731321a278771d20fc553f92da8d4808ac"
"1.12":
url: "https://github.com/ebiggers/libdeflate/archive/refs/tags/v1.12.tar.gz"
sha256: "ba89fb167a5ab6bbdfa6ee3b1a71636e8140fa8471cce8a311697584948e4d06"
"1.10":
url: "https://github.com/ebiggers/libdeflate/archive/refs/tags/v1.10.tar.gz"
sha256: "5c1f75c285cd87202226f4de49985dcb75732f527eefba2b3ddd70a8865f2533"
"1.9":
url: "https://github.com/ebiggers/libdeflate/archive/refs/tags/v1.9.tar.gz"
sha256: "a537ab6125c226b874c02b166488b326aece954930260dbf682d88fc339137e3"
"1.8":
url: "https://github.com/ebiggers/libdeflate/archive/refs/tags/v1.8.tar.gz"
sha256: "50711ad4e9d3862f8dfb11b97eb53631a86ee3ce49c0e68ec2b6d059a9662f61"
"1.7":
url: "https://github.com/ebiggers/libdeflate/archive/refs/tags/v1.7.tar.gz"
sha256: "a5e6a0a9ab69f40f0f59332106532ca76918977a974e7004977a9498e3f11350"
patches:
"1.14":
- patch_file: "patches/1.14-0001-fix-makefiles.patch"
patch_description: "disable optimization and apply compiler settings on conan recipe"
patch_type: "conan"
"1.12":
- patch_file: "patches/1.12-0001-fix-makefiles.patch"
patch_description: "disable optimization and apply compiler settings on conan recipe"
patch_type: "conan"
"1.10":
- patch_file: "patches/1.9-0001-fix-makefiles.patch"
patch_description: "disable optimization and apply compiler settings on conan recipe"
patch_type: "conan"
"1.9":
- patch_file: "patches/1.9-0001-fix-makefiles.patch"
patch_description: "disable optimization and apply compiler settings on conan recipe"
patch_type: "conan"
"1.8":
- patch_file: "patches/1.7-0001-fix-makefiles.patch"
patch_description: "disable optimization and apply compiler settings on conan recipe"
patch_type: "conan"
"1.7":
- patch_file: "patches/1.7-0001-fix-makefiles.patch"
patch_description: "disable optimization and apply compiler settings on conan recipe"
patch_type: "conan"

View File

@@ -0,0 +1,120 @@
from conan import ConanFile
from conan.tools.env import VirtualBuildEnv
from conan.tools.files import apply_conandata_patches, chdir, copy, export_conandata_patches, get, rm, rmdir
from conan.tools.gnu import Autotools, AutotoolsToolchain
from conan.tools.layout import basic_layout
from conan.tools.microsoft import is_msvc, unix_path, NMakeToolchain
import os
required_conan_version = ">=1.55.0"
class LibdeflateConan(ConanFile):
name = "libdeflate"
description = "Heavily optimized library for DEFLATE/zlib/gzip compression and decompression."
license = "MIT"
url = "https://github.com/conan-io/conan-center-index"
homepage = "https://github.com/ebiggers/libdeflate"
topics = ("compression", "decompression", "deflate", "zlib", "gzip")
package_type = "library"
settings = "os", "arch", "compiler", "build_type"
options = {
"shared": [True, False],
"fPIC": [True, False],
}
default_options = {
"shared": False,
"fPIC": True,
}
@property
def _is_clangcl(self):
return self.settings.compiler == "clang" and self.settings.os == "Windows"
@property
def _settings_build(self):
return getattr(self, "settings_build", self.settings)
def export_sources(self):
export_conandata_patches(self)
def config_options(self):
if self.settings.os == "Windows":
del self.options.fPIC
def configure(self):
if self.options.shared:
self.options.rm_safe("fPIC")
self.settings.rm_safe("compiler.cppstd")
self.settings.rm_safe("compiler.libcxx")
def layout(self):
basic_layout(self, src_folder="src")
def build_requirements(self):
if self._settings_build.os == "Windows" and not (is_msvc(self) or self._is_clangcl):
self.win_bash = True
if not self.conf.get("tools.microsoft.bash:path", check_type=str):
self.tool_requires("msys2/cci.latest")
def source(self):
get(self, **self.conan_data["sources"][self.version], strip_root=True)
def generate(self):
if is_msvc(self) or self._is_clangcl:
tc = NMakeToolchain(self)
tc.generate()
else:
env = VirtualBuildEnv(self)
env.generate()
tc = AutotoolsToolchain(self)
tc.generate()
def _build_nmake(self):
with chdir(self, self.source_folder):
target = "libdeflate.dll" if self.options.shared else "libdeflatestatic.lib"
self.run(f"nmake /f Makefile.msc {target}")
def _build_make(self):
autotools = Autotools(self)
with chdir(self, self.source_folder):
autotools.make()
def build(self):
apply_conandata_patches(self)
if is_msvc(self) or self._is_clangcl:
self._build_nmake()
else:
self._build_make()
def _package_windows(self):
copy(self, "libdeflate.h", dst=os.path.join(self.package_folder, "include"), src=self.source_folder)
if self.options.shared:
copy(self, "*deflate.lib", dst=os.path.join(self.package_folder, "lib"), src=self.source_folder)
copy(self, "*deflate.dll", dst=os.path.join(self.package_folder, "bin"), src=self.source_folder)
else:
copy(self, "*deflatestatic.lib", dst=os.path.join(self.package_folder, "lib"), src=self.source_folder)
def _package_make(self):
autotools = Autotools(self)
with chdir(self, self.source_folder):
# Note: not actually an autotools project, is a Makefile project.
autotools.install(args=[f"DESTDIR={unix_path(self, self.package_folder)}", "PREFIX=/"])
rmdir(self, os.path.join(self.package_folder, "bin"))
rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig"))
rm(self, "*.a" if self.options.shared else "*.[so|dylib]*", os.path.join(self.package_folder, "lib") )
def package(self):
copy(self, "COPYING", self.source_folder, dst=os.path.join(self.package_folder, "licenses"))
if self.settings.os == "Windows":
self._package_windows()
else:
self._package_make()
def package_info(self):
self.cpp_info.set_property("pkg_config_name", "libdeflate")
prefix = "lib" if self.settings.os == "Windows" else ""
suffix = "static" if self.settings.os == "Windows" and not self.options.shared else ""
self.cpp_info.libs = [f"{prefix}deflate{suffix}"]
if self.settings.os == "Windows" and self.options.shared:
self.cpp_info.defines = ["LIBDEFLATE_DLL"]

View File

@@ -0,0 +1,40 @@
diff --git a/Makefile b/Makefile
index 9e55d0c..917b6db 100644
--- a/Makefile
+++ b/Makefile
@@ -54,7 +54,7 @@ cc-option = $(shell if $(CC) $(1) -c -x c /dev/null -o /dev/null \
1>&2 2>/dev/null; then echo $(1); fi)
override CFLAGS := \
- -O2 -fomit-frame-pointer -std=c99 -I. -Wall -Wundef \
+ -fomit-frame-pointer -std=c99 -I. -Wall -Wundef \
$(call cc-option,-Wpedantic) \
$(call cc-option,-Wdeclaration-after-statement) \
$(call cc-option,-Wmissing-prototypes) \
@@ -124,7 +124,7 @@ else ifneq ($(findstring -darwin,$(TARGET_MACHINE)),)
SHARED_LIB := libdeflate.$(SOVERSION).dylib
SHARED_LIB_SYMLINK := libdeflate.dylib
SHARED_LIB_CFLAGS := -fPIC
- SHARED_LIB_LDFLAGS := -install_name $(LIBDIR)/$(SHARED_LIB)
+ SHARED_LIB_LDFLAGS := -install_name @rpath/$(SHARED_LIB)
# Compiling for Android?
else ifneq ($(findstring -android,$(TARGET_MACHINE)),)
diff --git a/Makefile.msc b/Makefile.msc
index 1449618..a61c034 100644
--- a/Makefile.msc
+++ b/Makefile.msc
@@ -7,11 +7,10 @@
.SUFFIXES: .c .obj .dllobj
-CC = cl
+CC = $(CC)
LD = link
AR = lib
-CFLAGS = /MD /O2 -I.
-LDFLAGS =
+CFLAGS = /nologo $(CFLAGS) -I.
STATIC_LIB = libdeflatestatic.lib
SHARED_LIB = libdeflate.dll

View File

@@ -0,0 +1,40 @@
diff --git a/Makefile b/Makefile
index a08c945..36876b5 100644
--- a/Makefile
+++ b/Makefile
@@ -54,7 +54,7 @@ cc-option = $(shell if $(CC) $(1) -c -x c /dev/null -o /dev/null \
1>&2 2>/dev/null; then echo $(1); fi)
override CFLAGS := \
- -O2 -fomit-frame-pointer -std=c99 -I. -Wall -Wundef \
+ -fomit-frame-pointer -std=c99 -I. -Wall -Wundef \
$(call cc-option,-Wdeclaration-after-statement) \
$(call cc-option,-Wimplicit-fallthrough) \
$(call cc-option,-Wmissing-prototypes) \
@@ -120,7 +120,7 @@ else ifneq ($(findstring -darwin,$(TARGET_MACHINE)),)
SHARED_LIB := libdeflate.$(SOVERSION).dylib
SHARED_LIB_SYMLINK := libdeflate.dylib
SHARED_LIB_CFLAGS := -fPIC
- SHARED_LIB_LDFLAGS := -install_name $(LIBDIR)/$(SHARED_LIB)
+ SHARED_LIB_LDFLAGS := -install_name @rpath/$(SHARED_LIB)
# Compiling for Android?
else ifneq ($(findstring -android,$(TARGET_MACHINE)),)
diff --git a/Makefile.msc b/Makefile.msc
index 1449618..a61c034 100644
--- a/Makefile.msc
+++ b/Makefile.msc
@@ -7,11 +7,10 @@
.SUFFIXES: .c .obj .dllobj
-CC = cl
+CC = $(CC)
LD = link
AR = lib
-CFLAGS = /MD /O2 -I.
-LDFLAGS =
+CFLAGS = /nologo $(CFLAGS) -I.
STATIC_LIB = libdeflatestatic.lib
SHARED_LIB = libdeflate.dll

View File

@@ -0,0 +1,40 @@
diff --git a/Makefile b/Makefile
index 276d75d..641e726 100644
--- a/Makefile
+++ b/Makefile
@@ -48,7 +48,7 @@ cc-option = $(shell if $(CC) $(1) -c -x c /dev/null -o /dev/null \
1>&2 2>/dev/null; then echo $(1); fi)
override CFLAGS := \
- -O2 -fomit-frame-pointer -std=c99 -I. -Wall -Wundef \
+ -fomit-frame-pointer -std=c99 -I. -Wall -Wundef \
$(call cc-option,-Wpedantic) \
$(call cc-option,-Wdeclaration-after-statement) \
$(call cc-option,-Wmissing-prototypes) \
@@ -111,7 +111,7 @@ else ifeq ($(shell uname),Darwin)
SHARED_LIB := libdeflate.$(SOVERSION).dylib
SHARED_LIB_SYMLINK := libdeflate.dylib
SHARED_LIB_CFLAGS := -fPIC
- SHARED_LIB_LDFLAGS := -install_name $(SHARED_LIB)
+ SHARED_LIB_LDFLAGS := -install_name @rpath/$(SHARED_LIB)
# Linux, FreeBSD, etc.
else
diff --git a/Makefile.msc b/Makefile.msc
index 1449618..a61c034 100644
--- a/Makefile.msc
+++ b/Makefile.msc
@@ -7,11 +7,10 @@
.SUFFIXES: .c .obj .dllobj
-CC = cl
+CC = $(CC)
LD = link
AR = lib
-CFLAGS = /MD /O2 -I.
-LDFLAGS =
+CFLAGS = /nologo $(CFLAGS) -I.
STATIC_LIB = libdeflatestatic.lib
SHARED_LIB = libdeflate.dll

View File

@@ -0,0 +1,40 @@
diff --git a/Makefile b/Makefile
index 0e8b008..d184a4a 100644
--- a/Makefile
+++ b/Makefile
@@ -54,7 +54,7 @@ cc-option = $(shell if $(CC) $(1) -c -x c /dev/null -o /dev/null \
1>&2 2>/dev/null; then echo $(1); fi)
override CFLAGS := \
- -O2 -fomit-frame-pointer -std=c99 -I. -Wall -Wundef \
+ -fomit-frame-pointer -std=c99 -I. -Wall -Wundef \
$(call cc-option,-Wpedantic) \
$(call cc-option,-Wdeclaration-after-statement) \
$(call cc-option,-Wmissing-prototypes) \
@@ -119,7 +119,7 @@ else ifneq ($(findstring -darwin,$(TARGET_MACHINE)),)
SHARED_LIB := libdeflate.$(SOVERSION).dylib
SHARED_LIB_SYMLINK := libdeflate.dylib
SHARED_LIB_CFLAGS := -fPIC
- SHARED_LIB_LDFLAGS := -install_name $(SHARED_LIB)
+ SHARED_LIB_LDFLAGS := -install_name @rpath/$(SHARED_LIB)
# Compiling for Android?
else ifneq ($(findstring -android,$(TARGET_MACHINE)),)
diff --git a/Makefile.msc b/Makefile.msc
index 1449618..a61c034 100644
--- a/Makefile.msc
+++ b/Makefile.msc
@@ -7,11 +7,10 @@
.SUFFIXES: .c .obj .dllobj
-CC = cl
+CC = $(CC)
LD = link
AR = lib
-CFLAGS = /MD /O2 -I.
-LDFLAGS =
+CFLAGS = /nologo $(CFLAGS) -I.
STATIC_LIB = libdeflatestatic.lib
SHARED_LIB = libdeflate.dll

View File

@@ -0,0 +1,7 @@
cmake_minimum_required(VERSION 3.1)
project(test_package C)
find_package(libdeflate REQUIRED CONFIG)
add_executable(${PROJECT_NAME} test_package.c)
target_link_libraries(${PROJECT_NAME} PRIVATE libdeflate::libdeflate)

View File

@@ -0,0 +1,26 @@
from conan import ConanFile
from conan.tools.build import can_run
from conan.tools.cmake import cmake_layout, CMake
import os
class TestPackageConan(ConanFile):
settings = "os", "arch", "compiler", "build_type"
generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv"
test_type = "explicit"
def layout(self):
cmake_layout(self)
def requirements(self):
self.requires(self.tested_reference_str)
def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()
def test(self):
if can_run(self):
bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package")
self.run(bin_path, env="conanrun")

View File

@@ -0,0 +1,8 @@
#include <libdeflate.h>
int main () {
struct libdeflate_compressor *c;
c = libdeflate_alloc_compressor(12);
libdeflate_free_compressor(c);
return 0;
}