diff --git a/binding/HarfBuzzSharp/HarfBuzzSharp.csproj b/binding/HarfBuzzSharp/HarfBuzzSharp.csproj
index bdde8f4bf9..bec8c224bb 100644
--- a/binding/HarfBuzzSharp/HarfBuzzSharp.csproj
+++ b/binding/HarfBuzzSharp/HarfBuzzSharp.csproj
@@ -31,6 +31,8 @@
Condition=" Exists('..\..\output\native\nanoserver\x64\libHarfBuzzSharp.dll') or '$(IsWindows)' == 'true' " />
+
diff --git a/binding/SkiaSharp/SkiaSharp.csproj b/binding/SkiaSharp/SkiaSharp.csproj
index bc9aa1fc8a..34b32ba4ac 100644
--- a/binding/SkiaSharp/SkiaSharp.csproj
+++ b/binding/SkiaSharp/SkiaSharp.csproj
@@ -30,6 +30,10 @@
Condition=" Exists('..\..\output\native\nanoserver\x64\libSkiaSharp.dll') or '$(IsWindows)' == 'true' " />
+
+
diff --git a/cake/native-shared.cake b/cake/native-shared.cake
index f94d32267c..d233304004 100644
--- a/cake/native-shared.cake
+++ b/cake/native-shared.cake
@@ -61,7 +61,7 @@ void GnNinja(DirectoryPath outDir, string target, string skiaArgs)
// build native skia
RunProcess(NINJA_EXE, new ProcessSettings {
- Arguments = $"{target} -C out/{outDir}",
+ Arguments = $"-C out/{outDir} {target}",
WorkingDirectory = SKIA_PATH.FullPath,
});
}
diff --git a/native/linuxnodeps/build.cake b/native/linuxnodeps/build.cake
index 13fba5b964..d52257ff7c 100644
--- a/native/linuxnodeps/build.cake
+++ b/native/linuxnodeps/build.cake
@@ -1,14 +1,17 @@
DirectoryPath ROOT_PATH = MakeAbsolute(Directory("../.."));
-DirectoryPath OUTPUT_PATH = MakeAbsolute(ROOT_PATH.Combine("output/native/linuxnodeps"));
+DirectoryPath OUTPUT_PATH = MakeAbsolute(ROOT_PATH.Combine("output/native"));
#load "../../cake/shared.cake"
+var BUILD_VARIANT = Argument("variant", EnvironmentVariable("BUILD_VARIANT") ?? "linuxnodeps");
+OUTPUT_PATH = OUTPUT_PATH.Combine(BUILD_VARIANT);
+
Task("libSkiaSharp")
.WithCriteria(IsRunningOnLinux())
.Does(() =>
{
RunCake("../linux/build.cake", "libSkiaSharp", new Dictionary {
- { "variant", "linuxnodeps" },
+ { "variant", BUILD_VARIANT },
{ "gnArgs", "skia_use_fontconfig=false" },
});
@@ -23,7 +26,7 @@ Task("libHarfBuzzSharp")
.Does(() =>
{
RunCake("../linux/build.cake", "libHarfBuzzSharp", new Dictionary {
- { "variant", "linuxnodeps" },
+ { "variant", BUILD_VARIANT },
});
RunProcess("ldd", OUTPUT_PATH.CombineWithFilePath($"x64/libHarfBuzzSharp.so").FullPath, out var stdout);
diff --git a/nuget/HarfbuzzSharp.NativeAssets.Linux.nuspec b/nuget/HarfbuzzSharp.NativeAssets.Linux.nuspec
index 95142579e4..24dd421a85 100644
--- a/nuget/HarfbuzzSharp.NativeAssets.Linux.nuspec
+++ b/nuget/HarfbuzzSharp.NativeAssets.Linux.nuspec
@@ -44,6 +44,7 @@ Please visit https://go.microsoft.com/fwlink/?linkid=868517 to view the release
+
diff --git a/nuget/SkiaSharp.NativeAssets.Linux.NoDependencies.nuspec b/nuget/SkiaSharp.NativeAssets.Linux.NoDependencies.nuspec
index c675d2a633..943c3829c8 100644
--- a/nuget/SkiaSharp.NativeAssets.Linux.NoDependencies.nuspec
+++ b/nuget/SkiaSharp.NativeAssets.Linux.NoDependencies.nuspec
@@ -57,6 +57,7 @@ Please visit https://go.microsoft.com/fwlink/?linkid=868517 to view the release
+
diff --git a/nuget/SkiaSharp.NativeAssets.Linux.nuspec b/nuget/SkiaSharp.NativeAssets.Linux.nuspec
index 22e7dabc68..a6440af497 100644
--- a/nuget/SkiaSharp.NativeAssets.Linux.nuspec
+++ b/nuget/SkiaSharp.NativeAssets.Linux.nuspec
@@ -45,6 +45,7 @@ Please visit https://go.microsoft.com/fwlink/?linkid=868517 to view the release
+
diff --git a/scripts/Docker/alpine/amd64/Dockerfile b/scripts/Docker/alpine/amd64/Dockerfile
new file mode 100644
index 0000000000..b17d01b623
--- /dev/null
+++ b/scripts/Docker/alpine/amd64/Dockerfile
@@ -0,0 +1,8 @@
+FROM amd64/alpine:3.9
+
+RUN apk add --no-cache bash curl ca-certificates python git build-base ninja fontconfig-dev
+RUN apk add --no-cache samurai --repository http://dl-cdn.alpinelinux.org/alpine/edge/main
+RUN apk add --no-cache mono clang gn --repository http://dl-cdn.alpinelinux.org/alpine/edge/testing
+RUN cert-sync /etc/ssl/certs/ca-certificates.crt
+
+WORKDIR /work
diff --git a/scripts/azure-pipelines.yml b/scripts/azure-pipelines.yml
index 0b8a45b309..bf87928a98 100644
--- a/scripts/azure-pipelines.yml
+++ b/scripts/azure-pipelines.yml
@@ -249,6 +249,22 @@ stages:
docker: scripts/Docker/ubuntu16/amd64
target: externals-linuxnodeps
additionalArgs: --buildarch=x64
+ - template: azure-templates-bootstrapper.yml # Build Native Linux [Alpine] (Linux)
+ parameters:
+ name: native_linux_alpine_linux
+ displayName: Build Native Linux [Alpine] (Linux)
+ vmImage: $(VM_IMAGE_LINUX)
+ docker: scripts/Docker/alpine/amd64
+ target: externals-linux
+ additionalArgs: --buildarch=x64 --gn=gn --ninja=ninja --variant=alpine
+ - template: azure-templates-bootstrapper.yml # Build Native Linux [Alpine, No Dependencies] (Linux)
+ parameters:
+ name: native_linux_alpinenodependencies_linux
+ displayName: Build Native Linux [Alpine, No Dependencies] (Linux)
+ vmImage: $(VM_IMAGE_LINUX)
+ docker: scripts/Docker/alpine/amd64
+ target: externals-linuxnodeps
+ additionalArgs: --buildarch=x64 --gn=gn --ninja=ninja --variant=alpinenodeps
- template: azure-templates-bootstrapper.yml # Build Native Tizen (Linux)
parameters:
name: native_tizen_linux
@@ -316,6 +332,8 @@ stages:
requiredArtifacts:
- native_linux_linux
- native_linux_nodependencies_linux
+ - native_linux_alpinenodependencies_linux
+ - native_linux_alpine_linux
- native_tizen_linux
- stage: package
@@ -454,6 +472,8 @@ stages:
requiredArtifacts:
- native_linux_linux
- native_linux_nodependencies_linux
+ - native_linux_alpinenodependencies_linux
+ - native_linux_alpine_linux
postBuildSteps:
- task: PublishTestResults@2
displayName: Publish the Mono test results
@@ -469,6 +489,7 @@ stages:
testResultsFormat: xUnit
testResultsFiles: 'tests/SkiaSharp*.NetCore.Tests/**/TestResults.xml'
testRunTitle: 'Linux .NET Core Tests'
+ # TODO: add tests for linux alpine
# TODO: add tests for linux no dependencies
# TODO: add tests for windows nano server
diff --git a/scripts/azure-templates-bootstrapper.yml b/scripts/azure-templates-bootstrapper.yml
index 8c2f98d63a..ab9907c5d5 100644
--- a/scripts/azure-templates-bootstrapper.yml
+++ b/scripts/azure-templates-bootstrapper.yml
@@ -44,7 +44,7 @@ jobs:
- template: azure-templates-variables.yml
# install any packages on linux
- - ${{ if endsWith(parameters.name, '_linux') }}:
+ - ${{ if and(eq(parameters.docker, ''), endsWith(parameters.name, '_linux')) }}:
- bash: |
sudo apt update
sudo apt install -y ${{ parameters.packages }}
@@ -52,7 +52,7 @@ jobs:
condition: ne('${{ parameters.packages }}', '')
# make sure mono/msbuild is the correct version
- - ${{ if endsWith(parameters.name, '_linux') }}:
+ - ${{ if and(eq(parameters.docker, ''), endsWith(parameters.name, '_linux')) }}:
- bash: |
sudo apt remove -y mono-complete msbuild
sudo apt autoremove -y
diff --git a/utils/NativeLibraryMiniTest/Program.cs b/utils/NativeLibraryMiniTest/Program.cs
new file mode 100644
index 0000000000..6243a9412b
--- /dev/null
+++ b/utils/NativeLibraryMiniTest/Program.cs
@@ -0,0 +1,111 @@
+using System;
+using System.Runtime.InteropServices;
+
+using sk_bitmap_t = System.IntPtr;
+using sk_colorspace_t = System.IntPtr;
+using sk_pixmap_t = System.IntPtr;
+using sk_wstream_t = System.IntPtr;
+using sk_wstream_filestream_t = System.IntPtr;
+
+namespace NativeLibraryMiniTest {
+ unsafe class Program {
+ const string SKIA = "libSkiaSharp.so";
+
+ static int Main(string[] args) {
+ Console.WriteLine("Starting test...");
+
+ Console.WriteLine("Color type test...");
+ Console.WriteLine($"sk_colortype_get_default_8888() = {sk_colortype_get_default_8888()}");
+
+ Console.WriteLine("Bitmap create and save test...");
+ var bmp = sk_bitmap_new();
+ var info = new sk_imageinfo_t {
+ width = 100,
+ height = 100,
+ colorType = sk_colortype_get_default_8888(),
+ alphaType = sk_alphatype_t.Premul,
+ };
+ sk_bitmap_try_alloc_pixels_with_flags(bmp, &info, 0);
+ sk_bitmap_erase(bmp, 0xFFFF0000);
+ var pix = sk_pixmap_new();
+ sk_bitmap_peek_pixels(bmp, pix);
+ var stream = sk_filewstream_new("output.png");
+ var opt = new sk_pngencoder_options_t {
+ fFilterFlags = 248,
+ fZLibLevel = 6,
+ };
+ sk_pngencoder_encode(stream, pix, &opt);
+ sk_filewstream_destroy(stream);
+ sk_pixmap_destructor(pix);
+ sk_bitmap_destructor(bmp);
+
+ Console.WriteLine("Test complete.");
+ return 0;
+ }
+
+ [DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
+ static extern sk_colortype_t sk_colortype_get_default_8888();
+
+ [DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
+ static extern sk_bitmap_t sk_bitmap_new();
+
+ [DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
+ [return: MarshalAs(UnmanagedType.I1)]
+ static extern bool sk_bitmap_try_alloc_pixels_with_flags(sk_bitmap_t cbitmap, sk_imageinfo_t* requestedInfo, uint flags);
+
+ [DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
+ static extern void sk_bitmap_erase(sk_bitmap_t cbitmap, uint color);
+
+ [DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
+ [return: MarshalAs(UnmanagedType.I1)]
+ static extern bool sk_bitmap_peek_pixels(sk_bitmap_t cbitmap, sk_pixmap_t cpixmap);
+
+ [DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
+ [return: MarshalAs(UnmanagedType.I1)]
+ static extern bool sk_pngencoder_encode(sk_wstream_t dst, sk_pixmap_t src, void* options);
+
+ [DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
+ static extern void sk_bitmap_destructor(sk_bitmap_t cbitmap);
+
+ [DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
+ static extern sk_pixmap_t sk_pixmap_new();
+
+ [DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
+ static extern void sk_pixmap_destructor(sk_pixmap_t cpixmap);
+
+ [DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
+ static extern sk_wstream_filestream_t sk_filewstream_new([MarshalAs(UnmanagedType.LPStr)] string path);
+
+ [DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
+ static extern void sk_filewstream_destroy(sk_wstream_filestream_t cstream);
+
+ [StructLayout(LayoutKind.Sequential)]
+ unsafe partial struct sk_imageinfo_t {
+ public sk_colorspace_t colorspace;
+ public int width;
+ public int height;
+ public sk_colortype_t colorType;
+ public sk_alphatype_t alphaType;
+ }
+
+ enum sk_colortype_t {
+ Unknown = 0,
+ Rgba8888 = 4,
+ Bgra8888 = 6,
+ }
+
+ enum sk_alphatype_t {
+ Unknown = 0,
+ Opaque = 1,
+ Premul = 2,
+ Unpremul = 3,
+ }
+
+ [StructLayout (LayoutKind.Sequential)]
+ struct sk_pngencoder_options_t {
+ public int fFilterFlags;
+ public int fZLibLevel;
+ public void* fComments;
+ }
+ }
+}
diff --git a/utils/NativeLibraryMiniTest/build.sh b/utils/NativeLibraryMiniTest/build.sh
new file mode 100644
index 0000000000..353db3e2d8
--- /dev/null
+++ b/utils/NativeLibraryMiniTest/build.sh
@@ -0,0 +1,7 @@
+#!/usr/bin/env bash
+
+mkdir -p utils/NativeLibraryMiniTest/bin
+csc /out:utils/NativeLibraryMiniTest/bin/Program.exe /unsafe utils/NativeLibraryMiniTest/Program.cs
+cp output/native/linux/x64/libSkiaSharp.so utils/NativeLibraryMiniTest/bin/
+
+(cd utils/NativeLibraryMiniTest/bin && mono Program.exe)