Skip to content

Commit fcb9323

Browse files
authored
Merge pull request #96 from xamarin/libzip-1.8.0
Update libzip to 1.8.0
2 parents 5e2cfed + 61c8d25 commit fcb9323

File tree

12 files changed

+79
-28
lines changed

12 files changed

+79
-28
lines changed

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,6 @@
2121
path = external/zlib
2222
url = https://github.com/madler/zlib.git
2323
branch = master
24+
[submodule "external/zstd"]
25+
path = external/zstd
26+
url = https://github.com/facebook/zstd.git

CMakeLists.txt

Lines changed: 63 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,21 @@ set(ENABLE_GNUTLS OFF CACHE BOOL "Do not use gnutls for libzip" FORCE)
4646
set(ENABLE_OPENSSL OFF CACHE BOOL "Do not use OpenSSL for libzip" FORCE)
4747
set(ENABLE_MBEDTLS OFF CACHE BOOL "Do not use mbedtls for libzip" FORCE)
4848
set(ENABLE_WINDOWS_CRYPTO OFF CACHE BOOL "Do not use Windows Crypto" FORCE)
49+
set(ENABLE_ZSTD ON CACHE BOOL "Use zstd in libzip" FORCE)
4950

5051
if(NOT ENABLE_XZ)
5152
set(ENABLE_LZMA OFF CACHE BOOL "Do not use XZ for libzip" FORCE)
5253
endif()
5354

55+
#
56+
# zstd
57+
#
58+
set(ZSTD_MULTITHREAD_SUPPORT OFF CACHE BOOL "Do not build zstd with multi-thread support" FORCE)
59+
set(ZSTD_BUILD_STATIC ON CACHE BOOL "Build static zstd" FORCE)
60+
set(ZSTD_BUILD_SHARED OFF CACHE BOOL "Do not build shared zstd" FORCE)
61+
set(ZSTD_BUILD_PROGRAMS OFF CACHE BOOL "Do not build zstd programs" FORCE)
62+
set(ZSTD_BUILD_TESTS OFF CACHE BOOL "Do not build zstd tests" FORCE)
63+
5464
#
5565
# zlib-ng
5666
#
@@ -298,11 +308,20 @@ if(BUILD_DEPENDENCIES)
298308
add_subdirectory(external/zlib)
299309
endif()
300310

311+
if(UNIX)
312+
set(ZLIB_EXTERN "-DZEXTERN=__attribute__((visibility(\"hidden\")))")
313+
target_compile_options(
314+
zlibstatic
315+
PRIVATE
316+
-fvisibility=hidden
317+
)
318+
endif()
319+
301320
target_compile_options(
302-
zlib
321+
zlibstatic
303322
PRIVATE
304323
${LZS_C_FLAGS}
305-
-fvisibility=hidden
324+
"${ZLIB_EXTERN}"
306325
)
307326

308327
if(NOT WIN32 AND ENABLE_XZ)
@@ -316,6 +335,23 @@ if(NOT WIN32 AND ENABLE_XZ)
316335
)
317336
endif()
318337

338+
add_subdirectory(external/zstd/build/cmake)
339+
if(UNIX)
340+
set(ZSTD_EXTERN "-DZSTDLIB_VISIBILITY=__attribute__((visibility(\"hidden\")))")
341+
target_compile_options(
342+
libzstd_static
343+
PRIVATE
344+
-fvisibility=hidden
345+
)
346+
endif()
347+
348+
target_compile_options(
349+
libzstd_static
350+
PRIVATE
351+
${LZS_C_FLAGS}
352+
"${ZSTD_EXTERN}"
353+
)
354+
319355
set(BZIP2_SOURCES external/bzip2)
320356
add_library(
321357
bz2
@@ -329,11 +365,19 @@ endif()
329365
${BZIP2_SOURCES}/bzlib.c
330366
)
331367

368+
if(UNIX)
369+
target_compile_options(
370+
bz2
371+
PRIVATE
372+
-fvisibility=hidden
373+
${LZS_C_FLAGS}
374+
)
375+
endif()
376+
332377
target_compile_options(
333378
bz2
334379
PRIVATE
335380
${LZS_C_FLAGS}
336-
-fvisibility=hidden
337381
)
338382

339383
configure_file("${CMAKE_SOURCE_DIR}/data/bzip2.pc.in" "${CMAKE_BINARY_DIR}/bzip2.pc")
@@ -371,6 +415,11 @@ else()
371415

372416
list(PREPEND CMAKE_PREFIX_PATH "${ARTIFACTS_ROOT_DIR}")
373417

418+
if(WIN32)
419+
# If we don't rename the library, it won't be detected by libzip's cmake
420+
file(RENAME ${ARTIFACTS_ROOT_DIR}/lib/zstd_static.lib ${ARTIFACTS_ROOT_DIR}/lib/zstd.lib)
421+
endif()
422+
374423
add_subdirectory(external/libzip)
375424

376425
target_compile_options(
@@ -381,6 +430,8 @@ else()
381430

382431
if(UNIX)
383432
set(ZIP_EXTERN "-DZIP_EXTERN=__attribute__((visibility(\"default\")))")
433+
set(ZSTD_EXTERN "-DZSTDLIB_VISIBILITY=__attribute__((visibility(\"hidden\")))")
434+
set(ZLIB_EXTERN "-DZEXTERN=__attribute__((visibility(\"hidden\")))")
384435
target_compile_options(
385436
zip
386437
PRIVATE
@@ -393,6 +444,8 @@ else()
393444
zip
394445
PRIVATE
395446
"${ZIP_EXTERN}"
447+
"${ZSTD_EXTERN}"
448+
"${ZLIB_EXTERN}"
396449
)
397450

398451
if(APPLE)
@@ -422,6 +475,7 @@ else()
422475
else()
423476
message(STATUS "LZMA: DISABLED")
424477
endif()
478+
message(STATUS "ZSTD: ${Zstd_INCLUDE_DIR}")
425479
message(STATUS "ZLIB: ${ZLIB_INCLUDE_DIR}")
426480
message(STATUS "BZ2: ${BZIP2_INCLUDE_DIR}")
427481

@@ -430,6 +484,7 @@ else()
430484
PRIVATE
431485
${ZLIB_INCLUDE_DIR}
432486
${BZIP2_INCLUDE_DIR}
487+
${Zstd_INCLUDE_DIR}
433488
${CMAKE_BINARY_DIR}/external/libzip
434489
)
435490

@@ -506,13 +561,15 @@ else()
506561

507562
set(ZLIB_PATH "${CMAKE_BINARY_DIR}/libz-fat.a")
508563
set(BZ2_PATH "${CMAKE_BINARY_DIR}/libbz2-fat.a")
564+
set(ZSTD_PATH "${CMAKE_BINARY_DIR}/libzstd-fat.a")
509565

510566
if(ENABLE_XZ)
511567
set(LZMA_PATH "${CMAKE_BINARY_DIR}/liblzma-fat.a")
512568
endif()
513569

514570
make_fat_archive("${ARTIFACTS_ROOT_DIR}/lib/libz.a" "${ARTIFACTS_OTHER_ROOT_DIR}/lib/libz.a" "${ZLIB_PATH}")
515571
make_fat_archive("${ARTIFACTS_ROOT_DIR}/lib/libbz2.a" "${ARTIFACTS_OTHER_ROOT_DIR}/lib/libbz2.a" "${BZ2_PATH}")
572+
make_fat_archive("${ARTIFACTS_ROOT_DIR}/lib/libzstd.a" "${ARTIFACTS_OTHER_ROOT_DIR}/lib/libzstd.a" "${ZSTD_PATH}")
516573

517574
if(ENABLE_XZ)
518575
make_fat_archive("${ARTIFACTS_ROOT_DIR}/lib/liblzma.a" "${ARTIFACTS_OTHER_ROOT_DIR}/lib/liblzma.a" "${LZMA_PATH}")
@@ -521,6 +578,7 @@ else()
521578
set(LIBS
522579
${ZLIB_PATH}
523580
${BZ2_PATH}
581+
${ZSTD_PATH}
524582
)
525583

