-
Notifications
You must be signed in to change notification settings - Fork 575
Add Alpine Native Libraries #1339
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Changes from all commits
f9e2f19
3f0a37d
86e74d0
4e80575
b523530
dc161e2
f2d1187
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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}", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Seems some version of ninja don't like this order. |
||
WorkingDirectory = SKIA_PATH.FullPath, | ||
}); | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,6 +45,7 @@ Please visit https://go.microsoft.com/fwlink/?linkid=868517 to view the release | |
|
||
<!-- libSkiaSharp.dll and other native files --> | ||
<file platform="linux" src="runtimes/linux-x64/native/libSkiaSharp.so" /> | ||
<file platform="linux" src="runtimes/linux-musl-x64/native/libSkiaSharp.so" /> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add the asset to the NuGet package |
||
|
||
<!-- placeholders --> | ||
<file src="_._" target="lib/net45/_._" /> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
Comment on lines
+1
to
+8
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the Docker file to run on. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
Comment on lines
+252
to
+259
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add an entry to the CI build |
||
- 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 | ||
Comment on lines
+335
to
+336
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Include it in the managed build/packaging. |
||
- 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 | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add the asset to the project.