Commit c3070e65 authored by Mikhail Glushenkov's avatar Mikhail Glushenkov
Browse files

Merge pull request #2934 from BardurArantsson/rework-setup-dev-sh

Rework setup-dev.sh to reduce redundancy
parents 84cecac6 7e0c7534
......@@ -6,45 +6,32 @@ die() {
exit 1
}
build_and_test() {
# Find sandbox location
local PACKAGEDB=`cabal exec -- sh -c 'echo $GHC_PACKAGE_PATH' | sed 's/:.*//'`
echo "Cabal package DB location: $PACKAGEDB"
# Do the building
./Setup configure --enable-tests --package-db="$PACKAGEDB" || die "$1 'configure' failed"
./Setup build || die "$1 'build' failed"
# Disabled for now: Tests fail on my system for some reason
# ./Setup test || die "$1 'test' failed"
}
install_deps() {
cabal install --only-dependencies --enable-tests || die "$1: Could not install needed dependencies"
}
create_setup() {
ghc --make -threaded Setup.hs || die "$1: Could not create 'Setup' executable"
}
init_sandbox() {
cabal sandbox delete # Ignore error status; probably just means sandbox doesn't exist
cabal sandbox init || die "$1: Could not initialize sandbox"
}
setup_cabal() {
init_sandbox Cabal
install_deps Cabal
create_setup Cabal
build_and_test Cabal
}
setup_cabalinstall() {
init_sandbox cabal-install
cabal sandbox add-source ../Cabal/ || die "cabal-install: Failed to add ../Cabal source"
install_deps cabal-install
create_setup cabal-install
build_and_test cabal-install
setup() {
# Extract parameters
local NAME="$1"
shift
local DEPS="$@"
# (Re-)create sandbox
cabal sandbox delete # Ignore error status; probably just means sandbox doesn't exist
cabal sandbox init || die "$NAME: Could not initialize sandbox"
# Add dependencies
for DEP in $DEPS; do
cabal sandbox add-source "$DEP"
done
# Install dependencies
cabal install --only-dependencies --enable-tests || die "$NAME: Could not install needed dependencies"
# Build the 'Setup' executable
ghc --make -threaded Setup.hs || die "$NAME: Could not create 'Setup' executable"
# Build the package
local PACKAGEDB=`cabal exec -- sh -c 'echo $GHC_PACKAGE_PATH' | sed 's/:.*//'`
echo "Cabal package DB location: $PACKAGEDB"
./Setup configure --enable-tests --package-db="$PACKAGEDB" || die "$NAME: 'configure' failed"
./Setup build || die "$NAME: 'build' failed"
# Run tests
# Disabled for now: There are some test failures
#./Setup test || die "$1 'test' failed"
}
# Build
(cd ${SCRIPT_DIR}/Cabal && setup_cabal ) || die "Failed to build Cabal"
(cd ${SCRIPT_DIR}/cabal-install && setup_cabalinstall) || die "Failed to build cabal-install"
(cd ${SCRIPT_DIR}/Cabal && setup "Cabal" ) || die "Failed to build Cabal"
(cd ${SCRIPT_DIR}/cabal-install && setup "cabal-install" ../Cabal) || die "Failed to build cabal-install"
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