From 43736ece0a5b45b5f4293f208e6ffa1da4e6374d Mon Sep 17 00:00:00 2001 From: Bobbey Reese Date: Sun, 8 Jan 2023 15:25:55 -0500 Subject: [PATCH] (#13646) lzham: Add cci.20220103 * lzham: Add 1.0.0 * Respond to comments * Fix lint error --- recipes/lzham/all/conandata.yml | 33 ++++ recipes/lzham/all/conanfile.py | 158 ++++++++++++++++++ .../patches/aarch64-yield-cci.20220103.patch | 16 ++ .../cmake-min-req-swap-cci.20220103.patch | 55 ++++++ .../patches/cmake-rm-tests-cci.20220103.patch | 12 ++ .../all/patches/fix-osx-cci.20220103.patch | 28 ++++ .../all/patches/msvc-conan-cci.20220103.patch | 83 +++++++++ .../use-lzham-types-cci.20220103.patch | 142 ++++++++++++++++ recipes/lzham/all/test_package/CMakeLists.txt | 7 + recipes/lzham/all/test_package/conanfile.py | 27 +++ .../lzham/all/test_package/test_package.cpp | 23 +++ .../lzham/all/test_v1_package/CMakeLists.txt | 10 ++ .../lzham/all/test_v1_package/conanfile.py | 17 ++ recipes/lzham/config.yml | 3 + 14 files changed, 614 insertions(+) create mode 100644 recipes/lzham/all/conandata.yml create mode 100644 recipes/lzham/all/conanfile.py create mode 100644 recipes/lzham/all/patches/aarch64-yield-cci.20220103.patch create mode 100644 recipes/lzham/all/patches/cmake-min-req-swap-cci.20220103.patch create mode 100644 recipes/lzham/all/patches/cmake-rm-tests-cci.20220103.patch create mode 100644 recipes/lzham/all/patches/fix-osx-cci.20220103.patch create mode 100644 recipes/lzham/all/patches/msvc-conan-cci.20220103.patch create mode 100644 recipes/lzham/all/patches/use-lzham-types-cci.20220103.patch create mode 100644 recipes/lzham/all/test_package/CMakeLists.txt create mode 100644 recipes/lzham/all/test_package/conanfile.py create mode 100644 recipes/lzham/all/test_package/test_package.cpp create mode 100644 recipes/lzham/all/test_v1_package/CMakeLists.txt create mode 100644 recipes/lzham/all/test_v1_package/conanfile.py create mode 100644 recipes/lzham/config.yml diff --git a/recipes/lzham/all/conandata.yml b/recipes/lzham/all/conandata.yml new file mode 100644 index 0000000000000..17b541de9d7b8 --- /dev/null +++ b/recipes/lzham/all/conandata.yml @@ -0,0 +1,33 @@ +sources: + "cci.20220103": + sha256: "3e3ccf7a57b1e6a90099784597aa7da30de3249a5f7fe532cefb3a77db5acbfb" + url: "https://github.com/richgel999/lzham_codec/archive/d379b1f9121e2197881c61cfc4713c78848bdfe7.zip" +patches: + "cci.20220103": + - patch_file: "patches/aarch64-yield-cci.20220103.patch" + patch_description: 'Uses "yield" rather than "pause" mneumonic to fix + aarch64 build' + patch_type: portability + + - patch_file: "patches/cmake-min-req-swap-cci.20220103.patch" + patch_description: 'Puts cmake_minimum_required before project in all + CMakeLists' + patch_type: portability + + - patch_file: "patches/fix-osx-cci.20220103.patch" + patch_description: "Fixes building on OSX" + patch_type: portability + + - patch_file: "patches/use-lzham-types-cci.20220103.patch" + patch_description: 'Uses typedefs prefixed with LZHAM to fix linux build + errors' + patch_type: portability + + - patch_file: "patches/cmake-rm-tests-cci.20220103.patch" + patch_description: "Skips building of lzhamtest for CMake" + patch_type: conan + + - patch_file: "patches/msvc-conan-cci.20220103.patch" + patch_description: 'Skips building of lzhamtest and examples for MSVC, + and injects conan toolchain for MSVC' + patch_type: conan diff --git a/recipes/lzham/all/conanfile.py b/recipes/lzham/all/conanfile.py new file mode 100644 index 0000000000000..b1b9dc2a684e4 --- /dev/null +++ b/recipes/lzham/all/conanfile.py @@ -0,0 +1,158 @@ +import os + +from conan import ConanFile +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import ( + apply_conandata_patches, + copy, + export_conandata_patches, + get, + rmdir +) +from conan.tools.microsoft import ( + MSBuild, MSBuildDeps, MSBuildToolchain, VCVars, is_msvc, vs_layout +) + +required_conan_version = ">=1.52.0" + +SLN_FILE = "lzham.sln" + + +class PackageConan(ConanFile): + name = "lzham" + + description = ( + "Compression algorithm similar compression ratio and faster " + "decompression than LZMA." + ) + + license = "LicenseRef-LICENSE" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/richgel999/lzham_codec" + topics = ("compression", "lz-compression") + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": 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") + + def layout(self): + if is_msvc(self): + vs_layout(self) + else: + cmake_layout(self, src_folder="src") + + def source(self): + get( + self, + **self.conan_data["sources"][self.version], + destination=self.source_folder, + strip_root=True + ) + + def generate(self): + if is_msvc(self): + tc = MSBuildToolchain(self) + tc.generate() + tc = MSBuildDeps(self) + tc.generate() + tc = VCVars(self) + tc.generate() + else: + tc = CMakeToolchain(self) + + # Honor BUILD_SHARED_LIBS from conan_toolchain (see + # https://github.com/conan-io/conan/issues/11840) + tc.cache_variables["CMAKE_POLICY_DEFAULT_CMP0077"] = "NEW" + tc.generate() + + def build(self): + apply_conandata_patches(self) + if is_msvc(self): + msbuild = MSBuild(self) + msbuild.build_type = ( + "Debug" if self.settings.build_type == "Debug" else "Release" + ) + msbuild.platform = ( + "Win32" if self.settings.arch == "x86" else msbuild.platform + ) + msbuild.build(sln="lzham.sln") + else: + cmake = CMake(self) + cmake.configure() + cmake.build() + + def package(self): + copy( + self, + pattern="LICENSE", + dst=os.path.join(self.package_folder, "licenses"), + src=self.source_folder + ) + + if is_msvc(self): + suffix = "x64D" if self.settings.build_type == "Debug" else "x64" + copy( + self, + pattern=f"lzham_{suffix}.lib", + dst=os.path.join(self.package_folder, "lib"), + src=os.path.join(self.build_folder, "lib", "x64"), + keep_path=False + ) + copy( + self, + pattern=f"lzham_{suffix}.dll", + dst=os.path.join(self.package_folder, "bin"), + src=os.path.join(self.build_folder, "bin"), + keep_path=False + ) + copy( + self, + pattern="*.h", + dst=os.path.join(self.package_folder, "include"), + src=os.path.join(self.source_folder, "include"), + ) + else: + cmake = CMake(self) + cmake.install() + + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) + rmdir(self, os.path.join(self.package_folder, "res")) + rmdir(self, os.path.join(self.package_folder, "share")) + + def package_info(self): + if self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.system_libs.extend(["m", "pthread"]) + + if is_msvc(self): + lib_name = "lzham_x64" + if self.settings.build_type == "Debug": + lib_name += "D" + self.cpp_info.libs = [lib_name] + else: + self.cpp_info.libs = ["lzhamdll", "lzhamcomp", "lzhamdecomp"] + self.cpp_info.set_property("cmake_file_name", "lzham") + self.cpp_info.set_property("cmake_target_name", "lzham::lzham") + self.cpp_info.set_property("pkg_config_name", "lzham") + + # TODO: to remove in conan v2 once cmake_find_package_* generators + # removed + self.cpp_info.names["cmake_find_package"] = "lzham" + self.cpp_info.names["cmake_find_package_multi"] = "lzham" + self.cpp_info.names["pkg_config"] = "lzham" diff --git a/recipes/lzham/all/patches/aarch64-yield-cci.20220103.patch b/recipes/lzham/all/patches/aarch64-yield-cci.20220103.patch new file mode 100644 index 0000000000000..313029dda755c --- /dev/null +++ b/recipes/lzham/all/patches/aarch64-yield-cci.20220103.patch @@ -0,0 +1,16 @@ +diff --git a/lzhamdecomp/lzham_platform.h b/lzhamdecomp/lzham_platform.h +index 01704be..920a8f4 100644 +--- a/lzhamdecomp/lzham_platform.h ++++ b/lzhamdecomp/lzham_platform.h +@@ -24,7 +24,11 @@ void lzham_fail(const char* pExp, const char* pFile, unsigned line); + #if defined(__GNUC__) && LZHAM_PLATFORM_PC + extern __inline__ __attribute__((__always_inline__,__gnu_inline__)) void lzham_yield_processor() + { ++ #if defined(__aarch64__) ++ __asm__ __volatile__("yield"); ++ #else + __asm__ __volatile__("pause"); ++ #endif + } + #elif LZHAM_PLATFORM_X360 + #define lzham_yield_processor() \ diff --git a/recipes/lzham/all/patches/cmake-min-req-swap-cci.20220103.patch b/recipes/lzham/all/patches/cmake-min-req-swap-cci.20220103.patch new file mode 100644 index 0000000000000..8c598c5b49697 --- /dev/null +++ b/recipes/lzham/all/patches/cmake-min-req-swap-cci.20220103.patch @@ -0,0 +1,55 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 428cdfc..b8980e5 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -1,5 +1,5 @@ +-# PROJECT(lzham) + cmake_minimum_required(VERSION 2.8) ++PROJECT(lzham) + option(BUILD_X64 "build 64-bit" ON) + option(BUILD_SHARED_LIBS "build shared/static libs" ON) + +diff --git a/lzhamcomp/CMakeLists.txt b/lzhamcomp/CMakeLists.txt +index c80cc66..a3f77e7 100644 +--- a/lzhamcomp/CMakeLists.txt ++++ b/lzhamcomp/CMakeLists.txt +@@ -1,5 +1,5 @@ +-PROJECT(lzhamcomp) + cmake_minimum_required(VERSION 2.8) ++PROJECT(lzhamcomp) + option(BUILD_X64 "build 64-bit" TRUE) + + message("Initial BUILD_X64=${BUILD_X64}") +diff --git a/lzhamdecomp/CMakeLists.txt b/lzhamdecomp/CMakeLists.txt +index bf87a02..723379e 100644 +--- a/lzhamdecomp/CMakeLists.txt ++++ b/lzhamdecomp/CMakeLists.txt +@@ -1,5 +1,5 @@ +-PROJECT(lzhamdecomp) + cmake_minimum_required(VERSION 2.8) ++PROJECT(lzhamdecomp) + option(BUILD_X64 "build 64-bit" TRUE) + + message("Initial BUILD_X64=${BUILD_X64}") +diff --git a/lzhamdll/CMakeLists.txt b/lzhamdll/CMakeLists.txt +index f77f3fe..5a162b6 100644 +--- a/lzhamdll/CMakeLists.txt ++++ b/lzhamdll/CMakeLists.txt +@@ -1,5 +1,5 @@ +-PROJECT(lzhamdll) + cmake_minimum_required(VERSION 2.8) ++PROJECT(lzhamdll) + option(BUILD_X64 "build 64-bit" TRUE) + + message("Initial BUILD_X64=${BUILD_X64}") +diff --git a/lzhamtest/CMakeLists.txt b/lzhamtest/CMakeLists.txt +index 3349911..b8833b9 100644 +--- a/lzhamtest/CMakeLists.txt ++++ b/lzhamtest/CMakeLists.txt +@@ -1,5 +1,5 @@ +-PROJECT(lzhamtest) + cmake_minimum_required(VERSION 2.8) ++PROJECT(lzhamtest) + option(BUILD_X64 "build 64-bit" TRUE) + + message("Initial BUILD_X64=${BUILD_X64}") diff --git a/recipes/lzham/all/patches/cmake-rm-tests-cci.20220103.patch b/recipes/lzham/all/patches/cmake-rm-tests-cci.20220103.patch new file mode 100644 index 0000000000000..7b5cf8afef5f7 --- /dev/null +++ b/recipes/lzham/all/patches/cmake-rm-tests-cci.20220103.patch @@ -0,0 +1,12 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 428cdfc..1857db2 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -6,7 +6,6 @@ option(BUILD_SHARED_LIBS "build shared/static libs" ON) + add_subdirectory(lzhamdecomp) + add_subdirectory(lzhamcomp) + add_subdirectory(lzhamdll) +-add_subdirectory(lzhamtest) + + install(FILES include/lzham_dynamic_lib.h + include/lzham_exports.inc diff --git a/recipes/lzham/all/patches/fix-osx-cci.20220103.patch b/recipes/lzham/all/patches/fix-osx-cci.20220103.patch new file mode 100644 index 0000000000000..156502e346443 --- /dev/null +++ b/recipes/lzham/all/patches/fix-osx-cci.20220103.patch @@ -0,0 +1,28 @@ +diff --git a/lzhamdecomp/lzham_platform.cpp b/lzhamdecomp/lzham_platform.cpp +index cfc85c1..599a847 100644 +--- a/lzhamdecomp/lzham_platform.cpp ++++ b/lzhamdecomp/lzham_platform.cpp +@@ -61,7 +61,7 @@ void lzham_debug_break(void) + { + #if LZHAM_USE_WIN32_API + DebugBreak(); +-#elif (TARGET_OS_MAC == 1) && (TARGET_IPHONE_SIMULATOR == 0) && (TARGET_OS_IPHONE == 0) ++#elif (TARGET_OS_MAC == 1) && (TARGET_IPHONE_SIMULATOR == 0) && (TARGET_OS_IPHONE == 0) && !defined(__clang__) + __asm {int 3} + #else + assert(0); +diff --git a/lzhamdecomp/lzham_traits.h b/lzhamdecomp/lzham_traits.h +index ea7214f..e103bad 100644 +--- a/lzhamdecomp/lzham_traits.h ++++ b/lzhamdecomp/lzham_traits.h +@@ -67,7 +67,9 @@ namespace lzham + // Defines type Q as bitwise copyable. + #define LZHAM_DEFINE_BITWISE_COPYABLE(Q) template<> struct bitwise_copyable { enum { cFlag = true }; }; + +-#if defined(__APPLE__) || defined(__NetBSD__) ++#if defined(__APPLE__) ++ #define LZHAM_IS_POD(T) std::is_pod::value ++#elif defined(__NetBSD__) + #define LZHAM_IS_POD(T) std::__is_pod::__value + #else + #define LZHAM_IS_POD(T) __is_pod(T) diff --git a/recipes/lzham/all/patches/msvc-conan-cci.20220103.patch b/recipes/lzham/all/patches/msvc-conan-cci.20220103.patch new file mode 100644 index 0000000000000..ca0b641855eed --- /dev/null +++ b/recipes/lzham/all/patches/msvc-conan-cci.20220103.patch @@ -0,0 +1,83 @@ +diff --git a/lzham.sln b/lzham.sln +index 5c0edb6..63343f3 100644 +--- a/lzham.sln ++++ b/lzham.sln +@@ -3,22 +3,12 @@ Microsoft Visual Studio Solution File, Format Version 11.00 + # Visual Studio 2010 + Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "lzhamdll", "lzhamdll\lzham.vcxproj", "{763BE79D-1280-41B7-81C5-7DC41E2BDB44}" + EndProject +-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "lzhamtest", "lzhamtest\lzhamtest.vcxproj", "{BBE16587-150E-460C-8AB4-F18B92D0B981}" +-EndProject + Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "lzhamdecomp", "lzhamdecomp\lzhamdecomp.vcxproj", "{8DA0CD32-701D-48D7-AE92-728338501500}" + EndProject + Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "lzhamcomp", "lzhamcomp\lzhamcomp.vcxproj", "{8DA0CD46-791D-48D7-AE92-728338501500}" + EndProject +-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example1", "example1\example1.vcxproj", "{BBE16587-150E-460C-8AB4-E18B92D0B982}" +-EndProject + Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "lzhamlib", "lzhamlib\lzhamlib.vcxproj", "{83A2F0B5-1D02-4A13-B579-714F60E31774}" + EndProject +-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example2", "example2\example2.vcxproj", "{CBE16587-150E-460C-8AB4-E18B92D0B983}" +-EndProject +-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example3", "example3\example3.vcxproj", "{1BE16587-150E-460C-8AB4-E18B92D0BA87}" +-EndProject +-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example4", "example4\example4.vcxproj", "{1BE16587-260E-460C-8AB4-E18B92D0BA87}" +-EndProject + Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 +diff --git a/lzhamcomp/lzhamcomp.vcxproj b/lzhamcomp/lzhamcomp.vcxproj +index 5fd6155..b45f3dc 100644 +--- a/lzhamcomp/lzhamcomp.vcxproj ++++ b/lzhamcomp/lzhamcomp.vcxproj +@@ -23,6 +23,9 @@ + lzhamcomp + Win32Proj + ++ ++ ++ + + + StaticLibrary +diff --git a/lzhamdecomp/lzhamdecomp.vcxproj b/lzhamdecomp/lzhamdecomp.vcxproj +index dbaf54c..5f78ca5 100644 +--- a/lzhamdecomp/lzhamdecomp.vcxproj ++++ b/lzhamdecomp/lzhamdecomp.vcxproj +@@ -23,6 +23,9 @@ + lzhamdecomp + Win32Proj + ++ ++ ++ + + + StaticLibrary +diff --git a/lzhamdll/lzham.vcxproj b/lzhamdll/lzham.vcxproj +index ec0a280..5536234 100644 +--- a/lzhamdll/lzham.vcxproj ++++ b/lzhamdll/lzham.vcxproj +@@ -24,6 +24,9 @@ + lzham + Win32Proj + ++ ++ ++ + + + DynamicLibrary +diff --git a/lzhamlib/lzhamlib.vcxproj b/lzhamlib/lzhamlib.vcxproj +index 954dd99..cdd2c26 100644 +--- a/lzhamlib/lzhamlib.vcxproj ++++ b/lzhamlib/lzhamlib.vcxproj +@@ -23,6 +23,9 @@ + lzhamlib + Win32Proj + ++ ++ ++ + + + StaticLibrary diff --git a/recipes/lzham/all/patches/use-lzham-types-cci.20220103.patch b/recipes/lzham/all/patches/use-lzham-types-cci.20220103.patch new file mode 100644 index 0000000000000..db6f4925fa490 --- /dev/null +++ b/recipes/lzham/all/patches/use-lzham-types-cci.20220103.patch @@ -0,0 +1,142 @@ +diff --git a/lzhamcomp/lzham_win32_threading.h b/lzhamcomp/lzham_win32_threading.h +index 0e1d16b..4aaff8c 100644 +--- a/lzhamcomp/lzham_win32_threading.h ++++ b/lzhamcomp/lzham_win32_threading.h +@@ -43,9 +43,9 @@ namespace lzham + } + } + +- bool wait(uint32 milliseconds = UINT32_MAX) ++ bool wait(uint32 milliseconds = LZHAM_UINT32_MAX) + { +- LZHAM_ASSUME(INFINITE == UINT32_MAX); ++ LZHAM_ASSUME(INFINITE == LZHAM_UINT32_MAX); + + DWORD result = WaitForSingleObject(m_handle, milliseconds); + +diff --git a/lzhamdecomp/lzham_huffman_codes.cpp b/lzhamdecomp/lzham_huffman_codes.cpp +index 11bdbd4..788414a 100644 +--- a/lzhamdecomp/lzham_huffman_codes.cpp ++++ b/lzhamdecomp/lzham_huffman_codes.cpp +@@ -224,7 +224,7 @@ namespace lzham + + sym_freq& sf = state.syms0[num_used_syms]; + sf.m_left = (uint16)i; +- sf.m_right = UINT16_MAX; ++ sf.m_right = LZHAM_UINT16_MAX; + sf.m_freq = freq; + num_used_syms++; + } +diff --git a/lzhamdecomp/lzham_prefix_coding.cpp b/lzhamdecomp/lzham_prefix_coding.cpp +index e9ada15..52377c9 100644 +--- a/lzhamdecomp/lzham_prefix_coding.cpp ++++ b/lzhamdecomp/lzham_prefix_coding.cpp +@@ -149,7 +149,7 @@ namespace lzham + { + uint c = pCodesizes[i]; + +- LZHAM_ASSERT(!c || (next_code[c] <= UINT16_MAX)); ++ LZHAM_ASSERT(!c || (next_code[c] <= LZHAM_UINT16_MAX)); + + pCodes[i] = static_cast(next_code[c]++); + +@@ -296,7 +296,7 @@ namespace lzham + + LZHAM_ASSERT(t < (1U << table_bits)); + +- LZHAM_ASSERT(pTables->m_lookup[t] == UINT32_MAX); ++ LZHAM_ASSERT(pTables->m_lookup[t] == LZHAM_UINT32_MAX); + + pTables->m_lookup[t] = sym_index | (codesize << 16U); + } +diff --git a/lzhamdecomp/lzham_symbol_codec.cpp b/lzhamdecomp/lzham_symbol_codec.cpp +index 5623584..b2ea7ee 100644 +--- a/lzhamdecomp/lzham_symbol_codec.cpp ++++ b/lzhamdecomp/lzham_symbol_codec.cpp +@@ -581,7 +581,7 @@ namespace lzham + freq++; + m_sym_freq[sym] = static_cast(freq); + +- LZHAM_ASSERT(freq <= UINT16_MAX); ++ LZHAM_ASSERT(freq <= LZHAM_UINT16_MAX); + + if (--m_symbols_until_update == 0) + { +@@ -828,7 +828,7 @@ namespace lzham + freq++; + model.m_sym_freq[sym] = static_cast(freq); + +- LZHAM_ASSERT(freq <= UINT16_MAX); ++ LZHAM_ASSERT(freq <= LZHAM_UINT16_MAX); + + if (--model.m_symbols_until_update == 0) + { +@@ -1265,8 +1265,8 @@ namespace lzham + { + uint32 t = pTables->m_lookup[m_bit_buf >> (cBitBufSize - pTables->m_table_bits)]; + +- LZHAM_ASSERT(t != UINT32_MAX); +- sym = t & UINT16_MAX; ++ LZHAM_ASSERT(t != LZHAM_UINT32_MAX); ++ sym = t & LZHAM_UINT16_MAX; + len = t >> 16; + + LZHAM_ASSERT(model.m_code_sizes[sym] == len); +@@ -1301,7 +1301,7 @@ namespace lzham + freq++; + model.m_sym_freq[sym] = static_cast(freq); + +- LZHAM_ASSERT(freq <= UINT16_MAX); ++ LZHAM_ASSERT(freq <= LZHAM_UINT16_MAX); + + if (--model.m_symbols_until_update == 0) + { +diff --git a/lzhamdecomp/lzham_symbol_codec.h b/lzhamdecomp/lzham_symbol_codec.h +index 306d59b..b231530 100644 +--- a/lzhamdecomp/lzham_symbol_codec.h ++++ b/lzhamdecomp/lzham_symbol_codec.h +@@ -19,7 +19,7 @@ namespace lzham + typedef uint64 bit_cost_t; + const uint32 cBitCostScaleShift = 24; + const uint32 cBitCostScale = (1U << cBitCostScaleShift); +- const bit_cost_t cBitCostMax = UINT64_MAX; ++ const bit_cost_t cBitCostMax = LZHAM_UINT64_MAX; + + inline bit_cost_t convert_to_scaled_bitcost(uint bits) { LZHAM_ASSERT(bits <= 255); uint32 scaled_bits = bits << cBitCostScaleShift; return static_cast(scaled_bits); } + +@@ -444,7 +444,7 @@ namespace lzham + if (LZHAM_BUILTIN_EXPECT(k <= pTables->m_table_max_code, 1)) \ + { \ + uint32 t = pTables->m_lookup[bit_buf >> (symbol_codec::cBitBufSize - pTables->m_table_bits)]; \ +- result = t & UINT16_MAX; \ ++ result = t & LZHAM_UINT16_MAX; \ + len = t >> 16; \ + } \ + else \ +@@ -465,7 +465,7 @@ namespace lzham + uint freq = pModel->m_sym_freq[result]; \ + freq++; \ + pModel->m_sym_freq[result] = static_cast(freq); \ +- LZHAM_ASSERT(freq <= UINT16_MAX); \ ++ LZHAM_ASSERT(freq <= LZHAM_UINT16_MAX); \ + if (LZHAM_BUILTIN_EXPECT(--pModel->m_symbols_until_update == 0, 0)) \ + { \ + pModel->update_tables(); \ +@@ -501,7 +501,7 @@ namespace lzham + if (LZHAM_BUILTIN_EXPECT(k <= pTables->m_table_max_code, 1)) \ + { \ + uint32 t = pTables->m_lookup[bit_buf >> (symbol_codec::cBitBufSize - pTables->m_table_bits)]; \ +- result = t & UINT16_MAX; \ ++ result = t & LZHAM_UINT16_MAX; \ + len = t >> 16; \ + } \ + else \ +@@ -522,7 +522,7 @@ namespace lzham + uint freq = pModel->m_sym_freq[result]; \ + freq++; \ + pModel->m_sym_freq[result] = static_cast(freq); \ +- LZHAM_ASSERT(freq <= UINT16_MAX); \ ++ LZHAM_ASSERT(freq <= LZHAM_UINT16_MAX); \ + if (LZHAM_BUILTIN_EXPECT(--pModel->m_symbols_until_update == 0, 0)) \ + { \ + pModel->update_tables(); \ diff --git a/recipes/lzham/all/test_package/CMakeLists.txt b/recipes/lzham/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..c4780ae45756c --- /dev/null +++ b/recipes/lzham/all/test_package/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package CXX) + +find_package(lzham REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PUBLIC lzham::lzham) diff --git a/recipes/lzham/all/test_package/conanfile.py b/recipes/lzham/all/test_package/conanfile.py new file mode 100644 index 0000000000000..eea09bfb32ab1 --- /dev/null +++ b/recipes/lzham/all/test_package/conanfile.py @@ -0,0 +1,27 @@ +import os + +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import cmake_layout, CMake + + +class TestPackageConan(ConanFile): + 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 can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/lzham/all/test_package/test_package.cpp b/recipes/lzham/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..c588215577f5f --- /dev/null +++ b/recipes/lzham/all/test_package/test_package.cpp @@ -0,0 +1,23 @@ +#include +#include + +#include + +int main() { + unsigned char in[] = "Hello Conan Center!"; + unsigned char out[sizeof(in)]; + + lzham_z_stream stream; + std::memset(&stream, 0, sizeof(stream)); + stream.next_in = in; + stream.avail_in = sizeof(in); + stream.next_out = out; + stream.avail_out = sizeof(out); + if (lzham_z_deflateInit(&stream, LZHAM_Z_BEST_COMPRESSION) != LZHAM_Z_OK) + return EXIT_FAILURE; + + if (lzham_z_deflate(&stream, LZHAM_Z_FULL_FLUSH) != LZHAM_Z_OK) + return EXIT_FAILURE; + + return EXIT_SUCCESS; +} diff --git a/recipes/lzham/all/test_v1_package/CMakeLists.txt b/recipes/lzham/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..231cec51e4ab9 --- /dev/null +++ b/recipes/lzham/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(lzham REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PUBLIC lzham::lzham) diff --git a/recipes/lzham/all/test_v1_package/conanfile.py b/recipes/lzham/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..0f735b51a2642 --- /dev/null +++ b/recipes/lzham/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageV1Conan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/lzham/config.yml b/recipes/lzham/config.yml new file mode 100644 index 0000000000000..d334d7a80bf72 --- /dev/null +++ b/recipes/lzham/config.yml @@ -0,0 +1,3 @@ +versions: + "cci.20220103": + folder: all