summaryrefslogtreecommitdiff
path: root/hadrian/build.stack.sh
diff options
context:
space:
mode:
authorAndrey Mokhov <andrey.mokhov@gmail.com>2017-11-06 22:59:38 +0000
committerAndrey Mokhov <andrey.mokhov@gmail.com>2017-11-06 22:59:38 +0000
commit5cee48036ed69ae298a599d43cf72e0fe73e3b4e (patch)
tree5fe732c738a769d02e732469f4ffecd4ac9e191a /hadrian/build.stack.sh
parent275ac8ef0a0081f16abbfb8934e10cf271573768 (diff)
parent7b0b9f603bb1215e2b7af23c2404d637b95a4988 (diff)
downloadhaskell-5cee48036ed69ae298a599d43cf72e0fe73e3b4e.tar.gz
Merge commit '7b0b9f603bb1215e2b7af23c2404d637b95a4988' as 'hadrian'
Diffstat (limited to 'hadrian/build.stack.sh')
-rwxr-xr-xhadrian/build.stack.sh39
1 files changed, 39 insertions, 0 deletions
diff --git a/hadrian/build.stack.sh b/hadrian/build.stack.sh
new file mode 100755
index 0000000000..2b1ff1d059
--- /dev/null
+++ b/hadrian/build.stack.sh
@@ -0,0 +1,39 @@
+#!/usr/bin/env bash
+
+set -euo pipefail
+
+# readlink on os x, doesn't support -f, to prevent the
+# need of installing coreutils (e.g. through brew, just
+# for readlink, we use the follownig substitute.
+#
+# source: http://stackoverflow.com/a/1116890
+function rl {
+ TARGET_FILE="$1"
+
+ cd "$(dirname "$TARGET_FILE")"
+ TARGET_FILE="$(basename "$TARGET_FILE")"
+
+ # Iterate down a (possible) chain of symlinks
+ while [ -L "$TARGET_FILE" ]
+ do
+ TARGET_FILE="$(readlink "$TARGET_FILE")"
+ cd "$(dirname "$TARGET_FILE")"
+ TARGET_FILE="$(basename "$TARGET_FILE")"
+ done
+
+ # Compute the canonicalized name by finding the physical path
+ # for the directory we're in and appending the target file.
+ PHYS_DIR="$(pwd -P)"
+ RESULT="$PHYS_DIR/$TARGET_FILE"
+ echo "$RESULT"
+}
+
+absoluteRoot="$(dirname "$(rl "$0")")"
+cd "$absoluteRoot"
+
+stack build --no-library-profiling ${HADRIAN_NIX:+--nix}
+
+stack exec hadrian -- \
+ --lint \
+ --directory "$absoluteRoot/.." \
+ "$@"