Skip to content
This repository was archived by the owner on Jan 18, 2026. It is now read-only.

Commit aa2380c

Browse files
authored
Scheduled upgrade + native zlib (#23)
* upgrade dependencies * start splitting * split * native artifact naming * typo * artifacts etc. * typo * envs * cmake requirement? * build * create fat native * and publish * deps * path for fats * more unit tests * wrong artifact name * i gave up on zlib-ng * adding native zlib compression support * fix exports * wrong size reporting * bug in managed compression test * comment
1 parent 9fef92b commit aa2380c

File tree

16 files changed

+358
-177
lines changed

16 files changed

+358
-177
lines changed

.github/workflows/full.yml

Lines changed: 84 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
name: 'Full Flow'
22

33
env:
4-
VERSION: 1.5.2
5-
# PACKAGE_SUFFIX: '-pre.1'
6-
PACKAGE_SUFFIX: ''
4+
VERSION: 1.6.0
5+
PACKAGE_SUFFIX: '-pre.1'
6+
# PACKAGE_SUFFIX: ''
77
ASM_VERSION: 1.0.0
88
BUILD_TYPE: Release
9+
VCPKG_HASH: 0f88ecb8528605f91980b90a2c5bad88e3cb565f
910
# Indicates the location of the vcpkg as a Git submodule of the project repository.
1011
#VCPKG_ROOT: ${{ github.workspace }}/vcpkg
1112
# Tells vcpkg where binary packages are stored.
@@ -28,95 +29,76 @@ jobs:
2829
runs-on: ${{ matrix.os }}
2930
strategy:
3031
matrix:
31-
os: [ubuntu-20.04, windows-latest, macos-latest]
32-
arch: [x64, arm64]
33-
#include:
34-
# - os: windows-latest
35-
# arch: x86
36-
exclude:
37-
# no build agent for Windows ARM
38-
- os: windows-latest
32+
include:
33+
- os: ubuntu-20.04
34+
arch: x64
35+
vcpkg_triplet: x64-linux
36+
vcpkg_config: RelWithDebInfo
37+
dotnet_rid: linux-x64
38+
- os: ubuntu-20.04
3939
arch: arm64
40-
# no more x64 agent available on GitHub Actions
41-
- os: macos-latest
40+
vcpkg_triplet: arm64-linux
41+
vcpkg_config: RelWithDebInfo
42+
dotnet_rid: linux-arm64
43+
- os: windows-latest
4244
arch: x64
45+
vcpkg_triplet: x64-windows-static
46+
vcpkg_config: Release
47+
dotnet_rid: win-x64
48+
- os: macos-latest
49+
arch: arm64
50+
vcpkg_triplet: arm64-osx
51+
vcpkg_config: RelWithDebInfo
52+
dotnet_rid: osx-arm64
53+
4354
fail-fast: false
4455
name: 'build: ${{ matrix.os }} (${{ matrix.arch }})'
4556

4657
steps:
4758

48-
- uses: actions/checkout@v3
59+
- uses: actions/checkout@v4
4960
with:
5061
submodules: true
5162

52-
- name: Windows Env
53-
if: matrix.os == 'windows-latest'
54-
run: |
55-
echo "VCPKG_DEFAULT_VCPKG_TRIPLET=${{ matrix.arch }}-windows-static" >> $env:GITHUB_ENV
56-
echo "VCPKG_TRIPLET=${{ matrix.arch }}-windows-static" >> $env:GITHUB_ENV
57-
echo "VCPKG_CONFIG=Release" >> $env:GITHUB_ENV
58-
59-
- name: Linux Env
60-
if: matrix.os == 'ubuntu-20.04'
61-
run: |
62-
echo "VCPKG_DEFAULT_VCPKG_TRIPLET=${{ matrix.arch }}-linux" >> $GITHUB_ENV
63-
echo "VCPKG_TRIPLET=${{ matrix.arch }}-linux" >> $GITHUB_ENV
64-
echo "VCPKG_CONFIG=RelWithDebInfo" >> $GITHUB_ENV
65-
66-
- name: MacOS Env
67-
if: matrix.os == 'macos-latest'
68-
run: |
69-
echo "VCPKG_DEFAULT_VCPKG_TRIPLET=${{ matrix.arch }}-osx" >> $GITHUB_ENV
70-
echo "VCPKG_TRIPLET=${{ matrix.arch }}-osx" >> $GITHUB_ENV
71-
echo "VCPKG_CONFIG=RelWithDebInfo" >> $GITHUB_ENV
72-
73-
- name: Windows x64
74-
if: runner.os == 'Windows' && matrix.arch == 'x64'
75-
run: |
76-
echo "DOTNET_RID=win-x64" >> $env:GITHUB_ENV
77-
78-
- name: Windows x32
79-
if: runner.os == 'Windows' && matrix.arch == 'x86'
63+
- name: env (windows)
64+
if: runner.os == 'Windows'
8065
run: |
81-
echo "VCPKG_DEFAULT_VCPKG_TRIPLET=${{ matrix.arch }}-windows" >> $env:GITHUB_ENV
82-
echo "VCPKG_TRIPLET=${{ matrix.arch }}-windows" >> $env:GITHUB_ENV
83-
echo "DOTNET_RID=win-x86" >> $env:GITHUB_ENV
84-
echo "CMAKE_OPTIONS=-A Win32" >> $env:GITHUB_ENV
66+
echo "VCPKG_DEFAULT_VCPKG_TRIPLET=${{ matrix.vcpkg_triplet }}" >> $env:GITHUB_ENV
67+
echo "VCPKG_TRIPLET=${{ matrix.vcpkg_triplet }}" >> $env:GITHUB_ENV
68+
echo "VCPKG_CONFIG=${{ matrix.vcpkg_config }}" >> $env:GITHUB_ENV
69+
echo "DOTNET_RID=${{ matrix.dotnet_rid }}" >> $env:GITHUB_ENV
8570
86-
- name: Linux x64
87-
if: runner.os == 'Linux' && matrix.arch == 'x64'
71+
- name: env
72+
if: runner.os == 'Linux' || runner.os == 'macOS'
8873
run: |
89-
echo "DOTNET_RID=linux-x64" >> $GITHUB_ENV
74+
echo "VCPKG_DEFAULT_VCPKG_TRIPLET=${{ matrix.vcpkg_triplet }}" >> $GITHUB_ENV
75+
echo "VCPKG_TRIPLET=${{ matrix.vcpkg_triplet }}" >> $GITHUB_ENV
76+
echo "VCPKG_CONFIG=${{ matrix.vcpkg_config }}" >> $GITHUB_ENV
77+
echo "DOTNET_RID=${{ matrix.dotnet_rid }}" >> $GITHUB_ENV
9078
9179
- name: Linux ARM
9280
if: runner.os == 'Linux' && matrix.arch == 'arm64'
9381
run: |
9482
sudo apt-get update
9583
sudo apt-get --yes install g++-aarch64-linux-gnu pkg-config-aarch64-linux-gnu
9684
echo "CMAKE_OPTIONS=-D CMAKE_SYSTEM_PROCESSOR=aarch64 -D CMAKE_C_COMPILER=$(which aarch64-linux-gnu-gcc) -D CMAKE_CXX_COMPILER=$(which aarch64-linux-gnu-g++)" >> $GITHUB_ENV
97-
echo "DOTNET_RID=linux-arm64" >> $GITHUB_ENV
98-
99-
- name: OSX x64
100-
if: runner.os == 'macOS' && matrix.arch == 'x64'
101-
run: |
102-
echo "DOTNET_RID=osx-x64" >> $GITHUB_ENV
85+
echo "SUPPRESS_TEST=1" >> $GITHUB_ENV
10386
10487
- name: OSX M1
10588
if: runner.os == 'macOS' && matrix.arch == 'arm64'
10689
run: |
10790
echo "CMAKE_OPTIONS=-D CMAKE_OSX_ARCHITECTURES=arm64" >> $GITHUB_ENV
108-
echo "DOTNET_RID=osx-arm64" >> $GITHUB_ENV
10991
11092
- uses: friendlyanon/setup-vcpkg@v1
11193
# seems like the absense of commit hash expects vcpkg submodule, i don't want that
11294
with:
113-
committish: 261dd6831673d3b07e5118261f7e161a21d1a759
95+
committish: ${{ env.VCPKG_HASH }}
11496
# set to false to clear any cache in case of build errors
11597
cache: false
11698

117-
- name: show cmake config
118-
run: cmake -h
119-
working-directory: native
99+
# - name: show cmake config
100+
# run: cmake -h
101+
# working-directory: native
120102

121103
- name: configure
122104
run: cmake -B build -S . -D CMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -D "CMAKE_TOOLCHAIN_FILE=${{ env.VCPKG_ROOT }}/scripts/buildsystems/vcpkg.cmake" -D "VCPKG_TARGET_TRIPLET=${{ env.VCPKG_TRIPLET }}" ${{ env.CMAKE_OPTIONS }}
@@ -130,7 +112,31 @@ jobs:
130112
run: ls -R
131113
working-directory: native
132114

133-
- uses: actions/upload-artifact@v3
115+
- uses: actions/upload-artifact@v4
116+
name: Collect Artifacts
117+
with:
118+
name: native-${{ matrix.dotnet_rid }}
119+
path: |
120+
native/ubin/**/*
121+
if-no-files-found: error
122+
123+
# create a unified fat native binary
124+
make-fat-native:
125+
runs-on: ubuntu-latest
126+
needs: build-native
127+
steps:
128+
129+
- uses: actions/download-artifact@v4
130+
with:
131+
pattern: native-*
132+
path: native/ubin/
133+
merge-multiple: true
134+
135+
- name: debug
136+
run: ls -R
137+
working-directory: .
138+
139+
- uses: actions/upload-artifact@v4
134140
name: Collect Artifacts
135141
with:
136142
name: native
@@ -139,10 +145,18 @@ jobs:
139145
140146
test-managed:
141147
runs-on: ${{ matrix.os }}
142-
needs: build-native
148+
needs: make-fat-native
143149
strategy:
144150
matrix:
145-
os: [ubuntu-20.04, ubuntu-22.04, windows-2022, macos-latest]
151+
include:
152+
- os: ubuntu-20.04
153+
dotnet_rid: linux-x64
154+
- os: ubuntu-22.04
155+
dotnet_rid: linux-x64
156+
- os: windows-2022
157+
dotnet_rid: win-x64
158+
- os: macos-latest
159+
dotnet_rid: osx-arm64
146160
fail-fast: false
147161
name: 'test: ${{ matrix.os }}'
148162

@@ -152,11 +166,11 @@ jobs:
152166

153167
steps:
154168

155-
- uses: actions/checkout@v3
169+
- uses: actions/checkout@v4
156170
with:
157171
submodules: true
158172

159-
- uses: actions/download-artifact@v3
173+
- uses: actions/download-artifact@v4
160174
with:
161175
name: native
162176
path: native/ubin/
@@ -183,15 +197,15 @@ jobs:
183197
run: dotnet test managed/IronCompress.sln -c release /p:Version=${{ env.VERSION }}${{ env.PACKAGE_SUFFIX }} /p:FileVersion=$VERSION /p:AssemblyVersion=$ASM_VERSION
184198

185199
build-managed:
186-
needs: build-native
200+
needs: make-fat-native
187201
runs-on: ubuntu-latest
188202
steps:
189203

190-
- uses: actions/checkout@v3
204+
- uses: actions/checkout@v4
191205
with:
192206
submodules: true
193207

194-
- uses: actions/download-artifact@v2
208+
- uses: actions/download-artifact@v4
195209
with:
196210
name: native
197211
path: native/ubin/
@@ -210,7 +224,7 @@ jobs:
210224
- name: Build
211225
run: dotnet build managed/IronCompress.sln -c release /p:Version=${{ env.VERSION }}${{ env.PACKAGE_SUFFIX }} /p:FileVersion=$VERSION /p:AssemblyVersion=$ASM_VERSION
212226

213-
- uses: actions/upload-artifact@v2
227+
- uses: actions/upload-artifact@v4
214228
name: Collect Artifacts
215229
with:
216230
name: managed
@@ -224,7 +238,7 @@ jobs:
224238
environment: nuget
225239
steps:
226240

227-
- uses: actions/download-artifact@v2
241+
- uses: actions/download-artifact@v4
228242
with:
229243
name: managed
230244
path: pub/managed/

docs/README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ And following architectures:
2323
| **Zstd** || |||| x32 |
2424
| | | |||| x64 |
2525
| | | |||| ARM64 |
26-
| **Gzip** | ✅<br /><sup>*part of .NET*</sup> | | | | | |
26+
| **Gzip** | ✅<br /><sup>*part of .NET*</sup> | |||| x32 |
27+
| | | |||| x64 |
28+
| | | |||| ARM64 |
2729
| **Brotli** | ✅<br /><sup>*except on .NET Standard 2.0*</sup> | |||| x32 |
2830
| | | |||| x64 |
2931
| | | |||| ARM64 |
@@ -73,7 +75,7 @@ using (IronCompressResult uncompressed = iron.Decompress(Codec.Snappy, compresse
7375

7476
As with compression, this returns `Result` with decompressed data. It's worth nothing one important difference - decompression needs the length of output buffer specified as third parameter (`input.Length`). Although some decompressors can guess uncompressed length more or less correct, the others won't know it beforehand. In reality this problem is solved by using a framing format that adds metadata about resulting length, however many compression formats do not define that and consider compressed packets to be implementation specific.
7577

76-
You will need more or less recent C++ compiler, `CMake` and `.NET SDK 6` to build the code.
78+
You will need more or less recent C++ compiler, `CMake` and `.NET SDK 8` to build the code.
7779

7880

7981
## Building

managed/IronCompress.Benchmarks/IronCompress.Benchmarks.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
</PropertyGroup>
99

1010
<ItemGroup>
11-
<PackageReference Include="BenchmarkDotNet" Version="0.13.12" />
11+
<PackageReference Include="BenchmarkDotNet" Version="0.14.0" />
1212
</ItemGroup>
1313

1414
<ItemGroup>

managed/IronCompress.Test/IronCompress.Test.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
</PropertyGroup>
88

99
<ItemGroup>
10-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
11-
<PackageReference Include="xunit" Version="2.8.0" />
12-
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.0">
10+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
11+
<PackageReference Include="xunit" Version="2.9.1" />
12+
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2">
1313
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
1414
<PrivateAssets>all</PrivateAssets>
1515
</PackageReference>

managed/IronCompress.Test/IronTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public void EncodeDecodeManaged(Codec codec) {
5555
_rnd.NextBytes(input);
5656

5757
using(IronCompressResult compressed = iron.Compress(codec, input.AsSpan())) {
58-
using(IronCompressResult uncompressed = _iron.Decompress(codec, compressed, input.Length)) {
58+
using(IronCompressResult uncompressed = iron.Decompress(codec, compressed, input.Length)) {
5959
Assert.Equal(input, uncompressed.AsSpan().ToArray());
6060
}
6161
}

managed/IronCompress/Iron.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public static bool IsNativeLibraryAvailable {
2121
// cache the results, as it won't change during the lifetime of the app
2222
if(_isNativeLibraryAvailable == null) {
2323
try {
24-
Native.ping();
24+
Native.iron_ping();
2525
_isNativeLibraryAvailable = true;
2626

2727
} catch(DllNotFoundException) {
@@ -44,7 +44,8 @@ static bool SupportsManaged(Codec c) {
4444
}
4545

4646
static bool SupportsNative(Codec c) {
47-
return IsNativeLibraryAvailable && c != Codec.Gzip;
47+
//return IsNativeLibraryAvailable && c != Codec.Gzip;
48+
return true;
4849
}
4950

5051
/// <summary>
@@ -131,7 +132,7 @@ private IronCompressResult NativeCompressOrDecompress(
131132
fixed(byte* inputPtr = input) {
132133
// get output buffer size into "len"
133134
if(outputLength == null) {
134-
bool ok = Native.compress(
135+
bool ok = Native.iron_compress(
135136
compressOrDecompress,
136137
(int)codec, inputPtr, input.Length, null, &len, level);
137138
if(!ok) {
@@ -147,7 +148,7 @@ private IronCompressResult NativeCompressOrDecompress(
147148

148149
fixed(byte* outputPtr = output) {
149150
try {
150-
bool ok = Native.compress(
151+
bool ok = Native.iron_compress(
151152
compressOrDecompress,
152153
(int)codec, inputPtr, input.Length, outputPtr, &len, level);
153154

managed/IronCompress/Native.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ private static IntPtr DllImportResolver(string libraryName, Assembly assembly, D
3838
#endif
3939

4040
[DllImport(LibName)]
41-
internal static extern unsafe bool compress(bool compress,
41+
internal static extern unsafe bool iron_compress(bool compress,
4242
int codec,
4343
byte* inputBuffer,
4444
int inputBufferSize,
@@ -47,9 +47,6 @@ internal static extern unsafe bool compress(bool compress,
4747
int compressionLevel);
4848

4949
[DllImport(LibName)]
50-
internal static extern bool ping();
51-
52-
[DllImport(LibName)]
53-
internal static extern bool is_supported(int codec);
50+
internal static extern bool iron_ping();
5451
}
5552
}

0 commit comments

Comments
 (0)