Created
December 8, 2023 18:03
-
-
Save gitcrtn/fe8a00c124ef773f2d10927e7e2f891b to your computer and use it in GitHub Desktop.
A cross compiler of rust-sdl2 project for aarch64
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
source $HOME/.cargo/env | |
cd /build | |
mkdir -p .cargo | |
cat <<EOF > .cargo/config | |
[target.aarch64-unknown-linux-gnu] | |
linker = "aarch64-linux-gnu-gcc" | |
EOF | |
cargo build --target=aarch64-unknown-linux-gnu |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM debian:bookworm | |
ENV USER root | |
RUN rm /bin/sh \ | |
&& ln -s /bin/bash /bin/sh | |
RUN mkdir /build \ | |
&& cd \ | |
&& apt update \ | |
&& apt install -y curl build-essential \ | |
&& curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y \ | |
&& source $HOME/.cargo/env \ | |
&& rustup target add aarch64-unknown-linux-gnu \ | |
&& dpkg --add-architecture arm64 \ | |
&& apt update \ | |
&& apt install -y gcc-aarch64-linux-gnu libsdl2-dev:arm64 libsdl2-image-dev:arm64 libsdl2-ttf-dev:arm64 | |
COPY build.sh / | |
ENTRYPOINT ["/build.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 1. Build docker image. | |
docker build -t rust-sdl2-aarch64 . | |
# 2. Build rust project with sdl2. | |
cd /path/to/project | |
docker run --rm -v $PWD:/build rust-sdl2-aarch64 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment