if [[ $(uname) == MINGW* ]]; then
work_dir="$(cmd /c cd)"
cache_dir="$work_dir\\cache"
else
work_dir="$PWD"
cache_dir="$work_dir/cache"
fi
printf '%s*- mode: compilation; default-directory: "%s" -*-\n' - "$work_dir"
printf 'Compilation started at %s\n\n' "$(date)"
function check_error {
code="$?"
if [ "$code" == "0" ]; then
return
fi
printf '\nCompilation exited abnormally with code %s at %s\n' \
"$code" "$(date)"
exit "$code"
}
for word in "$@"; do
arr=(X${word}X)
count=${#arr[*]}
if [ $count != 1 ]; then
printf 'Expected single parameter, got "%s"\n' "$word"
(exit 2)
check_error
fi
done
export GMP_MPFR_SYS_CACHE="$cache_dir"
if [ -e cache ]; then
rm -r cache
fi
if [ -e target ]; then
rm -r target
fi
suffix=""
if [[ "$1" == "-"* ]]; then
suffix="$1"
shift
fi
if [ $# == 0 ]; then
toolchains=(stable beta nightly 1.18.0)
else
toolchains=("$@")
fi
function print_eval_check {
printf '$'
printf ' %q' "$@"
printf '\n'
eval $(printf '%q ' "$@") 2>&1
check_error
}
function tc {
if [ "$1" != "" ]; then
echo +$1$suffix
fi
}
print_eval_check \
cargo $(tc "${toolchains[0]}") \
check \
--no-default-features --features gmp-mpfr-sys/mpc,gmp-mpfr-sys/ctest \
-p gmp-mpfr-sys -p rug
for features in \
'' gmp-mpfr-sys{,/mpfr,/mpc} \
integer{,\,float,\,complex}{,\,serde} \
rational{,\,float,\,complex}{,\,rand}{,\,serde} \
float{,\,rand}{,\,serde} \
complex{,\,rand}{,\,serde} \
rand{,\,serde} \
serde
do
if [[ "$features" =~ ^(()|serde)$ ]]; then
gmp=""
else
gmp="-p gmp-mpfr-sys"
fi
print_eval_check \
cargo $(tc "${toolchains[0]}") \
check --all-targets \
--no-default-features --features "$features" \
$gmp -p rug
done
rm -r target
for toolchain in "${toolchains[@]}"; do
for build in "" --release; do
print_eval_check \
cargo $(tc "$toolchain") \
test $build \
--features serde \
-p gmp-mpfr-sys -p rug
rm -r target
done
done
for toolchain in "${toolchains[@]}"; do
print_eval_check cargo $(tc "$toolchain") check -p gmp-mpfr-sys
print_eval_check cargo $(tc "$toolchain") check --release -p gmp-mpfr-sys
done
if [ -e cache ]; then
rm -r cache
fi
printf '\nCompilation finished at %s\n' "$(date)"