Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
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
46 changes: 46 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@

## THE EXTRA PACKAGES ADDED DURING BUILD ARE NECESSARY FOR THE NATIVE LIB LIBRARY TO SUCCEED
## THIS IS THE FIX TO ALLOW THIS LIB TO WORK
## WHILST https://github.com/mellinoe/nativelibraryloader/issues/2 is open
## AND WHILE https://github.com/dotnet/corefx/issues/32015 is open
#ENV LD_DEBUG=all can be used to see the full error (if the package management isnt used)


### BUILD IN ALPINE - TESTED PASSED
FROM microsoft/dotnet:2.2-sdk-alpine3.8 AS alpine
#zstd-libs in apk is 1.3.4
RUN apk add --no-cache libc6-compat
ENV ALPINE=TRUE
WORKDIR /src
COPY ./ ./
RUN ls /src/Zstandard.Net.Tests/bin/

RUN dotnet test


### BUILD IN STRETCH - TESTED PASSED
### Note: MSFT default image "sdk" is stretch https://github.com/dotnet/dotnet-docker
FROM microsoft/dotnet:2.2-sdk-stretch AS stretch

# Installing the lib is pointless as its 1.2 and fails the dictionary tests
RUN apt-get update \
&& apt-get install -y --no-install-recommends libc6-dev

WORKDIR /src
COPY ./ ./

RUN dotnet test


### BUILD IN bionic - TESTED PASSED
FROM microsoft/dotnet:2.2-sdk-bionic AS bionic

# libzstd1 is 1.3.3 which passes the tests
RUN apt-get update \
&& apt-get install -y --no-install-recommends libc6-dev

WORKDIR /src
COPY ./ ./

RUN dotnet test

47 changes: 47 additions & 0 deletions Dockerfile.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Using Docker instances

This is showing the SDK, you'd want to use the runtime for most things.

```
FROM microsoft/dotnet:2.2-sdk-alpine3.8 AS alpine

# This is required for libld to load the package
# The copying moves the libzstd to the standard library location
RUN apk add --no-cache libc6-compat && \
cp linuxalpine/libzstd.so /usr/lib/

WORKDIR /src
COPY ./ ./

# Entry point etc
```

```
### Note: MSFT default image "sdk" is stretch https://github.com/dotnet/dotnet-docker
FROM microsoft/dotnet:2.2-sdk-stretch AS stretch

# Installing the lib is pointless as its 1.2 and fails the dictionary tests
RUN apt-get update \
&& apt-get install -y --no-install-recommends libc6-dev \
&& cp linuxdebian/libzstd.so /usr/lib/

WORKDIR /src
COPY ./ ./

# Entry point etc
```

```
### bionic
FROM microsoft/dotnet:2.2-sdk-bionic AS bionic

# libzstd1 is 1.3.3 which passes the tests
RUN apt-get update \
&& apt-get install -y --no-install-recommends libc6-dev \
&& cp linuxdebian/libzstd.so /usr/lib/

WORKDIR /src
COPY ./ ./

# Entry point etc
```
30 changes: 30 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,33 @@ Download the library from NuGet:

https://www.nuget.org/packages/Zstandard.Net/



## Building ZStd binaries

It's usually best to create the binaries within a container or vm of the same type of OS, mapping the zstd (facebook repo) to the instance (or checking out within the image, but you'll need to map a local folder to copy the files out).

### For alpine

```dockerfile
FROM alpine:3.8

RUN apk --no-cache add make gcc libc-dev
COPY . /src
RUN mkdir /pkg && cd /src && make && make DESTDIR=/pkg install

```

* `docker build -t tmpzstd .`
* `docker run --rm -it -v I:\Zstandard.Net\zstd:/wrk tmpzstd `



### For Debian & Windows

The makefile can be ran from WSL (ubuntu) and will generate a debian compatible library.

For Windows you'll need VS installed; once installed you simply run the command that matches your version in `zstd\build\VS_scripts` the dll is deposited in the bin/release/x64 folder.



