-
Notifications
You must be signed in to change notification settings - Fork 564
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
Increase Linux support #3209
Increase Linux support #3209
Changes from all commits
b785521
159d70d
80fe135
b02c7c1
1766d87
b4c8998
28028d6
4a9db61
9fcff57
92bbc61
f257080
ceb6671
8bad5a7
c7c3fce
4676f38
8e3d803
84d227c
08fe863
259da8f
01a51b3
3daed6f
f99e99d
50e0859
d096023
69fb348
51e5198
27889dd
432e4ff
7ebfa6e
7cb8e7a
6c30f10
b408b07
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 |
---|---|---|
@@ -1,42 +1,43 @@ | ||
#!/usr/bin/env bash | ||
set -ex | ||
|
||
# Parameters: | ||
# $1 - The directory containing the Dockerfile [ clang-cross/10 | clang-cross ] | ||
# $2 - The target architecture to build for [ arm | arm64 | riscv64 | x86 | x64 ] | ||
# $3 - The ABI [ gnu | musl ] | ||
# $4 - The variant [ "" | alpine ] | ||
|
||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" | ||
|
||
# the directory containing the Dockerfile | ||
DOCKER_DIR="$1" | ||
|
||
# the target architecture to build for | ||
ARCH="${2:-arm}" | ||
ARCH="$2" | ||
|
||
# the docker image architecture to use | ||
MACHINE_ARCH="$(uname -m)" | ||
[ "$MACHINE_ARCH" = "arm64" ] && MACHINE_ARCH=aarch64 | ||
IMAGE_ARCH="${3:-$([[ "$MACHINE_ARCH" == "aarch64" ]] && echo "arm64v8" || echo "amd64")}" | ||
|
||
DISTRO_VERSION=$4 | ||
ABI=$5 | ||
VENDOR=$6 | ||
|
||
case $ARCH in | ||
arm) TOOLCHAIN_ARCH=arm$VENDOR-linux-${ABI}eabihf ; TOOLCHAIN_ARCH_SHORT=armhf ; TARGET_MACHINE_ARCH=armhf ;; | ||
arm64) TOOLCHAIN_ARCH=aarch64$VENDOR-linux-$ABI ; TOOLCHAIN_ARCH_SHORT=arm64 ; TARGET_MACHINE_ARCH=aarch64 ;; | ||
riscv64) TOOLCHAIN_ARCH=riscv64$VENDOR-linux-$ABI ; TOOLCHAIN_ARCH_SHORT=riscv64 ; TARGET_MACHINE_ARCH=riscv64 ;; | ||
x86) TOOLCHAIN_ARCH=i686$VENDOR-linux-$ABI ; TOOLCHAIN_ARCH_SHORT=i386 ; TARGET_MACHINE_ARCH=x86 ;; | ||
x64) TOOLCHAIN_ARCH=x86-64$VENDOR-linux-$ABI ; TOOLCHAIN_ARCH_SHORT=amd64 ; TARGET_MACHINE_ARCH=x86_64 ;; | ||
*) echo "Unsupported architecture: $ARCH" && exit 1 ;; | ||
case $MACHINE_ARCH in | ||
arm64) IMAGE_ARCH=arm64v8 ; MACHINE_ARCH=aarch64 ;; | ||
*) IMAGE_ARCH=amd64 ;; | ||
esac | ||
|
||
(cd $DIR && docker build --tag skiasharp-linux-$ABI-cross-$ARCH \ | ||
--build-arg TOOLCHAIN_ARCH=$TOOLCHAIN_ARCH \ | ||
--build-arg TOOLCHAIN_ARCH_SHORT=$TOOLCHAIN_ARCH_SHORT \ | ||
--build-arg IMAGE_ARCH=$IMAGE_ARCH \ | ||
--build-arg MACHINE_ARCH=$MACHINE_ARCH \ | ||
--build-arg TARGET_MACHINE_ARCH=$TARGET_MACHINE_ARCH \ | ||
--build-arg DISTRO_VERSION=$DISTRO_VERSION \ | ||
# the ABI | ||
ABI=$3 | ||
|
||
# the variant | ||
VARIANT=$4 | ||
|
||
(cd $DIR && | ||
docker build --tag skiasharp-linux-$ABI-cross-$ARCH \ | ||
--build-arg BUILD_ARCH=$ARCH \ | ||
--build-arg IMAGE_ARCH=$IMAGE_ARCH \ | ||
--build-arg MACHINE_ARCH=$MACHINE_ARCH \ | ||
$DOCKER_DIR) | ||
|
||
if [ "$VENDOR" = "-alpine" ]; then vendor=alpine; fi | ||
[ -n "$VARIANT" ] && VARIANT="--variant=$VARIANT" | ||
|
||
(cd $DIR/../.. && | ||
docker run --rm --name skiasharp-linux-$ABI-cross-$ARCH --volume $(pwd):/work skiasharp-linux-$ABI-cross-$ARCH /bin/bash -c "\ | ||
dotnet tool restore && | ||
dotnet cake --target=externals-linux-clang-cross --configuration=Release --buildarch=$ARCH --variant=$vendor") | ||
docker run --rm --name skiasharp-linux-$ABI-cross-$ARCH --volume $(pwd):/work skiasharp-linux-$ABI-cross-$ARCH /bin/bash -c " \ | ||
dotnet tool restore ; \ | ||
dotnet cake --target=externals-linux-clang-cross --configuration=Release --buildarch=$ARCH $VARIANT ") |
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. if we cross compile all archs, then we don't need these arch specific ones. 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. I am having issues with cross-compiling all archs. Debian x64 to x64 and Alpine x86. Once I get those to build then I can drop. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,76 @@ | ||
# Arguments: | ||
# IMAGE_ARCH - the architecture of the image [ amd64 | arm64v8 | riscv64 ] | ||
# DOTNET_SDK_VERSION - the version of dotnet for the Cake script [ 8.0 | * ] | ||
# LLVM_VERSION - the version of the LLVM compiler [ 13 | * ] | ||
# TOOLCHAIN_VERSION - the version of the GCC toolchain [ 9 | * ] | ||
# TOOLCHAIN_ARCH - the architecture of the GCC toolchain [ arm-alpine-linux-musleabihf | aarch64-alpine-linux-musl | riscv64-alpine-linux-musl ] | ||
# TOOLCHAIN_ARCH_SHORT - the short form architecture of the GCC toolchain [ armhf | arm64 ] | ||
# FONTCONFIG_VERSION - the exact version of libfontconfig1 to use [ 2.13.1-2 | * ] | ||
|
||
ARG IMAGE_ARCH=amd64 | ||
FROM ${IMAGE_ARCH}/debian:12 | ||
|
||
# Set the architecture-specific variables based on the value of the BUILD_ARCH argument | ||
ARG BUILD_ARCH=arm64 | ||
RUN case ${BUILD_ARCH} in \ | ||
arm) TOOLCHAIN_ARCH=armv7-alpine-linux-musleabihf ; TOOLCHAIN_ARCH_TARGET=armv7-alpine-linux-musleabihf ;; \ | ||
arm64) TOOLCHAIN_ARCH=aarch64-alpine-linux-musl ; TOOLCHAIN_ARCH_TARGET=aarch64-alpine-linux-musl ;; \ | ||
riscv64) TOOLCHAIN_ARCH=riscv64-alpine-linux-musl ; TOOLCHAIN_ARCH_TARGET=riscv64-alpine-linux-musl ;; \ | ||
x86) TOOLCHAIN_ARCH=i586-alpine-linux-musl ; TOOLCHAIN_ARCH_TARGET=i586-alpine-linux-musl ;; \ | ||
x64) TOOLCHAIN_ARCH=x86_64-alpine-linux-musl ; TOOLCHAIN_ARCH_TARGET=x86_64-alpine-linux-musl ;; \ | ||
*) echo "Unsupported architecture: ${BUILD_ARCH}" && exit 1 ;; \ | ||
esac \ | ||
&& echo "export TOOLCHAIN_ARCH=${TOOLCHAIN_ARCH}" > /etc/skia-env \ | ||
&& echo "export TOOLCHAIN_ARCH_TARGET=${TOOLCHAIN_ARCH_TARGET}" >> /etc/skia-env | ||
|
||
# Install the required packages | ||
ARG LLVM_VERSION=19 | ||
RUN apt-get update \ | ||
&& apt-get install -y \ | ||
curl python3 git clang-19 lld-19 ninja-build xz-utils curl \ | ||
curl python3 git clang-${LLVM_VERSION} lld-${LLVM_VERSION} ninja-build xz-utils \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
# Install the cross-compilation musl toolchain | ||
ARG DISTRO_VERSION=3.17 | ||
ARG TOOLCHAIN_ARCH_SHORT=armhf | ||
# First, obtain apk.static from https://gitlab.alpinelinux.org/alpine/apk-tools/-/releases/v2.12.14 | ||
ARG MACHINE_ARCH=x86_64 | ||
ARG TARGET_MACHINE_ARCH=armhf | ||
|
||
# obtain apk.static from gitlab.alpinelinux.org/alpine/apk-tools/-/releases/v2.12.14 | ||
RUN APK_DIR="$(mktemp -d)" && \ | ||
curl -SLO --create-dirs --output-dir "$APK_DIR" "https://gitlab.alpinelinux.org/api/v4/projects/5/packages/generic/v2.12.14/$MACHINE_ARCH/apk.static" && \ | ||
chmod +x "$APK_DIR/apk.static" && \ | ||
"$APK_DIR/apk.static" \ | ||
RUN . /etc/skia-env \ | ||
&& case "${BUILD_ARCH}" in \ | ||
arm) APK_ARCH=armv7 ;; \ | ||
arm64) APK_ARCH=aarch64 ;; \ | ||
riscv64) APK_ARCH=riscv64 ;; \ | ||
x86) APK_ARCH=x86 ;; \ | ||
x64) APK_ARCH=x86_64 ;; \ | ||
*) echo "Unsupported architecture: ${BUILD_ARCH}" && exit 1 ;; \ | ||
esac \ | ||
&& case "${BUILD_ARCH}" in \ | ||
riscv64) DISTRO_VERSION=3.20 ;; \ | ||
*) DISTRO_VERSION=3.17 ;; \ | ||
esac \ | ||
&& APK_DIR="$(mktemp -d)" \ | ||
&& curl -SLO --create-dirs --output-dir "$APK_DIR" "https://gitlab.alpinelinux.org/api/v4/projects/5/packages/generic/v2.12.14/$MACHINE_ARCH/apk.static" \ | ||
&& chmod +x "$APK_DIR/apk.static" \ | ||
&& "$APK_DIR/apk.static" \ | ||
-X "http://dl-cdn.alpinelinux.org/alpine/v$DISTRO_VERSION/main" \ | ||
-X "http://dl-cdn.alpinelinux.org/alpine/v$DISTRO_VERSION/community" \ | ||
-U --allow-untrusted --root /alpine --arch "$TARGET_MACHINE_ARCH" --initdb add && \ | ||
"$APK_DIR/apk.static" \ | ||
-U --allow-untrusted --root /alpine --arch "$APK_ARCH" --initdb add \ | ||
&& "$APK_DIR/apk.static" \ | ||
-X "http://dl-cdn.alpinelinux.org/alpine/v$DISTRO_VERSION/main" \ | ||
-X "http://dl-cdn.alpinelinux.org/alpine/v$DISTRO_VERSION/community" \ | ||
-U --allow-untrusted --root /alpine --arch "$TARGET_MACHINE_ARCH" --no-scripts \ | ||
-U --allow-untrusted --root /alpine --arch "$APK_ARCH" --no-scripts \ | ||
add fontconfig-dev build-base linux-headers | ||
|
||
# Install the .NET SDK | ||
ARG DOTNET_SDK_VERSION=8.0 | ||
ENV DOTNET_SYSTEM_GLOBALIZATION_INVARIANT 1 | ||
ENV DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=1 | ||
RUN curl https://dot.net/v1/dotnet-install.sh -L -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 | ||
|
||
ENV CC=clang-19 CXX=clang++-19 | ||
ENV CC=clang-${LLVM_VERSION} CXX=clang++-${LLVM_VERSION} | ||
|
||
WORKDIR /work | ||
|
||
COPY ./startup.sh / | ||
RUN chmod +x /startup.sh | ||
ENTRYPOINT [ "/startup.sh" ] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,11 @@ | ||
#!/usr/bin/env bash | ||
set -ex | ||
|
||
# Parameters: | ||
# $1 - The target architecture to build for [ arm | arm64 | riscv64 | x86 | x64 ] | ||
|
||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" | ||
|
||
ARCH=$1 | ||
ALPINE_VERSION=$3 | ||
if [ -z "$ALPINE_VERSION" ]; then | ||
case $ARCH in | ||
riscv64) ALPINE_VERSION=3.20 ;; | ||
*) ALPINE_VERSION=3.17 ;; | ||
esac | ||
fi | ||
ARCH="${1:-arm}" | ||
|
||
$DIR/../../_clang-cross-common.sh "$DIR" "$ARCH" "$2" "$ALPINE_VERSION" "musl" "-alpine" | ||
$DIR/../../_clang-cross-common.sh "$DIR" "$ARCH" "musl" "alpine" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/usr/bin/env bash | ||
set -e | ||
|
||
source /etc/skia-env | ||
|
||
exec "$@" |
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.
I now define these in the Docker container instead of having it calculated in other places each time we use it.
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.
running
file output/path/libSkiaSharp.so
will validate if we are producing the correct arch/bitness compared to main branch