@@ -6,26 +6,57 @@
66# (2) Detect the platform and run tests applicable to the platform, (3)
77# add a test for windows/msys
88
9−SCRIPT_DIR=$(cd `dirname $0`; pwd)
10−source $SCRIPT_DIR/build-lib.sh
9+# TODO: tee the output to a log file
10+
11+SCRIPT_DIR=$(cd "$(dirname "$0")" || exit; pwd)
12+SCRIPT_NAME=$(basename "$0")
13+source "$SCRIPT_DIR/build-lib.sh"
1114
1215#------------------------------------------------------------------------------
1316# Prime version (GHC 8.10)
1417#------------------------------------------------------------------------------
1518
16−GHC_PRIME=ghc8104
19+# XXX take these from command line
20+GHC_PRIME_NIX="ghc8104"
1721GHC_PRIME_VER="8.10"
22+JOBS=1
1823
24+# Without cabal project file, it will not run any tests
1925ghc_prime_dist () {
2026 nix-shell \
21− --argstr compiler "$GHC_PRIME" \
27+ --argstr compiler "$GHC_PRIME_NIX" \
28+ --run "\
29+ packcheck.sh cabal-v2 \
30+ GHCVER=$GHC_PRIME_VER \
31+ CABAL_BUILD_OPTIONS="--jobs=$JOBS" \
32+ CABAL_DISABLE_DEPS=y \
33+ CABAL_CHECK_RELAX=y"
34+}
35+
36+# With cabal.project file, it will run the tests
37+ghc_prime_dist_tests () {
38+ nix-shell \
39+ --argstr compiler "$GHC_PRIME_NIX" \
2240 --run "\
2341 packcheck.sh cabal-v2 \
2442 GHCVER=$GHC_PRIME_VER \
43+ CABAL_BUILD_OPTIONS="--jobs=$JOBS" \
44+ CABAL_PROJECT=cabal.project \
2545 CABAL_DISABLE_DEPS=y \
2646 CABAL_CHECK_RELAX=y"
2747}
2848
49+# With stack.yaml file, it will run the tests
50+ghc_prime_dist_tests_stack () {
51+ nix-shell \
52+ --argstr compiler "$GHC_PRIME_NIX" \
53+ --run "\
54+ packcheck.sh stack \
55+ GHCVER=$GHC_PRIME_VER \
56+ STACK_BUILD_OPTIONS="--jobs $JOBS --system-ghc" \
57+ STACK_YAML=stack.yaml"
58+}
59+
2960# build-all, Werror, test, inspection, fusion-plugin. Note, inspection
3061# requires fusion-plugin.
3162
@@ -33,21 +64,22 @@ PERF_FLAGS="--flag inspection --flag fusion-plugin"
3364
3465ghc_prime_perf () {
3566 nix-shell \
36− --argstr compiler "$GHC_PRIME" \
67+ --argstr compiler "$GHC_PRIME_NIX" \
3768 --argstr c2nix "--flag inspection" \
3869 --run "\
39− bin/bench.sh --cabal-build-options \
40− \"--project-file cabal.project.Werror $PERF_FLAGS\" --quick --raw;\
4170 bin/test.sh --cabal-build-options \
42− \"--project-file cabal.project.Werror $PERF_FLAGS\";"
71+ \"--jobs=$JOBS --project-file cabal.project.Werror $PERF_FLAGS\";\
72+ bin/bench.sh --cabal-build-options \
73+ \"--jobs=$JOBS --project-file cabal.project.Werror $PERF_FLAGS\" \
74+ --quick --raw;"
4375}
4476
4577ghc_prime_O0 () {
4678 nix-shell \
47− --argstr compiler "$GHC_PRIME" \
79+ --argstr compiler "$GHC_PRIME_NIX" \
4880 --run "\
4981 bin/test.sh --cabal-build-options \
50− \"--project-file cabal.project.O0\""
82+ \"--jobs=$JOBS --project-file cabal.project.O0\""
5183}
5284
5385#------------------------------------------------------------------------------
@@ -62,22 +94,22 @@ lint () {
6294 HLINT_TARGETS="src test benchmark"
6395}
6496
65−Werror () {
97+werror () {
6698 nix-shell \
67− --argstr compiler "$GHC_PRIME" \
99+ --argstr compiler "$GHC_PRIME_NIX" \
68100 --run "cabal build --project-file cabal.project.Werror-nocode all"
69101}
70102
71−ghc_prime_werror () {
103+ghc_prime_Werror () {
72104 nix-shell \
73− --argstr compiler "$GHC_PRIME" \
74− --run "cabal build --project-file cabal.project.Werror all"
105+ --argstr compiler "$GHC_PRIME_NIX" \
106+ --run "cabal build --jobs=$JOBS --project-file cabal.project.Werror all"
75107}
76108
77109ghc_prime_doctests () {
78110 nix-shell \
79− --argstr compiler "$GHC_PRIME" \
80− --run "cabal build --project-file cabal.project.doctest all"
111+ --argstr compiler "$GHC_PRIME_NIX" \
112+ --run "cabal build --jobs=$JOBS --project-file cabal.project.doctest all"
81113 cabal-docspec --timeout 60
82114}
83115
@@ -90,36 +122,40 @@ ghc_prime_doctests () {
90122
91123ghc_prime_coverage () {
92124 nix-shell \
93− --argstr compiler "$GHC_PRIME" \
94− --run "bin/test.sh --coverage"
125+ --argstr compiler "$GHC_PRIME_NIX" \
126+ --run "bin/test.sh --cabal-build-options \"--jobs=$JOBS\" --coverage"
95127}
96128
97129#------------------------------------------------------------------------------
98130# Flags
99131#------------------------------------------------------------------------------
100132
101−ghc_prime_dev () {
133+ghc_prime_dev_perf () {
102134 nix-shell \
103− --argstr compiler "$GHC_PRIME" \
104− --run "bin/test.sh --cabal-build-options \"--flag dev\""
135+ --argstr compiler "$GHC_PRIME_NIX" \
136+ --run "\
137+ bin/test.sh --cabal-build-options \
138+ \"--jobs=$JOBS --flag dev\";\
139+ bin/bench.sh --cabal-build-options \
140+ \"--jobs=$JOBS --flag dev $PERF_FLAGS\" --quick --raw"
105141}
106142
107143ghc_prime_c_malloc () {
108144 nix-shell \
109− --argstr compiler "$GHC_PRIME" \
110− --run "bin/test.sh --cabal-build-options \"--flag use-c-malloc\""
145+ --argstr compiler "$GHC_PRIME_NIX" \
146+ --run "bin/test.sh --cabal-build-options \"--jobs=$JOBS --flag use-c-malloc\""
111147}
112148
113149ghc_prime_debug () {
114150 nix-shell \
115− --argstr compiler "$GHC_PRIME" \
116− --run "bin/test.sh --cabal-build-options \"--flag debug\""
151+ --argstr compiler "$GHC_PRIME_NIX" \
152+ --run "bin/test.sh --cabal-build-options \"--jobs=$JOBS --flag debug\""
117153}
118154
119155ghc_prime_streamk () {
120156 nix-shell \
121− --argstr compiler "$GHC_PRIME" \
122− --run "bin/test.sh --cabal-build-options \"--flag streamk\""
157+ --argstr compiler "$GHC_PRIME_NIX" \
158+ --run "bin/test.sh --cabal-build-options \"--jobs=$JOBS --flag streamk\""
123159}
124160
125161#------------------------------------------------------------------------------
@@ -135,6 +171,7 @@ ghc () {
135171 --run "\
136172 packcheck.sh cabal-v2 \
137173 GHCVER=$2 \
174+ CABAL_BUILD_OPTIONS="--jobs=$JOBS" \
138175 CABAL_DISABLE_DEPS=y \
139176 CABAL_CHECK_RELAX=y \
140177 DISABLE_SDIST_BUILD=y \
@@ -155,6 +192,7 @@ ghcHEAD () {
155192 --run "\
156193 packcheck.sh cabal-v2 \
157194 GHCVER=9.3 \
195+ CABAL_BUILD_OPTIONS="--jobs=$JOBS" \
158196 CABAL_CHECK_RELAX=y \
159197 DISABLE_SDIST_BUILD=y \
160198 CABAL_BUILD_OPTIONS=\"--allow-newer --project-file cabal.project.ghc-head"
@@ -168,6 +206,7 @@ ghcjs () {
168206 export PATH=~/.local/bin:/opt/ghc/bin:/opt/ghcjs/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:$PATH
169207 packcheck.sh cabal-v2 \
170208 GHCVER=8.4.0 \
209+ CABAL_BUILD_OPTIONS="--jobs=$JOBS" \
171210 CABAL_CHECK_RELAX=y \
172211 DISABLE_SDIST_BUILD=y \
173212 DISABLE_TEST=y \
@@ -179,54 +218,79 @@ ghcjs () {
179218# Read command line
180219#-----------------------------------------------------------------------------
181220
182−ALL_TARGETS="\
221+RELEASE_CI_TARGETS="\
183222ghc_prime_dist \
223+ghc_prime_dist_tests \
184224ghc_prime_perf \
185225ghc_prime_O0 \
186226ghc_prime_Werror \
187227ghc_prime_doctests \
188228ghc_prime_coverage \
189−ghc_prime_dev \
190229ghc_prime_c_malloc \
191230ghc_prime_debug \
192231ghc_prime_streamk \
193232ghc901 \
194233ghc884 \
195−ghcHEAD \
196234ghcjs \
197−lint \
198−Werror"
235+lint"
236+
237+# XXX We should include dev as well but it has some test and benchmark
238+# failures to be fixed.
239+ALL_TARGETS="\
240+$RELEASE_CI_TARGETS \
241+ghc_prime_dist_tests_stack \
242+ghc_prime_dev_perf \
243+ghcHEAD \
244+werror"
199245
200246print_targets () {
201247 echo "Available targets: all $ALL_TARGETS"
202248}
203249
204250print_help () {
205− echo "Usage: $0 --targets <space separated target names>"
251+ echo "Usage:"
252+ echo "$SCRIPT_NAME --targets <space separated target names>"
253+ echo "$SCRIPT_NAME --release"
206254 print_targets
207255 exit
208256}
209257
258+RELEASE_CI=0
259+
210260while test -n "$1"
211261do
212262 case $1 in
263+ # flags
213264 -h|--help|help) print_help ;;
265+ --release) RELEASE_CI=1; shift; break ;;
214266 # options with arguments
215267 --targets) shift; TARGETS=$1; shift ;;
216268 --) shift; break ;;
217− -*|--*) echo "Unknown flags: $*"; echo; print_help ;;
269+ -*) echo "Unknown flags: $*"; echo; print_help ;;
218270 *) break ;;
219271 esac
220272done
221273
222274if test -z "$TARGETS"
223275then
224− print_help
276+ if test "$RELEASE_CI" -eq 1
277+ then
278+ TARGETS="$RELEASE_CI_TARGETS"
279+ else
280+ echo "No targets specified"
281+ print_help
282+ fi
283+else
284+ if test "$RELEASE_CI" -eq 1
285+ then
286+ echo "--targets and --release cannot be used together"
287+ print_help
288+ fi
225289fi
226290
227−for i in "$TARGETS"
291+for i in $TARGETS
228292do
229− if test "$(has_item "$ALL_TARGETS" $i)" != "$i"
293+ if test "$(has_item "$ALL_TARGETS" "$i")" != "$i"
230294 then
231295 echo "Unrecognized target: $i"
232296 print_help
@@ -244,7 +308,16 @@ then
244308 TARGETS="$ALL_TARGETS"
245309fi
246310
311+# $1: msg
312+show_step () {
313+ echo
314+ echo "--------------------------------------------------"
315+ echo "$1"
316+ echo "--------------------------------------------------"
317+}
318+
247319for i in $TARGETS
248320do
321+ show_step "$i"
249322 $i || { echo "$i failed."; exit 1; }
250323done