summaryrefslogtreecommitdiff
path: root/hadrian/build.cabal.sh
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2018-10-23 14:20:13 -0400
committerBen Gamari <ben@smart-cactus.org>2018-10-23 14:20:13 -0400
commit94756201349685a34c4495addd3484fdfcc8b498 (patch)
treefd4a9cee20d3c2b79f56ded7e02fb0c01b26b6c9 /hadrian/build.cabal.sh
parent575b35f4cdc18045bccd42d341d6f25d95c0696c (diff)
parent45f3bff7016a2a0cd9a5455a882ced984655e90b (diff)
downloadhaskell-94756201349685a34c4495addd3484fdfcc8b498.tar.gz
Add 'hadrian/' from commit '45f3bff7016a2a0cd9a5455a882ced984655e90b'
git-subtree-dir: hadrian git-subtree-mainline: 575b35f4cdc18045bccd42d341d6f25d95c0696c git-subtree-split: 45f3bff7016a2a0cd9a5455a882ced984655e90b
Diffstat (limited to 'hadrian/build.cabal.sh')
-rwxr-xr-xhadrian/build.cabal.sh34
1 files changed, 34 insertions, 0 deletions
diff --git a/hadrian/build.cabal.sh b/hadrian/build.cabal.sh
new file mode 100755
index 0000000000..9fddd61c4e
--- /dev/null
+++ b/hadrian/build.cabal.sh
@@ -0,0 +1,34 @@
+#!/usr/bin/env bash
+
+CABAL=cabal
+CABFLAGS="--disable-documentation --disable-profiling"
+
+# It is currently more robust to pass Cabal an absolute path to the project file.
+PROJ="$PWD/hadrian/cabal.project"
+
+set -euo pipefail
+
+if ! [ -f "$PROJ" ]; then
+ echo "Current working directory must be GHC's top-level folder"
+ exit 2
+fi
+
+if ! type "$CABAL" > /dev/null; then
+ echo "Please make sure 'cabal' is in your PATH"
+ exit 2
+fi
+
+CABVERSTR=$("$CABAL" --numeric-version)
+CABVER=( ${CABVERSTR//./ } )
+
+if [ "${CABVER[0]}" -gt 2 -o "${CABVER[0]}" -eq 2 -a "${CABVER[1]}" -ge 2 ];
+then
+ "$CABAL" --project-file="$PROJ" new-build $CABFLAGS -j exe:hadrian
+ "$CABAL" --project-file="$PROJ" new-run $CABFLAGS exe:hadrian -- \
+ --lint \
+ --directory "$PWD" \
+ "$@"
+else
+ echo "Cabal version is too old; you need at least cabal-install 2.2"
+ exit 2
+fi