#!/bin/bash

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
cd "$DIR/.."

# Clean previous builds
rm -rf target

# Set cross-compiler for ARMv7 (BeagleBone / ARM 32-bit musl)
export CC=arm-linux-gnueabi-gcc

# Add the ARMv7 target
rustup target add armv7-unknown-linux-musleabi

# Set Rust flags for linking and enabling static CRT
RUSTFLAGS="-C linker=arm-linux-gnueabi-gcc -C target-feature=+crt-static" \
    cargo build --target=armv7-unknown-linux-musleabi --release --verbose