2 changes: 1 addition & 1 deletion Zstandard.Net.Benchmark/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace Zstandard.Net.Benchmark
{
class Program
static class Program
{
static void Main(string[] args)
{
Expand Down
12 changes: 4 additions & 8 deletions Zstandard.Net.Benchmark/Zstandard.Net.Benchmark.csproj
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.0</TargetFramework>
<TargetFramework>netcoreapp2.2</TargetFramework>
<Configurations>Debug;Release;Sandbox</Configurations>
<IsTestProject>false</IsTestProject>
</PropertyGroup>

<ItemGroup>
<Reference Include="netstandard">
<HintPath>..\..\..\..\Program Files\dotnet\sdk\NuGetFallbackFolder\netstandard.library\2.0.1\build\netstandard2.0\ref\netstandard.dll</HintPath>
</Reference>
</ItemGroup>

<ItemGroup>
<None Update="cantrbry.zip">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
Expand Down
6 changes: 3 additions & 3 deletions Zstandard.Net.Sandbox/App.config
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.1"/>
</startup>
</configuration>
</configuration>
2 changes: 1 addition & 1 deletion Zstandard.Net.Sandbox/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace Zstandard.Net.Sandbox
{
class Program
static class Program
{
static void Main(string[] args)
{
Expand Down
13 changes: 12 additions & 1 deletion Zstandard.Net.Sandbox/Zstandard.Net.Sandbox.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@
<OutputType>Exe</OutputType>
<RootNamespace>Zstandard.Net.Sandbox</RootNamespace>
<AssemblyName>Zstandard.Net.Sandbox</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.7.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<IsTestProject>false</IsTestProject>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
Expand All @@ -32,6 +33,16 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Sandbox|AnyCPU'">
<OutputPath>bin\Sandbox\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>AnyCPU</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
Expand Down
8 changes: 8 additions & 0 deletions Zstandard.Net.Tests/GlobalSuppressions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

// This file is used by Code Analysis to maintain SuppressMessage
// attributes that are applied to this project.
// Project-level suppressions either have no target or are given
// a specific target and scoped to a namespace, type, member, etc.

[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "SecurityIntelliSenseCS:MS Security rules violation", Justification = "<Pending>", Scope = "member", Target = "~M:Zstandard.Net.Tests.StandardTests.GetRandomData(System.Int32)~System.Byte[]")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "SecurityIntelliSenseCS:MS Security rules violation", Justification = "<Pending>", Scope = "member", Target = "~M:Zstandard.Net.Tests.DictionaryTests.GetRandomData(System.Int32)~System.Byte[]")]
1 change: 1 addition & 0 deletions Zstandard.Net.Tests/PropertyTests.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.IO;

namespace Zstandard.Net.Tests
{
Expand Down
1 change: 1 addition & 0 deletions Zstandard.Net.Tests/StandardTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Runtime.InteropServices;

namespace Zstandard.Net.Tests
{
Expand Down
27 changes: 25 additions & 2 deletions Zstandard.Net.Tests/Zstandard.Net.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netcoreapp2.0;net45</TargetFrameworks>
<TargetFrameworks>netcoreapp2.2</TargetFrameworks>
<Configurations>Debug;Release;Sandbox</Configurations>
<IsTestProject>true</IsTestProject>
</PropertyGroup>

<ItemGroup>
Expand All @@ -20,6 +22,27 @@
<ProjectReference Include="..\Zstandard.Net\Zstandard.Net.csproj" />
</ItemGroup>

<PropertyGroup>
<IsWindows Condition="'$(OS)' == 'Windows_NT'">true</IsWindows>
</PropertyGroup>

<PropertyGroup Condition="'$(MSBuildRuntimeType)' == 'Core'">
<IsOSX Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::OSX)))' == 'true'">true</IsOSX>
<IsLinux Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Linux)))' == 'true'">true</IsLinux>
</PropertyGroup>


<ItemGroup Condition=" ('$(Platform)' == 'x64' OR '$(Platform)' == 'AnyCPU') AND '$(IsWindows)' == true">
<NativeLib Include="../Zstandard.Net/build/win-x64/libzstd.dll" />
</ItemGroup>
<ItemGroup Condition=" ('$(Platform)' == 'x64' OR '$(Platform)' == 'AnyCPU') AND '$(IsLinux)' == true">
<NativeLib Include="../Zstandard.Net/build/linuxdebian/libzstd.so" />
</ItemGroup>

<Target Name="CopyNativeLib" AfterTargets="Build">
<Copy SourceFiles="@(NativeLib)" DestinationFolder="$(OutputPath)" />
</Target>

