[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,40 @@
sources:
"1.5.6":
url: "https://nexus.avroid.tech/repository/devops-raw-proxy-github/facebook/zstd/releases/download/v1.5.6/zstd-1.5.6.tar.gz"
sha256: "8c29e06cf42aacc1eafc4077ae2ec6c6fcb96a626157e0593d5e82a34fd403c1"
"1.5.5":
url: "https://nexus.avroid.tech/repository/devops-raw-proxy-github/facebook/zstd/releases/download/v1.5.5/zstd-1.5.5.tar.gz"
sha256: "9c4396cc829cfae319a6e2615202e82aad41372073482fce286fac78646d3ee4"
"1.5.2":
url: "https://nexus.avroid.tech/repository/devops-raw-proxy-github/facebook/zstd/releases/download/v1.5.2/zstd-1.5.2.tar.gz"
sha256: "7c42d56fac126929a6a85dbc73ff1db2411d04f104fae9bdea51305663a83fd0"
"1.5.0":
url: "https://nexus.avroid.tech/repository/devops-raw-proxy-github/facebook/zstd/releases/download/v1.5.0/zstd-1.5.0.tar.gz"
sha256: "5194fbfa781fcf45b98c5e849651aa7b3b0a008c6b72d4a0db760f3002291e94"
patches:
"1.5.6":
- patch_file: "patches/1.5.6-public-scope-windows-shared.patch"
patch_description: "Include zstd.h folder when building shared library on Windows"
patch_type: "bugfix"
patch_source: "https://nexus.avroid.tech/repository/devops-raw-proxy-github/facebook/zstd/pull/4009"
"1.5.5":
- patch_file: "patches/1.5.2-cmake-remove-asm-except-x86_64.patch"
patch_description: "use assembler codes only on x86_64"
patch_type: "portability"
- patch_file: "patches/1.5.5-qnx_support.patch"
patch_description: "Add qnx to platform"
patch_type: "portability"
patch_source: "https://nexus.avroid.tech/repository/devops-raw-proxy-github/facebook/zstd/pull/3745"
"1.5.2":
- patch_file: "patches/1.5.2-cmake-remove-asm-except-x86_64.patch"
patch_description: "use assembler codes only on x86_64"
patch_type: "portability"
- patch_file: "patches/1.5.0-remove-explicit-standard-setting.patch"
patch_description: "fix strange performance and scalability issues"
patch_type: "bugfix"
patch_source: "https://nexus.avroid.tech/repository/devops-raw-proxy-github/facebook/zstd/pull/3167"
"1.5.0":
- patch_file: "patches/1.5.0-remove-explicit-standard-setting.patch"
patch_description: "fix strange performance and scalability issues"
patch_type: "bugfix"
patch_source: "https://nexus.avroid.tech/repository/devops-raw-proxy-github/facebook/zstd/pull/3167"

View File

@@ -0,0 +1,103 @@
from conan import ConanFile
from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout
from conan.tools.files import apply_conandata_patches, collect_libs, copy, export_conandata_patches, get, replace_in_file, rmdir, rm
import glob
import os
required_conan_version = ">=1.53.0"
class ZstdConan(ConanFile):
name = "zstd"
url = "https://github.com/conan-io/conan-center-index"
homepage = "https://github.com/facebook/zstd"
description = "Zstandard - Fast real-time compression algorithm"
topics = ("zstandard", "compression", "algorithm", "decoder")
license = "BSD-3-Clause"
package_type = "library"
settings = "os", "arch", "compiler", "build_type"
options = {
"shared": [True, False],
"fPIC": [True, False],
"threading": [True, False],
"build_programs": [True, False],
}
default_options = {
"shared": False,
"fPIC": True,
"threading": True,
"build_programs": True,
}
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):
cmake_layout(self, src_folder="src")
def source(self):
get(self, **self.conan_data["sources"][self.version], strip_root=True)
def generate(self):
tc = CMakeToolchain(self)
tc.variables["ZSTD_BUILD_PROGRAMS"] = self.options.build_programs
tc.variables["ZSTD_BUILD_STATIC"] = not self.options.shared or self.options.build_programs
tc.variables["ZSTD_BUILD_SHARED"] = self.options.shared
tc.variables["ZSTD_MULTITHREAD_SUPPORT"] = self.options.threading
tc.generate()
def _patch_sources(self):
apply_conandata_patches(self)
# Don't force PIC
replace_in_file(self, os.path.join(self.source_folder, "build", "cmake", "lib", "CMakeLists.txt"),
"POSITION_INDEPENDENT_CODE On", "")
def build(self):
self._patch_sources()
cmake = CMake(self)
cmake.configure(build_script_folder=os.path.join(self.source_folder, "build", "cmake"))
cmake.build()
def package(self):
copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses"))
cmake = CMake(self)
cmake.install()
rmdir(self, os.path.join(self.package_folder, "lib", "cmake"))
rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig"))
rmdir(self, os.path.join(self.package_folder, "share"))
if self.options.shared and self.options.build_programs:
# If we build programs we have to build static libs (see logic in generate()),
# but if shared is True, we only want shared lib in package folder.
rm(self, "*_static.*", os.path.join(self.package_folder, "lib"))
for lib in glob.glob(os.path.join(self.package_folder, "lib", "*.a")):
if not lib.endswith(".dll.a"):
os.remove(lib)
def package_info(self):
zstd_cmake = "libzstd_shared" if self.options.shared else "libzstd_static"
self.cpp_info.set_property("cmake_file_name", "zstd")
self.cpp_info.set_property("cmake_target_name", f"zstd::{zstd_cmake}")
self.cpp_info.set_property("pkg_config_name", "libzstd")
self.cpp_info.components["zstdlib"].libs = collect_libs(self)
if self.settings.os in ["Linux", "FreeBSD"]:
self.cpp_info.components["zstdlib"].system_libs.append("pthread")
# TODO: Remove after dropping Conan 1.x from ConanCenterIndex
self.cpp_info.components["zstdlib"].names["cmake_find_package"] = zstd_cmake
self.cpp_info.components["zstdlib"].names["cmake_find_package_multi"] = zstd_cmake
self.cpp_info.components["zstdlib"].set_property("cmake_target_name", f"zstd::{zstd_cmake}")
self.cpp_info.components["zstdlib"].set_property("pkg_config_name", "libzstd")
if self.options.build_programs:
bindir = os.path.join(self.package_folder, "bin")
self.env_info.PATH.append(bindir)

