From b0910739a3fe9ade92356f2ed510049ebbccbec9 Mon Sep 17 00:00:00 2001 From: Jan Engelhardt Date: Fri, 27 Oct 2023 09:01:47 +0200 Subject: [PATCH] Revert "Switch to miniz from zlib" This reverts commit ba9ce0e83f6e25e3ddef5000bd51d53f2e3947a2. --- CMakeLists.txt | 13 ++++++++++++- src/CMakeLists.txt | 4 ++-- src/common/audio/music/i_music.cpp | 3 ++- src/common/engine/serializer.cpp | 3 ++- src/common/filesystem/source/files_decompress.cpp | 3 ++- src/common/filesystem/source/filesystem.cpp | 3 ++- src/common/filesystem/source/resourcefile.cpp | 3 ++- src/common/models/model.cpp | 13 +++++++++++-- src/common/platform/win32/i_crash.cpp | 3 ++- src/common/textures/m_png.cpp | 3 ++- src/common/thirdparty/m_crc32.h | 6 ++++-- src/g_pch.h | 3 ++- src/g_pch2.h | 3 ++- src/maploader/glnodes.cpp | 3 ++- src/serializer_doom.cpp | 3 ++- tools/zipdir/CMakeLists.txt | 4 ++-- tools/zipdir/zipdir.c | 3 ++- vcpkg.json | 4 ++++ 18 files changed, 59 insertions(+), 21 deletions(-) Index: gzdoom-g4.12.2/CMakeLists.txt =================================================================== --- gzdoom-g4.12.2.orig/CMakeLists.txt +++ gzdoom-g4.12.2/CMakeLists.txt @@ -215,6 +215,7 @@ option( NO_OPENAL "Disable OpenAL sound find_package( BZip2 ) find_package( VPX ) +find_package( ZLIB ) include( TargetArch ) @@ -332,6 +333,7 @@ set( CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE set( CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} ${REL_C_FLAGS}" ) set( CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${DEB_C_FLAGS} -D_DEBUG" ) +option(FORCE_INTERNAL_ZLIB "Use internal zlib") option(FORCE_INTERNAL_BZIP2 "Use internal bzip2") option(FORCE_INTERNAL_ASMJIT "Use internal asmjit" ON) mark_as_advanced( FORCE_INTERNAL_ASMJIT ) @@ -348,6 +350,16 @@ set( DRPC_INCLUDE_DIR "-I/ignore" ) set( DRPC_LIBRARIES -ldiscord-rpc ) set( DRPC_LIBRARY -ldiscord-rpc ) +if( ZLIB_FOUND AND NOT FORCE_INTERNAL_ZLIB ) + message( STATUS "Using system zlib, includes found at ${ZLIB_INCLUDE_DIR}" ) +else() + message( STATUS "Using internal zlib" ) + set( SKIP_INSTALL_ALL TRUE ) # Avoid installing zlib + set( ZLIB_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/libraries/zlib ) + set( ZLIB_LIBRARIES z ) + set( ZLIB_LIBRARY z ) +endif() + if( HAVE_VM_JIT AND UNIX ) check_symbol_exists( "backtrace" "execinfo.h" HAVE_BACKTRACE ) if( NOT HAVE_BACKTRACE ) @@ -406,7 +418,6 @@ install(DIRECTORY docs/ option( DYN_OPENAL "Dynamically load OpenAL" ON ) add_subdirectory( libraries/lzma ) -add_subdirectory( libraries/miniz ) add_subdirectory( tools ) add_subdirectory( wadsrc ) add_subdirectory( wadsrc_bm ) Index: gzdoom-g4.12.2/src/CMakeLists.txt =================================================================== --- gzdoom-g4.12.2.orig/src/CMakeLists.txt +++ gzdoom-g4.12.2/src/CMakeLists.txt @@ -319,7 +319,7 @@ add_custom_target( revision_check ALL # required libraries -set( PROJECT_LIBRARIES ${PROJECT_LIBRARIES} miniz "${BZIP2_LIBRARIES}" "${CMAKE_DL_LIBS}" "${DRPC_LIBRARIES}") +set( PROJECT_LIBRARIES ${PROJECT_LIBRARIES} "${ZLIB_LIBRARIES}" "${BZIP2_LIBRARIES}" "${CMAKE_DL_LIBS}" "${DRPC_LIBRARIES}") if (HAVE_VULKAN) list( APPEND PROJECT_LIBRARIES "zvulkan" ) endif() @@ -383,7 +383,7 @@ else() message( SEND_ERROR "Could not find libvpx" ) endif() -include_directories( SYSTEM "${BZIP2_INCLUDE_DIR}" "${LZMA_INCLUDE_DIR}" "${ZMUSIC_INCLUDE_DIR}" "${DRPC_INCLUDE_DIR}") +include_directories( SYSTEM "${ZLIB_INCLUDE_DIR}" "${BZIP2_INCLUDE_DIR}" "${LZMA_INCLUDE_DIR}" "${ZMUSIC_INCLUDE_DIR}" "${DRPC_INCLUDE_DIR}") if( ${HAVE_VM_JIT} ) add_definitions( -DHAVE_VM_JIT ) Index: gzdoom-g4.12.2/src/common/audio/music/i_music.cpp =================================================================== --- gzdoom-g4.12.2.orig/src/common/audio/music/i_music.cpp +++ gzdoom-g4.12.2/src/common/audio/music/i_music.cpp @@ -37,7 +37,8 @@ #include #endif -#include +#include +#include #include #include "filesystem.h" Index: gzdoom-g4.12.2/src/common/engine/serializer.cpp =================================================================== --- gzdoom-g4.12.2.orig/src/common/engine/serializer.cpp +++ gzdoom-g4.12.2/src/common/engine/serializer.cpp @@ -37,7 +37,8 @@ #define RAPIDJSON_HAS_CXX11_RANGE_FOR 1 #define RAPIDJSON_PARSE_DEFAULT_FLAGS kParseFullPrecisionFlag -#include +#include +#include #include "rapidjson/rapidjson.h" #include "rapidjson/writer.h" #include "rapidjson/prettywriter.h" Index: gzdoom-g4.12.2/src/common/filesystem/source/files_decompress.cpp =================================================================== --- gzdoom-g4.12.2.orig/src/common/filesystem/source/files_decompress.cpp +++ gzdoom-g4.12.2/src/common/filesystem/source/files_decompress.cpp @@ -39,7 +39,8 @@ #include "Xz.h" // CRC table needs to be generated prior to reading XZ compressed files. #include "7zCrc.h" -#include +#include +#include #include #include #include Index: gzdoom-g4.12.2/src/common/filesystem/source/filesystem.cpp =================================================================== --- gzdoom-g4.12.2.orig/src/common/filesystem/source/filesystem.cpp +++ gzdoom-g4.12.2/src/common/filesystem/source/filesystem.cpp @@ -36,7 +36,8 @@ // HEADER FILES ------------------------------------------------------------ -#include +#include +#include #include #include #include Index: gzdoom-g4.12.2/src/common/filesystem/source/resourcefile.cpp =================================================================== --- gzdoom-g4.12.2.orig/src/common/filesystem/source/resourcefile.cpp +++ gzdoom-g4.12.2/src/common/filesystem/source/resourcefile.cpp @@ -35,7 +35,8 @@ */ #include -#include +#include +#include #include "resourcefile.h" #include "md5.hpp" #include "fs_stringpool.h" Index: gzdoom-g4.12.2/src/common/models/model.cpp =================================================================== --- gzdoom-g4.12.2.orig/src/common/models/model.cpp +++ gzdoom-g4.12.2/src/common/models/model.cpp @@ -25,7 +25,6 @@ ** General model handling code ** **/ -#include // offsetof() macro. #include "filesystem.h" #include "cmdlib.h" @@ -132,7 +131,17 @@ FTextureID LoadSkin(const char * path, c int ModelFrameHash(FSpriteModelFrame * smf) { - return crc32(0, (const unsigned char *)(&smf->type), offsetof(FSpriteModelFrame, hashnext) - offsetof(FSpriteModelFrame, type)); + const uint32_t *table = GetCRCTable (); + uint32_t hash = 0xffffffff; + + const char * s = (const char *)(&smf->type); // this uses type, sprite and frame for hashing + const char * se= (const char *)(&smf->hashnext); + + for (; s -#include +#include +#include // MACROS ------------------------------------------------------------------ Index: gzdoom-g4.12.2/src/common/textures/m_png.cpp =================================================================== --- gzdoom-g4.12.2.orig/src/common/textures/m_png.cpp +++ gzdoom-g4.12.2/src/common/textures/m_png.cpp @@ -36,7 +36,8 @@ #include #include -#include +#include +#include #include #ifdef _MSC_VER #include // for alloca() Index: gzdoom-g4.12.2/src/common/thirdparty/m_crc32.h =================================================================== --- gzdoom-g4.12.2.orig/src/common/thirdparty/m_crc32.h +++ gzdoom-g4.12.2/src/common/thirdparty/m_crc32.h @@ -32,11 +32,13 @@ ** */ #pragma once -#include +#include +#include #include -// miniz includes some CRC32 stuff, so just use that +// zlib includes some CRC32 stuff, so just use that +inline const uint32_t *GetCRCTable () { return (const uint32_t *)get_crc_table(); } inline uint32_t CalcCRC32 (const uint8_t *buf, unsigned int len) { return crc32 (0, buf, len); Index: gzdoom-g4.12.2/src/g_pch.h =================================================================== --- gzdoom-g4.12.2.orig/src/g_pch.h +++ gzdoom-g4.12.2/src/g_pch.h @@ -10,7 +10,8 @@ #include #include #include -#include +#include +#include #include #include #include Index: gzdoom-g4.12.2/src/g_pch2.h =================================================================== --- gzdoom-g4.12.2.orig/src/g_pch2.h +++ gzdoom-g4.12.2/src/g_pch2.h @@ -11,7 +11,8 @@ #include #include #include -#include +#include +#include #include #include #include Index: gzdoom-g4.12.2/src/maploader/glnodes.cpp =================================================================== --- gzdoom-g4.12.2.orig/src/maploader/glnodes.cpp +++ gzdoom-g4.12.2/src/maploader/glnodes.cpp @@ -42,7 +42,8 @@ #endif -#include +#include +#include #include "m_argv.h" #include "c_dispatch.h" Index: gzdoom-g4.12.2/src/serializer_doom.cpp =================================================================== --- gzdoom-g4.12.2.orig/src/serializer_doom.cpp +++ gzdoom-g4.12.2/src/serializer_doom.cpp @@ -38,7 +38,8 @@ #define RAPIDJSON_HAS_CXX11_RANGE_FOR 1 #define RAPIDJSON_PARSE_DEFAULT_FLAGS kParseFullPrecisionFlag -#include +#include +#include #include "rapidjson/rapidjson.h" #include "rapidjson/writer.h" #include "rapidjson/prettywriter.h" Index: gzdoom-g4.12.2/tools/zipdir/CMakeLists.txt =================================================================== --- gzdoom-g4.12.2.orig/tools/zipdir/CMakeLists.txt +++ gzdoom-g4.12.2/tools/zipdir/CMakeLists.txt @@ -1,9 +1,9 @@ cmake_minimum_required( VERSION 3.16 ) if( NOT CMAKE_CROSSCOMPILING ) - include_directories( SYSTEM "${BZIP2_INCLUDE_DIR}" "${LZMA_INCLUDE_DIR}" ) + include_directories( SYSTEM "${ZLIB_INCLUDE_DIR} ${BZIP2_INCLUDE_DIR}" "${LZMA_INCLUDE_DIR}" ) add_executable( zipdir zipdir.c ) - target_link_libraries( zipdir miniz ${BZIP2_LIBRARIES} lzma ) + target_link_libraries( zipdir ${ZLIB_LIBRARIES} ${BZIP2_LIBRARIES} lzma ) set( CROSS_EXPORTS ${CROSS_EXPORTS} zipdir PARENT_SCOPE ) endif() Index: gzdoom-g4.12.2/tools/zipdir/zipdir.c =================================================================== --- gzdoom-g4.12.2.orig/tools/zipdir/zipdir.c +++ gzdoom-g4.12.2/tools/zipdir/zipdir.c @@ -46,7 +46,8 @@ #include #include #include -#include +#include +#include #include "bzlib.h" #include "LzmaEnc.h" #include "7zVersion.h" Index: gzdoom-g4.12.2/vcpkg.json =================================================================== --- gzdoom-g4.12.2.orig/vcpkg.json +++ gzdoom-g4.12.2/vcpkg.json @@ -28,6 +28,10 @@ }, "dependencies": [ { + "name": "zlib", + "platform": "!windows | (windows & static & staticcrt)" + }, + { "name": "bzip2", "platform": "(!windows & static) | (windows & static & staticcrt)" },