summaryrefslogtreecommitdiff
path: root/hadrian/build.global-db.sh
blob: 5f1579becd14e13f6e0ec4fafe1e608ae08a1e97 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/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")")"

mkdir -p "$root/bin"

ghc                                      \
    "$root/src/Main.hs"                  \
    -Wall                                \
    -fno-warn-name-shadowing             \
    -XRecordWildCards                    \
    -i"$root/src"                        \
    -i"$root/../libraries/Cabal/Cabal"   \
    -rtsopts                             \
    -with-rtsopts=-I0                    \
    -threaded                            \
    -outputdir="$root/bin" \
    -j -O                                \
    -o "$root/bin/hadrian"

"$root/bin/hadrian"        \
    --lint                 \
    --directory "$root/.." \
    "$@"