@@ -1,5 +1,7 @@
1#!/usr/bin/env bash
1#!/usr/bin/env bash
3# TODO: (1) Detect if nix is available otherwise run with plain cabal,
5# TODO: (1) Detect if nix is available otherwise run with plain cabal,
4# (2) Detect the platform and run tests applicable to the platform, (3)
6# (2) Detect the platform and run tests applicable to the platform, (3)
5# add a test for windows/msys
7# add a test for windows/msys
@@ -8,86 +10,122 @@ SCRIPT_DIR=$(cd `dirname $0`; pwd)
8source $SCRIPT_DIR/build-lib.sh
10source $SCRIPT_DIR/build-lib.sh
10#------------------------------------------------------------------------------
12#------------------------------------------------------------------------------
11−# GHC 8.10
13+# Prime version (GHC 8.10)
12#------------------------------------------------------------------------------
14#------------------------------------------------------------------------------
21+ --argstr compiler "$GHC_PRIME" \
23+ packcheck.sh cabal-v2 \
24+ GHCVER=$GHC_PRIME_VER \
25+ CABAL_DISABLE_DEPS=y \
14# build-all, Werror, test, inspection, fusion-plugin. Note, inspection
29# build-all, Werror, test, inspection, fusion-plugin. Note, inspection
15# requires fusion-plugin.
30# requires fusion-plugin.
17−basic () {
32+PERF_FLAGS="--flag inspection --flag fusion-plugin"
18 nix-shell \
35 nix-shell \
19− --argstr compiler "ghc8101" \
36+ --argstr compiler "$GHC_PRIME" \
20 --argstr c2nix "--flag inspection" \
37 --argstr c2nix "--flag inspection" \
24− CABAL_DISABLE_DEPS=y \
25− CABAL_CHECK_RELAX=y \
26− DISABLE_SDIST_BUILD=y \
27− CABAL_PROJECT=cabal.project.ci \
28− CABAL_BUILD_OPTIONS=\"--flag inspection --flag fusion-plugin\""
29−# chart deps do not build with ghc-8.10 on nix
31−# --argstr compiler "ghc8101" \
32−# --argstr c2nix "--flag dev" \
33−# --run "cabal build chart --flag dev"
35−# --argstr compiler "ghc8101" \
36−# --argstr c2nix "--flag inspection" \
38−# bin/bench.sh \
39+ bin/bench.sh --cabal-build-options \
39−# --quick \
40+ \"--project-file cabal.project.Werror $PERF_FLAGS\" --quick --raw;\
40−# --cabal-build-options \"--cabal-project cabal.project.ci --flag inspection --flag fusion-plugin\""
41+ bin/test.sh --cabal-build-options \
42+ \"--project-file cabal.project.Werror $PERF_FLAGS\";"
47+ --argstr compiler "$GHC_PRIME" \
49+ bin/test.sh --cabal-build-options \
50+ \"--project-file cabal.project.O0\""
43#------------------------------------------------------------------------------
53#------------------------------------------------------------------------------
44−# hlint
54+# Check warnings, docs
45#------------------------------------------------------------------------------
55#------------------------------------------------------------------------------
47# XXX avoid rebuilding if nothing has changed in the source
57# XXX avoid rebuilding if nothing has changed in the source
48# XXX run hlint only on changed files
58# XXX run hlint only on changed files
49−hlint () {
59+lint () {
50 packcheck cabal \
60 packcheck cabal \
51 HLINT_OPTIONS="lint --cpp-include=src --cpp-include=test" \
61 HLINT_OPTIONS="lint --cpp-include=src --cpp-include=test" \
52 HLINT_TARGETS="src test benchmark"
62 HLINT_TARGETS="src test benchmark"
67+ --argstr compiler "$GHC_PRIME" \
68+ --run "cabal build --project-file cabal.project.Werror-nocode all"
73+ --argstr compiler "$GHC_PRIME" \
74+ --run "cabal build --project-file cabal.project.Werror all"
77+ghc_prime_doctests () {
79+ --argstr compiler "$GHC_PRIME" \
80+ --run "cabal build --project-file cabal.project.doctest all"
81+ cabal-docspec --timeout 60
55#------------------------------------------------------------------------------
84#------------------------------------------------------------------------------
57#------------------------------------------------------------------------------
86#------------------------------------------------------------------------------
59−coverage () {
88+# To upload the results to coveralls.io using hpc-coveralls
89+# hpc-coveralls --repo-token="$REPO_TOKEN" --coverage-mode=StrictlyFullLines
91+ghc_prime_coverage () {
60 nix-shell \
92 nix-shell \
61− --argstr compiler "ghc8101" \
93+ --argstr compiler "$GHC_PRIME" \
62 --run "bin/test.sh --coverage"
94 --run "bin/test.sh --coverage"
65−# To upload the results to coveralls.io using hpc-coveralls
66−# hpc-coveralls --repo-token="$REPO_TOKEN" --coverage-mode=StrictlyFullLines
68#------------------------------------------------------------------------------
97#------------------------------------------------------------------------------
70#------------------------------------------------------------------------------
99#------------------------------------------------------------------------------
72−# chart builds from the nix cache for 8.8, 8.10 requires building
101+ghc_prime_dev () {
73−# XXX Use a separate build-dir for this
74−# build-all only, throw in most flags except fusion-plugin, inspection, opt
76 nix-shell \
102 nix-shell \
77− --argstr compiler "ghc883" \
103+ --argstr compiler "$GHC_PRIME" \
78− --argstr c2nix "--flag dev" \
104+ --run "bin/test.sh --cabal-build-options \"--flag dev\""
82− CABAL_DISABLE_DEPS=y \
83− CABAL_CHECK_RELAX=y \
84− DISABLE_SDIST_BUILD=y \
88− CABAL_BUILD_OPTIONS=\"--flag streamk --flag debug --flag use-c-malloc --flag dev\""
107+ghc_prime_c_malloc () {
109+ --argstr compiler "$GHC_PRIME" \
110+ --run "bin/test.sh --cabal-build-options \"--flag use-c-malloc\""
115+ --argstr compiler "$GHC_PRIME" \
116+ --run "bin/test.sh --cabal-build-options \"--flag debug\""
119+ghc_prime_streamk () {
121+ --argstr compiler "$GHC_PRIME" \
122+ --run "bin/test.sh --cabal-build-options \"--flag streamk\""
125+#------------------------------------------------------------------------------
127+#------------------------------------------------------------------------------
91# build-all only
129# build-all only
93# $2 8.8.3
131# $2 8.8.3
@@ -95,43 +133,72 @@ ghc () {
95 nix-shell \
133 nix-shell \
96 --argstr compiler "ghc$1" \
134 --argstr compiler "ghc$1" \
98− packcheck cabal-v2 \
136+ packcheck.sh cabal-v2 \
99 GHCVER=$2 \
137 GHCVER=$2 \
100 CABAL_DISABLE_DEPS=y \
138 CABAL_DISABLE_DEPS=y \
101 CABAL_CHECK_RELAX=y \
139 CABAL_CHECK_RELAX=y \
102 DISABLE_SDIST_BUILD=y \
140 DISABLE_SDIST_BUILD=y \
103 DISABLE_TEST=y \
141 DISABLE_TEST=y \
104− DISABLE_DOCS=y "
142+ DISABLE_DOCS=y"
107−ghc883 () { ghc 883 8.8.3; }
145+ghc901 () { ghc 901 9.0.1; }
108−ghc865 () { ghc 865 8.6.5; }
146+ghc884 () { ghc 884 8.8.4; }
109−ghc844 () { ghc 865 8.4.4; }
147+
148+#------------------------------------------------------------------------------
150+#------------------------------------------------------------------------------
154+ --argstr compiler "ghcHEAD" \
156+ packcheck.sh cabal-v2 \
158+ CABAL_CHECK_RELAX=y \
159+ DISABLE_SDIST_BUILD=y \
160+ CABAL_BUILD_OPTIONS=\"--allow-newer --project-file cabal.project.ghc-head"
111#------------------------------------------------------------------------------
163#------------------------------------------------------------------------------
113#------------------------------------------------------------------------------
165#------------------------------------------------------------------------------
115−#nix-shell \
167+ghcjs () {
116−# --argstr compiler "ghcjs" \
168+ export PATH=~/.local/bin:/opt/ghc/bin:/opt/ghcjs/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:$PATH
118−# packcheck cabal-v2 \
169+ packcheck.sh cabal-v2 \
119−# GHCVER=8.6.0 \
170+ GHCVER=8.4.0 \
120−# CABAL_DISABLE_DEPS=y \
121−# CABAL_CHECK_RELAX=y \
171+ CABAL_CHECK_RELAX=y \
122−# DISABLE_SDIST_BUILD=y \
172+ DISABLE_SDIST_BUILD=y \
123−# DISABLE_TEST=y \
173+ DISABLE_TEST=y \
124−# DISABLE_DOCS=y \
174+ DISABLE_DOCS=y \
125−# ENABLE_GHCJS=y " || exit 1
175+ ENABLE_GHCJS=y
127#-----------------------------------------------------------------------------
178#-----------------------------------------------------------------------------
128# Read command line
179# Read command line
129#-----------------------------------------------------------------------------
180#-----------------------------------------------------------------------------
131−ALL_TARGETS="all basic hlint coverage flags ghc883 ghc864 ghc844"
182+ALL_TARGETS="\
133print_targets () {
200print_targets () {
134− echo "Available targets: $ALL_TARGETS"
201+ echo "Available targets: all $ALL_TARGETS"
137print_help () {
204print_help () {
@@ -152,22 +219,31 @@ do
222+if test -z "$TARGETS"
229+ if test "$(has_item "$ALL_TARGETS" $i)" != "$i"
231+ echo "Unrecognized target: $i"
155if test "$(has_item "$TARGETS" help)" = "help"
236if test "$(has_item "$TARGETS" help)" = "help"
157 print_targets
238 print_targets
161−if test "$(has_item "$TARGETS" help)" = "all"
242+if test "$(has_item "$TARGETS" all)" = "all"
163 TARGETS="$ALL_TARGETS"
244 TARGETS="$ALL_TARGETS"
166−if test -z "$TARGETS"
171for i in $TARGETS
247for i in $TARGETS
173 $i || { echo "$i failed."; exit 1; }
249 $i || { echo "$i failed."; exit 1; }