[commit: ghc] wip/nfs-locking: Rearrange unix build scripts. (#430) (45da08b)
git at git.haskell.org
git at git.haskell.org
Fri Oct 27 00:44:31 UTC 2017
Repository : ssh://git@git.haskell.org/ghc
On branch : wip/nfs-locking
Link : http://ghc.haskell.org/trac/ghc/changeset/45da08bb3c8b6806c0b3484e32abaeb4358cc6c1/ghc
>---------------------------------------------------------------
commit 45da08bb3c8b6806c0b3484e32abaeb4358cc6c1
Author: Doug Wilson <douglas.wilson at gmail.com>
Date: Wed Oct 11 14:32:35 2017 +1300
Rearrange unix build scripts. (#430)
Addresses Issue #428
>---------------------------------------------------------------
45da08bb3c8b6806c0b3484e32abaeb4358cc6c1
.travis.yml | 8 ++---
build.cabal.sh => build.global-db.sh | 0
build.sh | 69 +++++++++++++++++++++---------------
build.stack.sh => build.stack.nix.sh | 8 +----
build.stack.sh | 2 +-
circle.yml | 4 +--
stack.yaml | 1 +
7 files changed, 50 insertions(+), 42 deletions(-)
diff --git a/.travis.yml b/.travis.yml
index e14f962..e2455b2 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -18,10 +18,10 @@ matrix:
script:
# Run internal Hadrian tests
- - ./build.cabal.sh selftest
+ - ./build.sh selftest
# Build GHC
- - ./build.cabal.sh -j $MODE --no-progress --progress-colour=never --profile=-
+ - ./build.sh -j $MODE --no-progress --progress-colour=never --profile=-
- os: linux
env: MODE="--flavour=quickest --integer-simple"
@@ -40,7 +40,7 @@ matrix:
script:
# Build GHC
- - ./build.cabal.sh -j $MODE --no-progress --progress-colour=never --profile=-
+ - ./build.sh -j $MODE --no-progress --progress-colour=never --profile=-
# Test GHC binary
- cd ..
@@ -56,7 +56,7 @@ matrix:
script:
# Due to timeout limit of OS X build on Travis CI,
# we will ignore selftest and build only stage1
- - ./build.cabal.sh -j $MODE --no-progress --progress-colour=never --profile=-
+ - ./build.sh -j $MODE --no-progress --progress-colour=never --profile=-
install:
# Add Cabal to PATH
diff --git a/build.cabal.sh b/build.global-db.sh
similarity index 100%
rename from build.cabal.sh
rename to build.global-db.sh
diff --git a/build.sh b/build.sh
index 0f957cf..2a0e8a7 100755
--- a/build.sh
+++ b/build.sh
@@ -1,5 +1,7 @@
#!/usr/bin/env bash
+CABAL=cabal
+
set -euo pipefail
# readlink on os x, doesn't support -f, to prevent the
@@ -28,34 +30,45 @@ function rl {
echo "$RESULT"
}
-root="$(dirname "$(rl "$0")")"
+absoluteRoot="$(dirname "$(rl "$0")")"
+cd "$absoluteRoot"
-if type cabal > /dev/null 2>&1; then
- CABVERSTR=$(cabal --numeric-version)
- CABVER=( ${CABVERSTR//./ } )
- if [ "${CABVER[0]}" -eq 1 -a "${CABVER[1]}" -ge 24 ]; then
- echo "** Cabal 1.24 or later detected. Please consider using the 'build.cabal.sh' script **"
- echo ""
- fi
+if ! type "$CABAL" > /dev/null; then
+ echo "Please make sure 'cabal' is in your PATH"
+ exit 2
fi
-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/.." \
- "$@"
+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
diff --git a/build.stack.sh b/build.stack.nix.sh
similarity index 82%
copy from build.stack.sh
copy to build.stack.nix.sh
index 23f4833..59ac061 100755
--- a/build.stack.sh
+++ b/build.stack.nix.sh
@@ -29,11 +29,5 @@ function rl {
}
absoluteRoot="$(dirname "$(rl "$0")")"
-cd "$absoluteRoot"
-stack build --no-library-profiling
-
-stack exec hadrian -- \
- --lint \
- --directory "$absoluteRoot/.." \
- "$@"
+HADRIAN_NIX=YES ${absoluteRoot}/build.stack.sh
diff --git a/build.stack.sh b/build.stack.sh
index 23f4833..2b1ff1d 100755
--- a/build.stack.sh
+++ b/build.stack.sh
@@ -31,7 +31,7 @@ function rl {
absoluteRoot="$(dirname "$(rl "$0")")"
cd "$absoluteRoot"
-stack build --no-library-profiling
+stack build --no-library-profiling ${HADRIAN_NIX:+--nix}
stack exec hadrian -- \
--lint \
diff --git a/circle.yml b/circle.yml
index 48653e8..a386d72 100644
--- a/circle.yml
+++ b/circle.yml
@@ -30,10 +30,10 @@ compile:
# XXX: export PATH doesn't work well either, so we use inline env
# Self test
- - PATH=$HOME/.cabal/bin:$PATH ghc/hadrian/build.cabal.sh selftest
+ - PATH=$HOME/.cabal/bin:$PATH ghc/hadrian/build.sh selftest
# Build GHC
- - PATH=$HOME/.cabal/bin:$PATH ghc/hadrian/build.cabal.sh -j $MODE --no-progress --progress-colour=never --profile=-
+ - PATH=$HOME/.cabal/bin:$PATH ghc/hadrian/build.sh -j $MODE --no-progress --progress-colour=never --profile=-
test:
override:
diff --git a/stack.yaml b/stack.yaml
index 2a92f26..da03763 100644
--- a/stack.yaml
+++ b/stack.yaml
@@ -12,6 +12,7 @@ extra-deps:
- shake-0.16
nix:
+ enable: false
packages:
- autoconf
- automake
More information about the ghc-commits
mailing list