1#!/usr/bin/env bash
2# Script for building your rust projects.
3set -e
4
5required_arg() {
6    if [ -z "$1" ]; then
7        echo "Required argument $2 missing"
8        exit 1
9    fi
10}
11
12# $1 {path} = Path to cross/cargo executable
13CROSS=$1
14# $2 {string} = <Target Triple>
15TARGET_TRIPLE=$2
16
17required_arg $CROSS 'CROSS'
18required_arg $TARGET_TRIPLE '<Target Triple>'
19
20if [ "${TARGET_TRIPLE%-windows-gnu}" != "$TARGET_TRIPLE" ]; then
21    # On windows-gnu targets, we need to set the PATH to include MinGW
22    if [ "${TARGET_TRIPLE#x86_64-}" != "$TARGET_TRIPLE" ]; then
23        PATH=/c/msys64/mingw64/bin:/c/msys64/usr/bin:$PATH
24    elif [ "${TARGET_TRIPLE#i?86-}" != "$TARGET_TRIPLE" ]; then
25        PATH=/c/msys64/mingw32/bin:/c/msys64/usr/bin:$PATH
26    else
27        echo Unknown windows-gnu target
28        exit 1
29    fi
30fi
31
32$CROSS test --target $TARGET_TRIPLE
33$CROSS run --target $TARGET_TRIPLE --manifest-path systest/Cargo.toml
34echo === zlib-ng build ===
35$CROSS test --target $TARGET_TRIPLE --no-default-features --features zlib-ng
36$CROSS run --target $TARGET_TRIPLE --manifest-path systest/Cargo.toml  --no-default-features --features zlib-ng
37