Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,7 @@
url = https://github.com/xz-mirror/xz.git
branch = master

[submodule "zlib"]
path = external/zlib
url = https://github.com/madler/zlib.git
branch = master
23 changes: 18 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ cmake_minimum_required(VERSION 3.18)
option(BUILD_DEPENDENCIES "Build only libzip dependencies" OFF)
option(BUILD_LIBZIP "Build libzip and libZipSharp" OFF)
option(ENABLE_XZ "Enable XZ (LZMA compression) in the build" OFF)
option(ENABLE_ZLIBNG "Use zlib-ng instead of zlib" OFF)

set(CMAKE_POSITION_INDEPENDENT_CODE True CACHE BOOL "Always build position independent code" FORCE)

Expand Down Expand Up @@ -53,9 +54,11 @@ endif()
#
# zlib-ng
#
set(ZLIB_COMPAT ON CACHE BOOL "Build zlib-ng for compatibility with zlib" FORCE)
set(ZLIB_ENABLE_TESTS OFF CACHE BOOL "Do not build zlib-ng tests" FORCE)
set(WITH_NEW_STRATEGIES OFF CACHE BOOL "Disable faster, but with worse compression, deflate strategies" FORCE)
if(ENABLE_ZLIBNG)
set(ZLIB_COMPAT ON CACHE BOOL "Build zlib-ng for compatibility with zlib" FORCE)
set(ZLIB_ENABLE_TESTS OFF CACHE BOOL "Do not build zlib-ng tests" FORCE)
set(WITH_NEW_STRATEGIES OFF CACHE BOOL "Disable faster, but with worse compression, deflate strategies" FORCE)
endif()

#
# Read product version
Expand Down Expand Up @@ -289,7 +292,11 @@ endforeach()
set(LZS_CXX_LINKER_FLAGS "${_CHECKED_FLAGS}")

if(BUILD_DEPENDENCIES)
add_subdirectory(external/zlib-ng)
if(ENABLE_ZLIBNG)
add_subdirectory(external/zlib-ng)
else()
add_subdirectory(external/zlib)
endif()

target_compile_options(
zlib
Expand Down Expand Up @@ -521,8 +528,14 @@ else()
endif()
else()
if(WIN32)
if(ENABLE_ZLIBNG)
set(ZLIB_NAME "zlib.lib")
else()
set(ZLIB_NAME "zlibstatic.lib")
endif()

set(LIBS
${ARTIFACTS_ROOT_DIR}/lib/zlib.lib
${ARTIFACTS_ROOT_DIR}/lib/${ZLIB_NAME}
${ARTIFACTS_ROOT_DIR}/lib/bz2.lib
)

Expand Down
2 changes: 1 addition & 1 deletion LibZipSharp.props
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<_LibZipSharpNugetVersion>2.0.0-alpha5</_LibZipSharpNugetVersion>
<_LibZipSharpNugetVersion>2.0.0-alpha6</_LibZipSharpNugetVersion>
<_NativeBuildDir>$(MSBuildThisFileDirectory)lzsbuild</_NativeBuildDir>
<_ExternalDir>$(MSBuildThisFileDirectory)external</_ExternalDir>
<_MonoPosixNugetVersion>7.0.0-alpha8.21302.6</_MonoPosixNugetVersion>
Expand Down
13 changes: 13 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ BUILD_DIR_ROOT="${MY_DIR}/lzsbuild"
OS=$(uname -s)
LZS_BUILD_DIR="${BUILD_DIR_ROOT}/lib/${OS}"
DEPS_BASE_BUILD_DIR="${BUILD_DIR_ROOT}/deps/${OS}"
ZLIB_DIR="external/zlib"

if [ "${OS}" == "Darwin" ]; then
DEPS_BUILD_DIR="${DEPS_BASE_BUILD_DIR}/native"
Expand All @@ -29,6 +30,7 @@ CONFIGURATION="RelWithDebInfo"
REBUILD="no"
VERBOSE="no"
USE_XZ="no"
USE_ZLIBNG="no"

# The color block is pilfered from the dotnet installer script
#
Expand Down Expand Up @@ -77,6 +79,7 @@ where OPTIONS are one or more of:
-m|--cmake PATH use cmake at PATH instead of the default of '${CMAKE}'

-x|--xz use the XZ library for LZMA support (default: ${USE_XZ})
-g|--zlib-ng use the zlib-ng library instead of zlib (default: ${USE_ZLIBNG}
-c|--configuration NAME build using configuration NAME instead of the default of '${CONFIGURATION}'
-j|--jobs NUM run at most this many build jobs in parallel
-v|--verbose make cmake and ninja verbose
Expand Down Expand Up @@ -233,6 +236,8 @@ while (( "$#" )); do

-x|--xz) USE_XZ="yes"; shift ;;

-g|--zlib-ng) USE_ZLIBNG="yes"; shift ;;

-v|--verbose) VERBOSE="yes"; shift ;;

-r|--rebuild) REBUILD="yes"; shift ;;
Expand All @@ -254,6 +259,14 @@ if [ -z "${NINJA}" ]; then
die ninja binary must be specified
fi

if [ "${USE_ZLIBNG}" == "no" ]; then
ZLIB_CMAKELISTS_PATH="${ZLIB_DIR}/CMakeLists.txt"
if ! $(grep 'lzs: disable-examples' "${ZLIB_CMAKELISTS_PATH}" > /dev/null 2>&1); then
print_banner Applying zlib patch
$(cd "${ZLIB_DIR}"; git apply "${MY_DIR}/zlib-changes.patch")
fi
fi

if [ "${REBUILD}" == "yes" ]; then
rm -rf "${BUILD_DIR_ROOT}"
rm -rf "${ARTIFACTS_DIR_ROOT}"
Expand Down
1 change: 1 addition & 0 deletions external/zlib
Submodule zlib added at cacf7f
4 changes: 4 additions & 0 deletions native/version.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@
constexpr char libzipsharp_version[] = LIBZIPSHARP_VERSION;
constexpr char libzip_version[] = LIBZIP_VERSION;
constexpr char libzlib_version[] = ZLIB_VERSION;
#if defined (ZLIBNG_VERSION)
constexpr char libzlibng_version[] = ZLIBNG_VERSION;
#else
constexpr char libzlibng_version[] = "not used";
#endif // ndef ZLIBNG_VERSION
#if defined (HAVE_XZ)
constexpr char lzma_version[] = LZMA_VERSION_STRING;
#else
Expand Down
18 changes: 18 additions & 0 deletions zlib-changes.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 0fe939d..f3ad0ed 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -229,7 +229,7 @@ endif()
#============================================================================
# Example binaries
#============================================================================
-
+if(False) # lzs: disable-examples
add_executable(example test/example.c)
target_link_libraries(example zlib)
add_test(example example)
@@ -247,3 +247,4 @@ if(HAVE_OFF64_T)
target_link_libraries(minigzip64 zlib)
set_target_properties(minigzip64 PROPERTIES COMPILE_FLAGS "-D_FILE_OFFSET_BITS=64")
endif()
+endif()