diff options
author | Andrey Mokhov <andrey.mokhov@gmail.com> | 2017-11-06 22:59:37 +0000 |
---|---|---|
committer | Andrey Mokhov <andrey.mokhov@gmail.com> | 2017-11-06 22:59:37 +0000 |
commit | 7b0b9f603bb1215e2b7af23c2404d637b95a4988 (patch) | |
tree | ca118c1b14bc4429e827e0caf925dbc3ab77d1cd /build.sh | |
download | haskell-7b0b9f603bb1215e2b7af23c2404d637b95a4988.tar.gz |
Squashed 'hadrian/' content from commit 438dc57
git-subtree-dir: hadrian
git-subtree-split: 438dc576e7b84c473a09d1d7ec7798a30303bc4e
Diffstat (limited to 'build.sh')
-rwxr-xr-x | build.sh | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/build.sh b/build.sh new file mode 100755 index 0000000000..ad502b3c49 --- /dev/null +++ b/build.sh @@ -0,0 +1,35 @@ +#!/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" +} + +root="$(dirname "$(rl "$0")")" + +# By default on Linux/MacOS we build Hadrian using Cabal +chmod a+x "$root/build.cabal.sh" +(. "$root/build.cabal.sh" "$@") |