Created
December 8, 2023 18:06
-
-
Save gitcrtn/1dd001ba0b4a3c2572cd06f384288d33 to your computer and use it in GitHub Desktop.
A cross compiler of bevy 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 pkg-config \ | |
&& 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 g++-aarch64-linux-gnu libx11-dev:arm64 libasound2-dev:arm64 libudev-dev:arm64 libwayland-dev:arm64 libxkbcommon-dev:arm64 | |
COPY build.sh / | |
ENV CARGO_BUILD_TARGET=aarch64-unknown-linux-gnu | |
ENV CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=/usr/bin/aarch64-linux-gnu-gcc | |
ENV PKG_CONFIG_ALLOW_CROSS=1 | |
ENV PKG_CONFIG_PATH_aarch64_unknown_linux_gnu=/usr/lib/aarch64-linux-gnu/pkgconfig/ | |
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-bevy-aarch64 . | |
# 2. Build rust project with bevy. | |
cd /path/to/project | |
docker run --rm -v $PWD:/build rust-bevy-aarch64 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment