Skip to content

Commit 8f2053c

Browse files
authored
Build on Windows again (#71)
Commit 755a42a reverted the system which built the native libzip.dll in Windows. This was because we suspected that the change from using mingw was causing a runtime crash. However this turned out not to be the case (see #67). So this PR adds back in the code which builds the windows dll on windows. It also updates the libzip-changes.patch so that it would apply on windows via `git apply`. This patch now works on all platforms. Also testing out a new release package system. Rather than just publishing to stable on nuget, we will first publish an `x.x.x-rc` release candidate. This will allow us to do a test PR on xamarin.android without breaking the current stable package. We had a situation over the last few months where the "stable" package actually had a crash on windows. This is not ideal for people consuming the nuget. So from now on we will publish an `-rc` do a bump in xamarin.android and if that passes, then we can publish a stable release.
1 parent 1752f95 commit 8f2053c

File tree

4 files changed

+85
-15
lines changed

4 files changed

+85
-15
lines changed

LibZipSharp.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
22
<PropertyGroup>
3-
<_LibZipSharpNugetVersion>1.0.20</_LibZipSharpNugetVersion>
3+
<_LibZipSharpNugetVersion>1.0.21-rc</_LibZipSharpNugetVersion>
44
</PropertyGroup>
55
</Project>

azure-pipelines.yml

Lines changed: 72 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,60 @@ variables:
1414
stages:
1515
- stage: Build
1616
jobs:
17+
- job: buildWindows
18+
pool:
19+
vmImage: windows-latest
20+
variables:
21+
LIBZIP_FEATURES: -DENABLE_COMMONCRYPTO=OFF -DENABLE_GNUTLS=OFF -DENABLE_MBEDTLS=OFF -DENABLE_OPENSSL=OFF -DENABLE_WINDOWS_CRYPTO=OFF -DBUILD_TOOLS=OFF -DBUILD_REGRESS=OFF -DBUILD_EXAMPLES=OFF -DBUILD_DOC=OFF -DENABLE_BZIP2=OFF -DENABLE_LZMA=OFF
22+
COMMON_CMAKE_PARAMS: -DCMAKE_BUILD_TYPE=Release -G "Visual Studio 16 2019" -DBUILD_SHARED_LIBS=ON -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded -DCMAKE_POLICY_DEFAULT_CMP0074=NEW -DCMAKE_POLICY_DEFAULT_CMP0091=NEW
23+
steps:
24+
- script: |
25+
echo "Hello"
26+
git submodule update --init --recursive
27+
displayName: "Update Submodules"
28+
- script: |
29+
cd external/libzip
30+
git apply -v ../../libzip-changes.patch
31+
displayName: "Apply Patches"
32+
- script: |
33+
cd external/vcpkg
34+
bootstrap-vcpkg.bat
35+
displayName: "Build vcpkg"
36+
- script: |
37+
external\vcpkg\vcpkg.exe integrate install
38+
external\vcpkg\vcpkg.exe install zlib:x64-windows-static
39+
mkdir .\build\Windows\64
40+
cd .\build\Windows\64
41+
cmake $(LIBZIP_FEATURES) $(COMMON_CMAKE_PARAMS) -DZLIB_ROOT=..\..\..\external\vcpkg\installed\x64-windows-static -A x64 ..\..\..\external\libzip
42+
cmake --build . --config Release -v
43+
displayName: "x64 Build"
44+
- script: |
45+
external\vcpkg\vcpkg.exe integrate install
46+
external\vcpkg\vcpkg.exe install zlib:x86-windows-static
47+
mkdir .\build\Windows\32
48+
cd .\build\Windows\32
49+
cmake $(LIBZIP_FEATURES) $(COMMON_CMAKE_PARAMS) -DZLIB_ROOT=..\..\..\external\vcpkg\installed\x86-windows-static -A Win32 ..\..\..\external\libzip
50+
cmake --build . --config Release -v
51+
displayName: "x86 Build"
52+
- task: ArchiveFiles@2
53+
inputs:
54+
rootFolderOrFile: build\Windows\32\lib\Release\zip.dll
55+
includeRootFolder: false
56+
archiveType: 7z
57+
replaceExistingArchive: true
58+
archiveFile: $(Build.ArtifactStagingDirectory)\libzip-windows-x86.7z
59+
- task: ArchiveFiles@2
60+
inputs:
61+
rootFolderOrFile: build\Windows\64\lib\Release\zip.dll
62+
includeRootFolder: false
63+
archiveType: 7z
64+
replaceExistingArchive: true
65+
archiveFile: $(Build.ArtifactStagingDirectory)\libzip-windows-x64.7z
66+
- task: PublishBuildArtifacts@1
67+
displayName: upload artifacts
68+
inputs:
69+
artifactName: 'native'
70+
pathtoPublish: $(Build.ArtifactStagingDirectory)
1771
- job: buildLinux
1872
pool:
1973
vmImage: ubuntu-16.04
@@ -55,7 +109,9 @@ stages:
55109
artifactName: 'native'
56110
pathtoPublish: $(Build.ArtifactStagingDirectory)
57111
- job: buildMacOS
58-
dependsOn: buildLinux
112+
dependsOn:
113+
- buildlinux
114+
- buildWindows
59115
pool:
60116
vmImage: macOS-10.14
61117
steps:
@@ -71,9 +127,10 @@ stages:
71127
displayName: 'Apply Patch'
72128
- bash: |
73129
HOSTOS=Darwin ./build_native
74-
./build_windows
75130
mkdir -p build/Linux/64
76131
mkdir -p build/Linux/32
132+
mkdir -p build/Windows/64
133+
mkdir -p build/Windows/32
77134
find build/* | grep libzip
78135
displayName: 'Build native and Windows'
79136
- task: DownloadBuildArtifacts@0
@@ -91,10 +148,23 @@ stages:
91148
inputs:
92149
archiveFilePatterns: $(Build.ArtifactStagingDirectory)/native/libzip-linux-x86.7z
93150
destinationFolder: build/Linux/32
151+
- task: ExtractFiles@1
152+
displayName: Extract 64 bit Windows native
153+
inputs:
154+
archiveFilePatterns: $(Build.ArtifactStagingDirectory)/native/libzip-windows-x64.7z
155+
destinationFolder: build/Windows/64
156+
- task: ExtractFiles@1
157+
displayName: Extract 32 bit Windows native
158+
inputs:
159+
archiveFilePatterns: $(Build.ArtifactStagingDirectory)/native/libzip-windows-x86.7z
160+
destinationFolder: build/Windows/32
94161
- bash: |
95162
mv build/Linux/32/libzip.so.5.3 build/Linux/32/libzip.so
96163
mv build/Linux/64/libzip.so.5.3 build/Linux/64/libzip.so
164+
mv build/Windows/32/zip.dll build/Windows/32/libzip.dll
165+
mv build/Windows/64/zip.dll build/Windows/64/libzip.dll
97166
rm $(Build.ArtifactStagingDirectory)/native/libzip-linux-*.7z
167+
rm $(Build.ArtifactStagingDirectory)/native/libzip-windows-*.7z
98168
displayName: 'Find libzip'
99169
- task: MSBuild@1
100170
displayName: 'Build solution libZipSharp.csproj'

libZipSharp.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<DocumentationFile>libZipSharp.xml</DocumentationFile>
1414
</PropertyGroup>
1515
<PropertyGroup>
16-
<!--
16+
<!--
1717
nuget packaging
1818
-->
1919
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
@@ -44,8 +44,8 @@
4444
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
4545
</None>
4646
<None Include="build\Darwin\64\lib\libzip.5.3.dylib" PackagePath="runtimes\osx\native\libzip.dylib" Pack="true" />
47-
<None Include="build\Windows\64\lib\libzip.dll" PackagePath="runtimes\win-x64\native\libzip.dll" Pack="true" />
48-
<None Include="build\Windows\32\lib\libzip.dll" PackagePath="runtimes\win-x86\native\libzip.dll" Pack="true" />
47+
<None Include="build\Windows\64\libzip.dll" PackagePath="runtimes\win-x64\native\libzip.dll" Pack="true" />
48+
<None Include="build\Windows\32\libzip.dll" PackagePath="runtimes\win-x86\native\libzip.dll" Pack="true" />
4949
<None Include="build\Linux\64\libzip.so" PackagePath="runtimes\linux-x64\native\libzip.so" Pack="true" />
5050
<None Include="build\Linux\32\libzip.so" PackagePath="runtimes\linux-x86\native\libzip.so" Pack="true" />
5151
<None Include="LICENSE" PackagePath="Licences" Pack="true" />

libzip-changes.patch

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
diff --git a/lib/zip_stat_index.c b/lib/zip_stat_index.c
2-
index 0f8bead8..62dc0455 100644
2+
index 77993257..a1cba96a 100644
33
--- a/lib/zip_stat_index.c
44
+++ b/lib/zip_stat_index.c
55
@@ -55,7 +55,7 @@ zip_stat_index(zip_t *za, zip_uint64_t index, zip_flags_t flags, zip_stat_t *st)
6-
return -1;
7-
}
8-
9-
- if (entry->changes->changed & ZIP_DIRENT_LAST_MOD) {
10-
+ if (entry->changes != NULL && entry->changes->changed & ZIP_DIRENT_LAST_MOD) {
11-
st->mtime = de->last_mod;
12-
st->valid |= ZIP_STAT_MTIME;
13-
}
6+
return -1;
7+
}
8+
9+
- if (entry->changes->changed & ZIP_DIRENT_LAST_MOD) {
10+
+ if (entry->changes != NULL && entry->changes->changed & ZIP_DIRENT_LAST_MOD) {
11+
st->mtime = de->last_mod;
12+
st->valid |= ZIP_STAT_MTIME;
13+
}

0 commit comments

Comments
 (0)