Restore the original build script relying on the global package database
authorAndrey Mokhov <andrey.mokhov@gmail.com>
Sat, 14 Oct 2017 22:44:49 +0000 (23:44 +0100)
committerAndrey Mokhov <andrey.mokhov@gmail.com>
Sat, 14 Oct 2017 22:44:49 +0000 (23:44 +0100)
See #435, #430

build.global-db.sh

index 2a0e8a7..5f1579b 100755 (executable)
@@ -1,7 +1,5 @@
 #!/usr/bin/env bash
 
-CABAL=cabal
-
 set -euo pipefail
 
 # readlink on os x, doesn't support -f, to prevent the
@@ -30,45 +28,25 @@ function rl {
     echo "$RESULT"
 }
 
-absoluteRoot="$(dirname "$(rl "$0")")"
-cd "$absoluteRoot"
-
-if ! type "$CABAL" > /dev/null; then
-    echo "Please make sure 'cabal' is in your PATH"
-    exit 2
-fi
-
-CABVERSTR=$("$CABAL" --numeric-version)
-
-CABVER=( ${CABVERSTR//./ } )
-
-if [ "${CABVER[0]}" -eq 2 -o "${CABVER[0]}" -eq 1 -a "${CABVER[1]}" -ge 24 ]; then
-    # New enough cabal version detected, so
-    # let's use the superior 'cabal new-build' mode
-
-    # there's no 'cabal new-run' yet, but it's easy to emulate
-    "$CABAL" new-build --disable-profiling --disable-documentation -j exe:hadrian
-    $(find ./dist-newstyle -type f -name hadrian | head -n 1) \
-        --lint                         \
-        --directory "$absoluteRoot/.." \
-        "$@"
-
-else
-    # The logic below is quite fragile, but it's better than nothing for pre-1.24 cabals
-    echo "Old pre cabal 1.24 version detected. Falling back to legacy 'cabal sandbox' mode."
-
-    # Initialize sandbox if necessary
-    if ! ( "$CABAL" sandbox hc-pkg list > /dev/null 2>&1); then
-        "$CABAL" sandbox init
-        "$CABAL" sandbox add-source ../libraries/Cabal/Cabal
-        "$CABAL" install                \
-            --dependencies-only         \
-            --disable-library-profiling \
-            --disable-shared
-    fi
-
-    "$CABAL" run hadrian --            \
-        --lint                         \
-        --directory "$absoluteRoot/.." \
-        "$@"
-fi
+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/.." \
+    "$@"
\ No newline at end of file