set -eu
cargo doc
cargo test
TARGETS="
i686-unknown-linux-gnu
x86_64-unknown-linux-gnu
x86_64-pc-windows-gnu
"
RUST_LOG="guess_host_triple=debug"
export RUST_LOG
cargo build --example guess-host-triple --target i686-unknown-linux-gnu
OUTPUT=$(target/i686-unknown-linux-gnu/debug/examples/guess-host-triple)
if [ "$OUTPUT" != "x86_64-unknown-linux-gnu" ]; then
echo "library is broken, printed $OUTPUT"
exit 1
fi
cargo build --example guess-host-triple --target x86_64-unknown-linux-gnu
OUTPUT=$(target/x86_64-unknown-linux-gnu/debug/examples/guess-host-triple)
if [ "$OUTPUT" != "x86_64-unknown-linux-gnu" ]; then
echo "library is broken, printed $OUTPUT"
exit 1
fi
RUSTFLAGS="-C linker=x86_64-w64-mingw32-gcc" \
cargo build --example guess-host-triple \
--target x86_64-pc-windows-gnu
WINEPREFIX=$(mktemp -d)
WINEARCH=win64
export RUSTFLAGS WINEPREFIX WINEARCH
OUTPUT=$(wine target/x86_64-pc-windows-gnu/debug/examples/guess-host-triple)
if [ "$OUTPUT" != "x86_64-pc-windows-msvc" ]; then
echo "library is broken, printed $OUTPUT"
exit 1
fi