hyfetch/tools/rust-builder/general/build.sh

34 lines
1.4 KiB
Bash
Raw Normal View History

2024-12-22 01:09:44 -05:00
#!/usr/bin/env bash
2024-12-22 01:39:13 -05:00
set -e
2024-12-22 04:22:52 -05:00
# Add cargo to path
export PATH="$HOME/.cargo/bin:$PATH"
cd /app
2024-12-22 01:39:13 -05:00
# Set linkers for cross-compilation
2024-12-22 04:22:52 -05:00
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
2024-12-22 01:39:13 -05:00
2024-12-22 05:53:28 -05:00
# Add -C relocation-model=static to the build command
# See https://github.com/rust-lang/rust/issues/95926
export RUSTFLAGS="-C relocation-model=static"
2024-12-22 01:09:44 -05:00
# Build for platforms
cargo build --release --target x86_64-unknown-linux-musl
2024-12-22 04:22:52 -05:00
cargo build --release --target aarch64-unknown-linux-musl
cargo build --release --target armv7-unknown-linux-musleabihf
#cargo build --release --target riscv64gc-unknown-linux-musl
2024-12-22 01:09:44 -05:00
cargo build --release --target x86_64-pc-windows-gnu
2024-12-22 04:22:52 -05:00
#cargo build --release --target x86_64-apple-darwin
#cargo build --release --target aarch64-apple-darwin