<ItemGroup>
<None Update="Data\loremipsum.zdict">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
Expand Down
13 changes: 10 additions & 3 deletions Zstandard.Net.sln
Original file line number Diff line number Diff line change
Expand Up @@ -9,30 +9,37 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Zstandard.Net.Tests", "Zsta
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Zstandard.Net.Sandbox", "Zstandard.Net.Sandbox\Zstandard.Net.Sandbox.csproj", "{2F3734C8-67F5-42C4-BEE3-BCA10285E310}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Zstandard.Net.Benchmark", "Zstandard.Net.Benchmark\Zstandard.Net.Benchmark.csproj", "{7273C9EE-8EBD-466B-8AC7-FFC830D15E19}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Zstandard.Net.Benchmark", "Zstandard.Net.Benchmark\Zstandard.Net.Benchmark.csproj", "{7273C9EE-8EBD-466B-8AC7-FFC830D15E19}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
Sandbox|Any CPU = Sandbox|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{054BA829-FE7C-476C-A335-FB8CCB552F05}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{054BA829-FE7C-476C-A335-FB8CCB552F05}.Debug|Any CPU.Build.0 = Debug|Any CPU
{054BA829-FE7C-476C-A335-FB8CCB552F05}.Release|Any CPU.ActiveCfg = Release|Any CPU
{054BA829-FE7C-476C-A335-FB8CCB552F05}.Release|Any CPU.Build.0 = Release|Any CPU
{054BA829-FE7C-476C-A335-FB8CCB552F05}.Sandbox|Any CPU.ActiveCfg = Sandbox|Any CPU
{054BA829-FE7C-476C-A335-FB8CCB552F05}.Sandbox|Any CPU.Build.0 = Sandbox|Any CPU
{5623F4A5-9E4D-4BB7-BB46-9B50CC291321}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5623F4A5-9E4D-4BB7-BB46-9B50CC291321}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5623F4A5-9E4D-4BB7-BB46-9B50CC291321}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5623F4A5-9E4D-4BB7-BB46-9B50CC291321}.Release|Any CPU.Build.0 = Release|Any CPU
{5623F4A5-9E4D-4BB7-BB46-9B50CC291321}.Sandbox|Any CPU.ActiveCfg = Sandbox|Any CPU
{5623F4A5-9E4D-4BB7-BB46-9B50CC291321}.Sandbox|Any CPU.Build.0 = Sandbox|Any CPU
{2F3734C8-67F5-42C4-BEE3-BCA10285E310}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2F3734C8-67F5-42C4-BEE3-BCA10285E310}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2F3734C8-67F5-42C4-BEE3-BCA10285E310}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2F3734C8-67F5-42C4-BEE3-BCA10285E310}.Release|Any CPU.Build.0 = Release|Any CPU
{2F3734C8-67F5-42C4-BEE3-BCA10285E310}.Sandbox|Any CPU.ActiveCfg = Sandbox|Any CPU
{2F3734C8-67F5-42C4-BEE3-BCA10285E310}.Sandbox|Any CPU.Build.0 = Sandbox|Any CPU
{7273C9EE-8EBD-466B-8AC7-FFC830D15E19}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7273C9EE-8EBD-466B-8AC7-FFC830D15E19}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7273C9EE-8EBD-466B-8AC7-FFC830D15E19}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7273C9EE-8EBD-466B-8AC7-FFC830D15E19}.Release|Any CPU.Build.0 = Release|Any CPU
{7273C9EE-8EBD-466B-8AC7-FFC830D15E19}.Sandbox|Any CPU.ActiveCfg = Sandbox|Any CPU
{7273C9EE-8EBD-466B-8AC7-FFC830D15E19}.Sandbox|Any CPU.Build.0 = Sandbox|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
58 changes: 36 additions & 22 deletions Zstandard.Net/Zstandard.Net.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard2.0;net45</TargetFrameworks>
<TargetFramework>netstandard2.0</TargetFramework>
<RootNamespace>Zstandard.Net</RootNamespace>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Authors>bp74</Authors>
Expand All @@ -11,28 +11,42 @@
<PackageLicenseUrl>https://github.com/bp74/Zstandard.Net/blob/master/LICENSE</PackageLicenseUrl>
<RepositoryUrl>https://github.com/bp74/Zstandard.Net</RepositoryUrl>
<PackageTags>Compression Stream Zstandard Zstd</PackageTags>
<PackageReleaseNotes>fixed unmanaged resource leak
</PackageReleaseNotes>
<Version>1.1.7</Version>
<PackageReleaseNotes>Added alpine and nix build of libzstd, added NativeLibraryLoader to resolve on nix/docker</PackageReleaseNotes>
<Version>1.2.6</Version>
<Configurations>Debug;Release;Sandbox</Configurations>
<IsTestProject>false</IsTestProject>
<PackageReleaseNotes>fixed unmanaged resource leak</PackageReleaseNotes>
</PropertyGroup>

<ItemGroup>
<None Include="build\x64\libzstd.dll">
<Link>x64\%(FileName)%(Extension)</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="build\x86\libzstd.dll">
<Link>x86\%(FileName)%(Extension)</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>

<ItemGroup>
<None Include="build\**\*" Pack="true" PackagePath="build\" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="System.Buffers" Version="4.5.0" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="System.Buffers" Version="4.5.0" />
</ItemGroup>

<ItemGroup>
<None Include="build\win-x64\libzstd.dll">
<Link>win-x64\%(FileName)%(Extension)</Link>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<Visible>true</Visible>
</None>
<None Include="build\win-x86\libzstd.dll">
<Link>win-x86\%(FileName)%(Extension)</Link>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<Visible>true</Visible>
</None>
<None Include="build\linuxdebian\libzstd.so">
<Link>linuxdebian\%(FileName)%(Extension)</Link>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<Visible>true</Visible>
</None>
<None Include="build\linuxalpine\libzstd.so">
<Link>linuxalpine\%(FileName)%(Extension)</Link>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<Visible>true</Visible>
</None>
</ItemGroup>

<ItemGroup>
<None Include="build\**\*" Pack="true" PackagePath="build\" />
</ItemGroup>

</Project>
Loading