summaryrefslogtreecommitdiff
path: root/hadrian/build-cabal
diff options
context:
space:
mode:
authorXavier Denis <xldenis@gmail.com>2020-02-13 17:52:09 +0100
committerMarge Bot <ben+marge-bot@smart-cactus.org>2020-02-29 05:07:50 -0500
commita999ee96a22650b59855609f84e2808b4133e9e0 (patch)
treeaf6a76a019dab2f9b8d6428bedcf55d95d1e2e5e /hadrian/build-cabal
parent99d2de860ff82e3f626c8b3d47d355ab16d18fd1 (diff)
downloadhaskell-a999ee96a22650b59855609f84e2808b4133e9e0.tar.gz
Rename ghci.sh and build.sh to ghci and build respectively
Convert hadrian buildscripts to unsuffixed, dashed form final cleanups
Diffstat (limited to 'hadrian/build-cabal')
-rwxr-xr-xhadrian/build-cabal48
1 files changed, 48 insertions, 0 deletions
diff --git a/hadrian/build-cabal b/hadrian/build-cabal
new file mode 100755
index 0000000000..c385542410
--- /dev/null
+++ b/hadrian/build-cabal
@@ -0,0 +1,48 @@
+#!/usr/bin/env bash
+
+CABAL=cabal
+CABFLAGS="--disable-documentation --disable-profiling --disable-library-profiling $CABFLAGS"
+
+# 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//./ } )
+
+build_failed() {
+ ( ghc --info | grep -s '("Support SMP","YES")' > /dev/null ) \
+ || cat <<EOF
+Your compiler does not support the threaded runtime system.
+Please disable the \`threaded\` Cabal flag in project.cabal.local
+by running:
+
+ echo -e "package hadrian\n flags: -threaded" >> project.cabal.local
+
+EOF
+ exit 1
+}
+
+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
+ # use new-exec instead of new-run to make sure that the build-tools (alex & happy) are in PATH
+ "$CABAL" --project-file="$PROJ" new-exec $CABFLAGS hadrian -- \
+ --directory "$PWD" \
+ "$@" \
+ || build_failed
+else
+ echo "Cabal version is too old; you need at least cabal-install 2.2"
+ exit 2
+fi