Commit ed18f47f authored by Mateusz Kowalczyk's avatar Mateusz Kowalczyk
Browse files

Factor out builds into steps. Address ghc/ghc#83 comments.

This should greatly improve log output.
parent 07e0d0d5
#!/usr/bin/env bash
# vim: sw=2 et
set -euo pipefail
fail() {
echo "ERROR: $*" >&2
exit 1
}
echo 'BUILD_SPHINX_HTML = NO' > mk/validate.mk
echo 'BUILD_SPHINX_PDF = NO' >> mk/validate.mk
cat > mk/build.mk <<EOF
V=1
HADDOCK_DOCS=YES
LATEX_DOCS=YES
HSCOLOUR_SRCS=YES
BUILD_DOCBOOK_HTML=YES
BeConservative=YES
EOF
export THREADS=8
export SKIP_PERF_TESTS=YES
export VERBOSE=2
function run_build() {
./boot
./configure "$@"
make -j$THREADS
make fasttest
make binary-dist
}
case "$(uname)" in
Linux)
if [[ -n ${TARGET:-} ]]; then
if [[ $TARGET = FreeBSD ]]; then
# cross-compiling to FreeBSD
echo 'HADDOCK_DOCS = NO' >> mk/build.mk
echo 'WERROR=' >> mk/build.mk
export PATH=/opt/ghc/bin:$PATH
run_build --target=x86_64-unknown-freebsd10
else
fail "TARGET=$target not supported"
fi
else
run_build
fi
;;
Darwin)
if [[ -n ${TARGET:-} ]]; then
fail "uname=$(uname) not supported for cross-compilation"
fi
run_build
;;
*)
fail "uname=$(uname) not supported"
esac
......@@ -3,6 +3,16 @@ version: 2
aliases:
- &defaults
working_directory: ~/ghc
# Make sure we have proper openssh before checkout: CircleCI git
# does not check the repository out properly without it and also
# takes 20 times longer than it should be.
- &precheckout
run:
name: Install OpenSSH client
command: |
apt-get update -qq
apt-get install -qy openssh-client
- &prepare
run:
name: prepare-system
......@@ -11,16 +21,40 @@ aliases:
run:
name: submodules
command: .circleci/fetch-submodules.sh
- &build
- &buildenv
THREADS: 8
SKIP_PERF_TESTS: YES
VERBOSE: 2
- &boot
run:
name: Boot
command: ./boot
- &configure_unix
run:
name: Configure
command: ./configure
- &configure_bsd
run:
name: Configure
command: ./configure --target=x86_64-unknown-freebsd10
- &make
run:
name: build
command: .circleci/build.sh
name: Build
command: "make -j$THREADS"
- &test
run:
name: Test
command: make test
- &bindist
run:
name: Create bindist
command: make binary-dist
# Building bindist takes ~15 minutes without output, account for
# that.
no_output_timeout: "30m"
- &collectartifacts
run:
name: collect artifacts
name: Collect artifacts
# We need this because CircleCI expects a path without
# wildcards but bindist archive name is not static
command: |
......@@ -28,28 +62,29 @@ aliases:
pwd
find .
cp ghc*.tar.xz /tmp/artifacts
- &storeartifacts
store-artifacts:
path: /tmp/artifacts
jobs:
"validate-x86_64-linux":
resource_class: xlarge
docker:
- image: haskell:8.2
environment:
<<: *buildenv
steps:
# Make sure we have proper openssh before checkout: CircleCI git
# does not check the repository out properly without it and also
# takes 20 times longer than it should be.
- run:
name: install openssh
command: |
apt-get update -qq
apt-get install -y openssh-client
- *precheckout
- checkout
- *prepare
- *submodules
- *build
- *boot
- *configure_unix
- *make
- *test
- *bindist
- *collectartifacts
- store-artifacts:
path: /tmp/artifacts
- *storeartifacts
"validate-x86_64-freebsd":
resource_class: xlarge
......@@ -57,28 +92,36 @@ jobs:
- image: tweag/toolchain-x86_64-freebsd
environment:
TARGET: FreeBSD
<<: *buildenv
steps:
- run:
name: install git
command: |
apt-get update -qq
apt-get install -qy openssh-client
- *precheckout
- checkout
- *prepare
- *submodules
- *build
- *boot
- *configure_bsd
- *make
- *test
- *bindist
- *collectartifacts
- *storeartifacts
"validate-x86_64-darwin":
macos:
xcode: "9.0"
environment:
<<: *buildenv
steps:
- checkout
- *prepare
- *submodules
- *build
- *boot
- *configure_unix
- *make
- *test
- *bindist
- *collectartifacts
- store-artifacts:
path: /tmp/artifacts
- *storeartifacts
workflows:
version: 2
......
......@@ -7,6 +7,18 @@ fail() {
exit 1
}
echo 'BUILD_SPHINX_HTML = NO' > mk/validate.mk
echo 'BUILD_SPHINX_PDF = NO' >> mk/validate.mk
cat > mk/build.mk <<EOF
V=1
HADDOCK_DOCS=YES
LATEX_DOCS=YES
HSCOLOUR_SRCS=YES
BUILD_DOCBOOK_HTML=YES
BeConservative=YES
EOF
case "$(uname)" in
Linux)
if [[ -n ${TARGET:-} ]]; then
......@@ -14,17 +26,23 @@ case "$(uname)" in
# cross-compiling to FreeBSD
add-apt-repository -y ppa:hvr/ghc
apt-get update -qq
apt-get install -qy ghc-8.0.2 cabal-install alex happy ncurses-dev git openssh-client make automake autoconf gcc perl python3 texinfo xz-utils
apt-get install -qy ghc-8.0.2 cabal-install-1.24 alex happy \
ncurses-dev git make automake autoconf gcc perl \
python3 texinfo xz-utils
cabal update
cabal install --reinstall hscolour
ln -s $HOME/.cabal/bin/HsColour /usr/local/bin/HsColour
echo 'HADDOCK_DOCS = NO' >> mk/build.mk
echo 'WERROR=' >> mk/build.mk
# https://circleci.com/docs/2.0/env-vars/#interpolating-environment-variables-to-set-other-environment-variables
echo 'export PATH=/opt/ghc/bin:$PATH' >> $BASH_ENV
else
fail "TARGET=$target not supported"
fi
else
# assuming Ubuntu
apt-get update -qq
apt-get install -qy git openssh-client make automake autoconf gcc perl python3 texinfo xz-utils
apt-get install -qy git make automake autoconf gcc perl python3 texinfo xz-utils
cabal update
cabal install --reinstall hscolour
fi
......
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