Skip to content

Add Android Bionic Library build support #3217

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 15 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
<PackageFile Include="..\..\output\native\alpine\arm\libHarfBuzzSharp*.so" PackagePath="runtimes\linux-musl-arm\native\%(Filename)%(Extension)" />
<PackageFile Include="..\..\output\native\alpine\riscv64\libHarfBuzzSharp*.so" PackagePath="runtimes\linux-musl-riscv64\native\%(Filename)%(Extension)" />
<PackageFile Include="..\..\output\native\alpine\loongarch64\libHarfBuzzSharp*.so" PackagePath="runtimes\linux-musl-loongarch64\native\%(Filename)%(Extension)" />
<!-- Bionic -->
<PackageFile Include="..\..\output\native\bionic\x64\libHarfBuzzSharp*.so" PackagePath="runtimes\linux-bionic-x64\native\%(Filename)%(Extension)" />
<PackageFile Include="..\..\output\native\bionic\arm64\libHarfBuzzSharp*.so" PackagePath="runtimes\linux-bionic-arm64\native\%(Filename)%(Extension)" />
</ItemGroup>
<Target Name="IncludeAdditionalTfmSpecificPackageFiles">
<ItemGroup Condition="$(TargetFramework.StartsWith('net4'))">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,14 @@
<Dir>musl-loongarch64\</Dir>
</_NativeHarfBuzzSharpFile>

<!-- Bionic -->
<_NativeHarfBuzzSharpFile Include="$(MSBuildThisFileDirectory)..\..\runtimes\linux-bionic-x64\native\libHarfBuzzSharp*.so">
<Dir>bionic-x64\</Dir>
</_NativeHarfBuzzSharpFile>
<_NativeHarfBuzzSharpFile Include="$(MSBuildThisFileDirectory)..\..\runtimes\linux-bionic-arm64\native\libHarfBuzzSharp*.so">
<Dir>bionic-arm64\</Dir>
</_NativeHarfBuzzSharpFile>

<!-- include everything -->
<Content Include="@(_NativeHarfBuzzSharpFile)">
<Link>%(Dir)%(Filename)%(Extension)</Link>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ The excluded dependencies are:
<PackageFile Include="..\..\output\native\alpinenodeps\arm\libSkiaSharp*.so" PackagePath="runtimes\linux-musl-arm\native\%(Filename)%(Extension)" />
<PackageFile Include="..\..\output\native\alpinenodeps\riscv64\libSkiaSharp*.so" PackagePath="runtimes\linux-musl-riscv64\native\%(Filename)%(Extension)" />
<PackageFile Include="..\..\output\native\alpinenodeps\loongarch64\libSkiaSharp*.so" PackagePath="runtimes\linux-musl-loongarch64\native\%(Filename)%(Extension)" />
<!-- Bionic -->
<PackageFile Include="..\..\output\native\bionicnodeps\x64\libSkiaSharp*.so" PackagePath="runtimes\linux-bionic-x64\native\%(Filename)%(Extension)" />
<PackageFile Include="..\..\output\native\bionicnodeps\arm64\libSkiaSharp*.so" PackagePath="runtimes\linux-bionic-arm64\native\%(Filename)%(Extension)" />
</ItemGroup>
<Target Name="IncludeAdditionalTfmSpecificPackageFiles">
<ItemGroup Condition="$(TargetFramework.StartsWith('net4'))">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,14 @@
<Dir>musl-loongarch64\</Dir>
</_NativeSkiaSharpFile>

<!-- Bionic -->
<_NativeSkiaSharpFile Include="$(MSBuildThisFileDirectory)..\..\runtimes\linux-bionic-x64\native\libSkiaSharp*.so">
<Dir>bionic-x64\</Dir>
</_NativeSkiaSharpFile>
<_NativeSkiaSharpFile Include="$(MSBuildThisFileDirectory)..\..\runtimes\linux-bionic-arm64\native\libSkiaSharp*.so">
<Dir>bionic-arm64\</Dir>
</_NativeSkiaSharpFile>

<!-- include everything -->
<Content Include="@(_NativeSkiaSharpFile)">
<Link>%(Dir)%(Filename)%(Extension)</Link>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
<PackageFile Include="..\..\output\native\alpine\arm\libSkiaSharp*.so" PackagePath="runtimes\linux-musl-arm\native\%(Filename)%(Extension)" />
<PackageFile Include="..\..\output\native\alpine\riscv64\libSkiaSharp*.so" PackagePath="runtimes\linux-musl-riscv64\native\%(Filename)%(Extension)" />
<PackageFile Include="..\..\output\native\alpine\loongarch64\libSkiaSharp*.so" PackagePath="runtimes\linux-musl-loongarch64\native\%(Filename)%(Extension)" />
<!-- Bionic -->
<PackageFile Include="..\..\output\native\bionic\x64\libSkiaSharp*.so" PackagePath="runtimes\linux-bionic-x64\native\%(Filename)%(Extension)" />
<PackageFile Include="..\..\output\native\bionic\arm64\libSkiaSharp*.so" PackagePath="runtimes\linux-bionic-arm64\native\%(Filename)%(Extension)" />
</ItemGroup>
<Target Name="IncludeAdditionalTfmSpecificPackageFiles">
<ItemGroup Condition="$(TargetFramework.StartsWith('net4'))">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,14 @@
<Dir>musl-loongarch64\</Dir>
</_NativeSkiaSharpFile>

<!-- Bionic -->
<_NativeSkiaSharpFile Include="$(MSBuildThisFileDirectory)..\..\runtimes\linux-bionic-x64\native\libSkiaSharp*.so">
<Dir>bionic-x64\</Dir>
</_NativeSkiaSharpFile>
<_NativeSkiaSharpFile Include="$(MSBuildThisFileDirectory)..\..\runtimes\linux-bionic-arm64\native\libSkiaSharp*.so">
<Dir>bionic-arm64\</Dir>
</_NativeSkiaSharpFile>

<!-- include everything -->
<Content Include="@(_NativeSkiaSharpFile)">
<Link>%(Dir)%(Filename)%(Extension)</Link>
Expand Down
1 change: 1 addition & 0 deletions scripts/Docker/bionic/amd64/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
build-local.sh
49 changes: 49 additions & 0 deletions scripts/Docker/bionic/amd64/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Arguments:
# DOTNET_SDK_VERSION - the version of dotnet for the Cake script [ 8.0 | * ]
FROM amd64/debian:bookworm

# Install the required packages
RUN apt-get update && apt-get install -y \
build-essential \
git \
wget \
unzip \
cmake \
ninja-build \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

# Configure Android NDK r26b
RUN wget https://dl.google.com/android/repository/android-ndk-r26b-linux.zip && \
unzip android-ndk-r26b-linux.zip -d /opt && \
rm android-ndk-r26b-linux.zip
ENV ANDROID_NDK_HOME /opt/android-ndk-r26b
ENV PATH $PATH:$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin

# Copy source
COPY . .

# Install the .NET SDK
ARG DOTNET_SDK_VERSION=8.0
ENV DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=1
RUN wget https://builds.dotnet.microsoft.com/dotnet/scripts/v1/dotnet-install.sh -O dotnet-install.sh \
&& bash dotnet-install.sh --channel ${DOTNET_SDK_VERSION} --install-dir /usr/share/dotnet --verbose \
&& ln -s /usr/share/dotnet/dotnet /usr/bin/dotnet \
&& rm dotnet-install.sh \
&& dotnet help \
&& dotnet --info

WORKDIR /work

# Cmake
RUN cmake -DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK_HOME/build/cmake/android.toolchain.cmake \
-DANDROID_ABI=x86_64 \ # target architecture
-DANDROID_NATIVE_API_LEVEL=29 \ # Android 10.0 (API 29)
-DANDROID_TOOLCHAIN=clang \ # use clang
-DCMAKE_BUILD_TYPE=Release \
-B build \
.
RUN cmake --build build --parallel

# Clean build cache
RUN rm -rf build
10 changes: 10 additions & 0 deletions scripts/Docker/bionic/amd64/build-local.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env bash
set -e

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"

(cd $DIR && docker build --tag skiasharp-bionic-x64 .)
(cd $DIR/../../../../ && \
docker run --rm --name skiasharp-bionic-x64 --volume $(pwd):/work skiasharp-bionic-x64 /bin/bash -c "\
dotnet tool restore ; \
dotnet cake --target=externals-linux --configuration=Release --buildarch=x64 --variant=bionic")
1 change: 1 addition & 0 deletions scripts/Docker/bionic/arm64v8/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
build-local.sh
55 changes: 55 additions & 0 deletions scripts/Docker/bionic/arm64v8/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Arguments:
# DOTNET_SDK_VERSION - the version of dotnet for the Cake script [ 8.0 | * ]
FROM debian:bookworm

# Install the required packages
RUN apt-get update && apt-get install -y \
build-essential \
git \
wget \
unzip \
cmake \
ninja-build \
qemu-user-static \
binfmt-support \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

# Configure Android NDK r26b
RUN wget https://dl.google.com/android/repository/android-ndk-r26b-linux.zip && \
unzip android-ndk-r26b-linux.zip -d /opt && \
rm android-ndk-r26b-linux.zip
ENV ANDROID_NDK_HOME /opt/android-ndk-r26b
ENV PATH $PATH:$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin

# AArch64 qemu emulation
COPY qemu-aarch64-static /usr/bin/qemu-aarch64-static
RUN chmod +x /usr/bin/qemu-aarch64-static

# Copy source
COPY . .

# Install the .NET SDK
ARG DOTNET_SDK_VERSION=8.0
ENV DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=1
RUN wget https://builds.dotnet.microsoft.com/dotnet/scripts/v1/dotnet-install.sh -O dotnet-install.sh \
&& bash dotnet-install.sh --channel ${DOTNET_SDK_VERSION} --install-dir /usr/share/dotnet --verbose \
&& ln -s /usr/share/dotnet/dotnet /usr/bin/dotnet \
&& rm dotnet-install.sh \
&& dotnet help \
&& dotnet --info

WORKDIR /work

# Cmake
RUN cmake -DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK_HOME/build/cmake/android.toolchain.cmake \
-DANDROID_ABI=arm64-v8a \ # target architecture
-DANDROID_NATIVE_API_LEVEL=29 \ # Android 10.0 (API 29)
-DANDROID_TOOLCHAIN=clang \ # use clang
-DCMAKE_BUILD_TYPE=Release \
-B build \
.
RUN cmake --build build --parallel

# Clean build cache
RUN rm -rf build
10 changes: 10 additions & 0 deletions scripts/Docker/bionic/arm64v8/build-local.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env bash
set -e

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"

(cd $DIR && docker build --tag skiasharp-bionic-arm64 .)
(cd $DIR/../../../../ && \
docker run --rm --name skiasharp-bionic-arm64 --volume $(pwd):/work skiasharp-bionic-arm64 /bin/bash -c "\
dotnet tool restore ; \
dotnet cake --target=externals-linux --configuration=Release --buildarch=arm64 --variant=bionic")
1 change: 0 additions & 1 deletion scripts/azure-templates-stages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ stages:
- template: /scripts/azure-templates-stages-prepare.yml@self
parameters:
buildAgentHost: ${{ parameters.buildAgentHost }}

- ${{ if in(parameters.buildPipelineType, 'native', 'complete') }}:
- template: /scripts/azure-templates-stages-native.yml@self
parameters:
Expand Down