#!/bin/sh
set -x
# Change to this script directory
cd $(dirname "$0")

rustup override set 1.86

cargo test --all || exit 1
cargo test --all --target x86_64-pc-windows-gnu || exit 1

# # The following is setup already in `rust-toolchain.toml`
# rustup target add x86_64-unknown-linux-gnu
# # Musl needs: `sudo apt install musl-tools` 
# rustup target add x86_64-unknown-linux-musl
# # Windows needs: `sudo apt install binutils-mingw-w64 mingw-w64`
# rustup target add x86_64-pc-windows-gnu
# # Binary for Raspberry Pi (32 bit)
# rustup target add armv7-unknown-linux-gnueabihf
# # needs: `sudo apt install crossbuild-essential-armhf`
# # Binary for Raspberry Pi (arm64, 64 bit)
# rustup target add aarch64-unknown-linux-gnu
# # needs: `sudo apt install crossbuild-essential-arm64`

# CARGO_TARGET_ARMV7_UNKNOWN_LINUX_GNUEABIHF_LINKER=/usr/bin/arm-linux-gnueabihf-gcc \
# CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=/usr/bin/aarch64-linux-gnu-gcc \
cargo build \
   --target x86_64-unknown-linux-gnu \
   --target x86_64-unknown-linux-musl \
   --target x86_64-pc-windows-gnu \
   --target armv7-unknown-linux-gnueabihf \
   --target aarch64-unknown-linux-gnu \
   --release

