hyfetch/tools/rust-builder/general/build.sh
2024-12-22 05:53:28 -05:00

33 lines
1.4 KiB
Bash
Executable file

#!/usr/bin/env bash
set -e
# Add cargo to path
export PATH="$HOME/.cargo/bin:$PATH"
cd /app
# Set linkers for cross-compilation
export CARGO_TARGET_X86_64_UNKNOWN_LINUX_MUSL_LINKER=musl-gcc
export CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_LINKER=/musl/aarch64/bin/musl-gcc
export CARGO_TARGET_ARMV7_UNKNOWN_LINUX_MUSLEABIHF_LINKER=/musl/armv7l/bin/musl-gcc
export CARGO_TARGET_RISCV64GC_UNKNOWN_LINUX_MUSL_LINKER=/musl/riscv64/bin/musl-gcc
# OSX linker and ar
#export OSX_VER=20.4
#export CARGO_TARGET_X86_64_APPLE_DARWIN_LINKER=/osxcross/bin/x86_64-apple-darwin$OSX_VER-clang
#export CARGO_TARGET_X86_64_APPLE_DARWIN_AR=/osxcross/bin/x86_64-apple-darwin$OSX_VER-ar
#export CARGO_TARGET_AARCH64_APPLE_DARWIN_LINKER=/osxcross/bin/aarch64-apple-darwin$OSX_VER-clang
#export CARGO_TARGET_AARCH64_APPLE_DARWIN_AR=/osxcross/bin/aarch64-apple-darwin$OSX_VER-ar
# Add -C relocation-model=static to the build command
# See https://github.com/rust-lang/rust/issues/95926
export RUSTFLAGS="-C relocation-model=static"
# Build for platforms
cargo build --release --target x86_64-unknown-linux-musl
cargo build --release --target aarch64-unknown-linux-musl
cargo build --release --target armv7-unknown-linux-musleabihf
#cargo build --release --target riscv64gc-unknown-linux-musl
cargo build --release --target x86_64-pc-windows-gnu
#cargo build --release --target x86_64-apple-darwin
#cargo build --release --target aarch64-apple-darwin