View File

@@ -0,0 +1,21 @@
diff --git a/a/build/cmake/CMakeModules/AddZstdCompilationFlags.cmake b/b/build/cmake/CMakeModules/AddZstdCompilationFlags.cmake
index e23b9d6..8d04458 100644
--- a/a/build/cmake/CMakeModules/AddZstdCompilationFlags.cmake
+++ b/b/build/cmake/CMakeModules/AddZstdCompilationFlags.cmake
@@ -22,10 +22,12 @@ endfunction()
macro(ADD_ZSTD_COMPILATION_FLAGS)
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang" OR MINGW) #Not only UNIX but also WIN32 for MinGW
- #Set c++11 by default
- EnableCompilerFlag("-std=c++11" false true)
- #Set c99 by default
- EnableCompilerFlag("-std=c99" true false)
+ # It's possible to select the exact standard used for compilation.
+ # It's not necessary, but can be employed for specific purposes.
+ # Note that zstd source code is compatible with both C++98 and above
+ # and C-gnu90 (c90 + long long + variadic macros ) and above
+ # EnableCompilerFlag("-std=c++11" false true) # Set C++ compilation to c++11 standard
+ # EnableCompilerFlag("-std=c99" true false) # Set C compiation to c99 standard
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND MSVC)
# clang-cl normally maps -Wall to -Weverything.
EnableCompilerFlag("/clang:-Wall" true true)

View File

@@ -0,0 +1,17 @@
diff --git a/build/cmake/lib/CMakeLists.txt b/build/cmake/lib/CMakeLists.txt
index 4905bd9..5974725 100644
--- a/build/cmake/lib/CMakeLists.txt
+++ b/build/cmake/lib/CMakeLists.txt
@@ -26,7 +26,11 @@ if (MSVC)
file(GLOB DecompressSources ${LIBRARY_DIR}/decompress/*.c)
add_compile_options(-DZSTD_DISABLE_ASM)
else ()
- file(GLOB DecompressSources ${LIBRARY_DIR}/decompress/*.c ${LIBRARY_DIR}/decompress/*.S)
+ if(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64")
+ file(GLOB DecompressSources ${LIBRARY_DIR}/decompress/*.c ${LIBRARY_DIR}/decompress/*.S)
+ else()
+ file(GLOB DecompressSources ${LIBRARY_DIR}/decompress/*.c)
+ endif()
endif ()
file(GLOB DictBuilderSources ${LIBRARY_DIR}/dictBuilder/*.c)

View File

@@ -0,0 +1,11 @@
--- programs/platform.h 2023-04-04 22:13:52.000000000 +0200
+++ programs/platform.h 2023-09-03 10:01:58.930595800 +0200
@@ -89,7 +89,7 @@
*/
# elif !defined(_WIN32) \
&& ( defined(__unix__) || defined(__unix) \
- || defined(__midipix__) || defined(__VMS) || defined(__HAIKU__) )
+ || defined(_QNX_SOURCE) || defined(__midipix__) || defined(__VMS) || defined(__HAIKU__) )
# if defined(__linux__) || defined(__linux) || defined(__CYGWIN__)
# ifndef _POSIX_C_SOURCE

View File

@@ -0,0 +1,13 @@
diff --git a/build/cmake/lib/CMakeLists.txt b/build/cmake/lib/CMakeLists.txt
index 5d514cc..1791897 100644
--- a/build/cmake/lib/CMakeLists.txt
+++ b/build/cmake/lib/CMakeLists.txt
@@ -123,7 +123,7 @@ set(PUBLIC_INCLUDE_DIRS ${LIBRARY_DIR})
set(library_targets)
if (ZSTD_BUILD_SHARED)
add_library(libzstd_shared SHARED ${Sources} ${Headers} ${PlatformDependResources})
- target_include_directories(libzstd_shared INTERFACE $<BUILD_INTERFACE:${PUBLIC_INCLUDE_DIRS}>)
+ target_include_directories(libzstd_shared PUBLIC $<BUILD_INTERFACE:${PUBLIC_INCLUDE_DIRS}>)
list(APPEND library_targets libzstd_shared)
if (ZSTD_MULTITHREAD_SUPPORT)
set_property(TARGET libzstd_shared APPEND PROPERTY COMPILE_DEFINITIONS "ZSTD_MULTITHREAD")

View File

@@ -0,0 +1,11 @@
cmake_minimum_required(VERSION 3.1)
project(test_package LANGUAGES C)
find_package(zstd REQUIRED CONFIG)
add_executable(${PROJECT_NAME} test_package.c)
if (TARGET zstd::libzstd_shared)
target_link_libraries(${PROJECT_NAME} PRIVATE zstd::libzstd_shared)
else()
target_link_libraries(${PROJECT_NAME} PRIVATE zstd::libzstd_static)
endif()

View File

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

View File

@@ -0,0 +1,12 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <zstd.h>
int main() {
const char* originalData = "Sample text";
size_t compressedSize = ZSTD_compressBound(strlen(originalData) + 1);
printf("%zu\n", compressedSize);
return 0;
}

9
recipes/zstd/config.yml Normal file
View File

@@ -0,0 +1,9 @@
versions:
"1.5.6":
folder: all
"1.5.5":
folder: all
"1.5.2":
folder: all
"1.5.0":
folder: all