Commit 08387f8e authored by Mikhail Glushenkov's avatar Mikhail Glushenkov
Browse files

Merge pull request #3447 from tuncer/jobs

Implement -j in travis and bootstrap script
parents 345aeeff 491be6df
......@@ -31,7 +31,7 @@ install:
# ./dist/setup/setup here instead of cabal-install to avoid breakage when the
# build config format changed.
script:
- ./travis-script.sh
- ./travis-script.sh -j
matrix:
allow_failures:
......
......@@ -105,6 +105,7 @@ GHC_PKG_VER="$(${GHC_PKG} --version | cut -d' ' -f 5)"
die "Version mismatch between ${GHC} and ${GHC_PKG}.
If you set the GHC variable then set GHC_PKG too."
JOBS="-j1"
while [ "$#" -gt 0 ]; do
case "${1}" in
"--user")
......@@ -127,11 +128,25 @@ while [ "$#" -gt 0 ]; do
"--no-doc")
NO_DOCUMENTATION=1
shift;;
"-j"|"--jobs")
shift
# check if there is another argument which doesn't start with - or --
if [ "$#" -le 0 ] \
|| [ ! -z $(echo "${1}" | grep "^-") ] \
|| [ ! -z $(echo "${1}" | grep "^--") ]
then
JOBS="-j"
else
JOBS="-j${1}"
shift
fi;;
*)
echo "Unknown argument or option, quitting: ${1}"
echo "usage: bootstrap.sh [OPTION]"
echo
echo "options:"
echo " -j/--jobs Number of concurrent workers to use (Default: 1)"
echo " -j without an argument will use all available cores"
echo " --user Install for the local user (default)"
echo " --global Install systemwide (must be run as root)"
echo " --no-doc Do not generate documentation for installed"\
......@@ -143,6 +158,15 @@ while [ "$#" -gt 0 ]; do
esac
done
# Do not try to use -j with GHC older than 7.8
case $GHC_VER in
7.4*|7.6*)
JOBS=""
;;
*)
;;
esac
abspath () { case "$1" in /*)printf "%s\n" "$1";; *)printf "%s\n" "$PWD/$1";;
esac; }
......@@ -330,7 +354,7 @@ install_pkg () {
[ -x Setup ] && ./Setup clean
[ -f Setup ] && rm Setup
${GHC} --make Setup -o Setup ||
${GHC} --make ${JOBS} Setup -o Setup ||
die "Compiling the Setup script failed."
[ -x Setup ] || die "The Setup script does not exist or cannot be run"
......@@ -341,7 +365,7 @@ install_pkg () {
./Setup configure $args || die "Configuring the ${PKG} package failed."
./Setup build ${EXTRA_BUILD_OPTS} ${VERBOSE} ||
./Setup build ${JOBS} ${EXTRA_BUILD_OPTS} ${VERBOSE} ||
die "Building the ${PKG} package failed."
if [ ! ${NO_DOCUMENTATION} ]
......
#!/usr/bin/env bash
set -ev
usage() {
echo -e -n "Usage: `basename $0`\n-j jobs\n"
}
jobs="-j1"
# We use a separate jobs var for bootstrap.sh because the arg parser in
# bootstrap.sh wouldn't be able to interpret -j1 (or any -jN).
bootstrap_jobs="-j 1"
while getopts ":hj:" opt; do
case $opt in
h)
usage
exit 0
;;
j)
jobs="-j$OPTARG"
bootstrap_jobs="-j $OPTARG"
;;
:)
# Argument-less -j
if [ "$OPTARG" = "j" ]; then
jobs="-j"
bootstrap_jobs="-j"
fi
;;
\?)
echo "Invalid option: $OPTARG"
usage
exit 1
;;
esac
done
shift $((OPTIND-1))
# Do not try to use -j with GHC older than 7.8
case $GHCVER in
7.4*|7.6*)
jobs=""
bootstrap_jobs=""
;;
*)
;;
esac
# ---------------------------------------------------------------------
# Bootstrap cabal, to verify bootstrap.sh script works.
# ---------------------------------------------------------------------
......@@ -9,7 +53,7 @@ OLD_CWD=$PWD
# Bootstrap
cd cabal-install
env EXTRA_CONFIGURE_OPTS="" ./bootstrap.sh --no-doc
env EXTRA_CONFIGURE_OPTS="" ./bootstrap.sh $bootstrap_jobs --no-doc
~/.cabal/bin/cabal --version
# Move cabal for local use.
......@@ -31,7 +75,7 @@ cabal update
# We depend on parsec nowadays, which isn't distributed with GHC <8.0
if [ "$PARSEC_BUNDLED" != "YES" ]; then
cabal install parsec
cabal install $jobs parsec
fi
# ---------------------------------------------------------------------
......@@ -64,18 +108,19 @@ cd Cabal
mkdir -p ./dist/setup
cp Setup.hs ./dist/setup/setup.hs
ghc --make \
$jobs \
-odir ./dist/setup -hidir ./dist/setup -i -i. \
./dist/setup/setup.hs -o ./dist/setup/setup \
-Wall -Werror -threaded
# Install test dependencies only after setup is built
cabal install --only-dependencies --enable-tests --enable-benchmarks
cabal install $jobs --only-dependencies --enable-tests --enable-benchmarks
./dist/setup/setup configure \
--user --ghc-option=-Werror --enable-tests --enable-benchmarks \
-v2 # -v2 provides useful information for debugging
# Build all libraries and executables (including tests/benchmarks)
./dist/setup/setup build
./dist/setup/setup build $jobs
./dist/setup/setup haddock # see https://github.com/haskell/cabal/issues/2198
./dist/setup/setup test --show-details=streaming --test-option=--hide-successes
......@@ -110,12 +155,12 @@ install_from_tarball
cd ../cabal-install
cabal install happy
cabal install --only-dependencies --enable-tests --enable-benchmarks
cabal install $jobs happy
cabal install $jobs --only-dependencies --enable-tests --enable-benchmarks
cabal configure \
--user --ghc-option=-Werror --enable-tests --enable-benchmarks \
-v2 # -v2 provides useful information for debugging
cabal build
cabal build $jobs
cabal haddock # see https://github.com/haskell/cabal/issues/2198
cabal test unit-tests --show-details=streaming --test-option=--hide-successes
cabal test integration-tests --show-details=streaming --test-option=--hide-successes
......
Supports Markdown
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