Commit 45da08bb authored by duog's avatar duog Committed by Andrey Mokhov

Rearrange unix build scripts. (#430)

Addresses Issue #428
parent 10b83588
......@@ -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
......
#!/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
#!/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"
}
absoluteRoot="$(dirname "$(rl "$0")")"
HADRIAN_NIX=YES ${absoluteRoot}/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 \
......
......@@ -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:
......
......@@ -12,6 +12,7 @@ extra-deps:
- shake-0.16
nix:
enable: false
packages:
- autoconf
- automake
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment