fix end
[hadrian.git] / build.global-db.sh
1 #!/usr/bin/env bash
2
3 set -euo pipefail
4
5 # readlink on os x, doesn't support -f, to prevent the
6 # need of installing coreutils (e.g. through brew, just
7 # for readlink, we use the follownig substitute.
8 #
9 # source: http://stackoverflow.com/a/1116890
10 function rl {
11 TARGET_FILE="$1"
12
13 cd "$(dirname "$TARGET_FILE")"
14 TARGET_FILE="$(basename "$TARGET_FILE")"
15
16 # Iterate down a (possible) chain of symlinks
17 while [ -L "$TARGET_FILE" ]
18 do
19 TARGET_FILE="$(readlink "$TARGET_FILE")"
20 cd "$(dirname "$TARGET_FILE")"
21 TARGET_FILE="$(basename "$TARGET_FILE")"
22 done
23
24 # Compute the canonicalized name by finding the physical path
25 # for the directory we're in and appending the target file.
26 PHYS_DIR="$(pwd -P)"
27 RESULT="$PHYS_DIR/$TARGET_FILE"
28 echo "$RESULT"
29 }
30
31 root="$(dirname "$(rl "$0")")"
32
33 mkdir -p "$root/bin"
34
35 ghc \
36 "$root/src/Main.hs" \
37 -Wall \
38 -fno-warn-name-shadowing \
39 -XRecordWildCards \
40 -i"$root/src" \
41 -i"$root/../libraries/Cabal/Cabal" \
42 -rtsopts \
43 -with-rtsopts=-I0 \
44 -threaded \
45 -outputdir="$root/bin" \
46 -j -O \
47 -o "$root/bin/hadrian"
48
49 "$root/bin/hadrian" \
50 --lint \
51 --directory "$root/.." \
52 "$@"