Select Git revision
Forked from
Jonas Rabenstein / Linux
Source project has a limited visibility.
build.sh 1.68 KiB
#!/usr/bin/env bash
# A simple wrapper around stack
#
# This exists mainly to make it easier to pass arguments to test and benchmark
# suites.
if [[ $# -eq 0 ]]; then
cat <<EOF
Usage: $0 COMMAND [OPTS]
Commands:
---------
b[uild] [OPTS] build project
[c]opy [OPTS] copy binaries to ./bin/
t[est] u[nit] [OPTS] run unit tests
t[est] e[xamples] [OPTS] run exampes
t[est] d[octests] [OPTS] run doctests
t[est] [OPTS] run all testsuites
bench [OPTS] run the benchmark suite
r[un] [OPTS] run the main program
haddock [OPTS] build documentation
EOF
exit 1
fi
doTest() {
if [[ $# -eq 0 ]]; then
exec stack test
fi
case "$1" in
u|unit|s|spec)
exec stack test :spec --test-arguments "${*:2}"
;;
e|examples)
exec stack test :examples --test-arguments "${*:2}"
;;
d|doctests)
exec stack test :doctests --test-arguments "${*:2}"
;;
*)
exec stack test "$@"
esac
}
doBench() {
exec stack bench :bench --benchmark-arguments "$*"
}
doCopy() {
DIR=$(dirname "$0")/bin
mkdir -p ${DIR}
exec stack build --copy-bins --local-bin-path "${DIR}" "$@"
}
case "$1" in
b|build)
exec stack build "${@:2}"
;;
c|copy)
doCopy "${@:2}"
;;
t|test)
doTest "${@:2}"
;;
bench)
doBench "${@:2}"
;;
r|run)
exec stack exec ma -- "${@:2}"
;;
haddock)
exec stack haddock :ma "${@:2}"
;;
*)
echo "Unknown command $1"
exit 1
esac