526584
if(ENABLE_XZ)
@@ -537,6 +595,7 @@ else()
537595
set(LIBS
538596
${ARTIFACTS_ROOT_DIR}/lib/${ZLIB_NAME}
539597
${ARTIFACTS_ROOT_DIR}/lib/bz2.lib
598+
${ARTIFACTS_ROOT_DIR}/lib/zstd.lib
540599
)
541600

542601
if(ENABLE_XZ)
@@ -546,6 +605,7 @@ else()
546605
set(LIBS
547606
${ARTIFACTS_ROOT_DIR}/lib/libz.a
548607
${ARTIFACTS_ROOT_DIR}/lib/libbz2.a
608+
${ARTIFACTS_ROOT_DIR}/lib/libzstd.a
549609
)
550610

551611
if(ENABLE_XZ)

LibZipSharp.UnitTest/ZipTests.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,7 @@ public void SmallTextFile ()
216216

217217
[TestCase (CompressionMethod.Deflate)]
218218
[TestCase (CompressionMethod.Bzip2)]
219+
[TestCase (CompressionMethod.ZSTD)]
219220
#if HAVE_XZ
220221
[TestCase (CompressionMethod.XZ)]
221222
#endif

LibZipSharp.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
22
<PropertyGroup>
3-
<_LibZipSharpNugetVersion>2.0.0-alpha6</_LibZipSharpNugetVersion>
3+
<_LibZipSharpNugetVersion>2.0.0-alpha7</_LibZipSharpNugetVersion>
44
<_NativeBuildDir>$(MSBuildThisFileDirectory)lzsbuild</_NativeBuildDir>
55
<_ExternalDir>$(MSBuildThisFileDirectory)external</_ExternalDir>
66
<_MonoPosixNugetVersion>7.0.0-alpha8.21302.6</_MonoPosixNugetVersion>

LibZipSharp/Xamarin.Tools.Zip/Native.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ public struct LZSVersions
4040
public string libzip;
4141
public string zlib;
4242
public string zlibng;
43+
public string zstd;
4344
public string lzma;
4445
public string libzipsharp;
4546
};
@@ -109,6 +110,7 @@ public static Versions get_versions ()
109110
LibZip = ret.libzip ?? String.Empty,
110111
Zlib = ret.zlib ?? String.Empty,
111112
ZlibNG = ret.zlibng ?? String.Empty,
113+
ZStd = ret.zstd ?? String.Empty,
112114
LZMA = ret.lzma ?? String.Empty,
113115
LibZipSharp = ret.libzipsharp ?? String.Empty
114116
};

LibZipSharp/Xamarin.Tools.Zip/Versions.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ public string Zlib {
1414
get; internal set;
1515
}
1616

17+
public string ZStd {
18+
get; internal set;
19+
}
20+
1721
public string ZlibNG {
1822
get; internal set;
1923
}

azure-pipelines.yml

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,6 @@ stages:
2323
echo "Hello"
2424
git submodule update --init --recursive
2525
displayName: "Update Submodules"
26-
- script: |
27-
cd external/libzip
28-
git apply -v ../../libzip-changes.patch
29-
displayName: "Apply Patches"
3026
- script: |
3127
build_windows.bat
3228
displayName: "Build"
@@ -59,9 +55,6 @@ stages:
5955
sudo apt -f -u install ninja-build -y
6056
git submodule update --init --recursive
6157
displayName: 'Install Tools'
62-
- bash: |
63-
patch --verbose -d external/libzip -p1 -l < libzip-changes.patch
64-
displayName: 'Apply Patch'
6558
- bash: |
6659
./build.sh -v
6760
displayName: 'Build Linux x64'
@@ -88,9 +81,6 @@ stages:
8881
brew install ninja
8982
git submodule update --init --recursive
9083
displayName: 'Install toolchain'
91-
- bash: |
92-
patch --verbose -d external/libzip -p1 -l < libzip-changes.patch
93-
displayName: 'Apply Patch'
9484
- bash: |
9585
./build.sh -v
9686
mkdir -p lzsbuild/lib/Linux

external/libzip

Submodule libzip updated 333 files

external/zstd

Submodule zstd added at a488ba1

libzip-changes.patch

Lines changed: 0 additions & 13 deletions
This file was deleted.

0 commit comments

Comments
 (0)