-
Notifications
You must be signed in to change notification settings - Fork 0
/
b
executable file
·93 lines (83 loc) · 3 KB
/
b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#!/usr/bin/env bash
set -e
# DESCRIPTION
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# This script builds the project in a way that is convenient for developers.
# It passes the right flags into right places, builds the project with --fast,
# tidies up and highlights error messages in GHC output.
# USAGE
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# ./b build whole project with all targets
# ./b -c do stack clean
# ./b -t build and run tests
# ./b -b build and run benchmarks
# ./b --nix use nix to build package
args=''
test=false
bench=false
with_nix=false
clean=false
for var in "$@"
do
# -t = run tests
if [[ $var == "-t" ]]; then
test=true
# -b = run benchmarks
elif [[ $var == "-b" ]]; then
bench=true
elif [[ $var == "--nix" ]]; then
with_nix=true
# -c = clean
elif [[ $var == "-c" ]]; then
clean=true
else
args="$args $var"
fi
done
# Cleaning project
if [[ $clean == true ]]; then
echo "Cleaning project..."
stack clean
exit
fi
if [[ $no_nix == true ]]; then
args="$args --nix"
fi
stack build $args \
--ghc-options="+RTS -A256m -n2m -RTS" \
--test \
--no-run-tests \
--no-haddock-deps \
--bench \
--no-run-benchmarks \
--jobs=4 \
--dependencies-only
stack build $args \
--fast \
--ghc-options="+RTS -A256m -n2m -RTS" \
--test \
--no-run-tests \
--no-haddock-deps \
--bench \
--no-run-benchmarks \
--jobs=4 2>&1 | perl -pe '$|++; s/(.*) Compiling\s([^\s]+)\s+\(\s+([^\/]+).*/\1 \2/p' | grep -E --color "(^.*warning.*$|^.*error.*$|^ .*$)|"
if [[ $test == true ]]; then
stack build $args \
--fast \
--ghc-options="+RTS -A256m -n2m -RTS" \
--test \
--no-haddock-deps \
--bench \
--no-run-benchmarks \
--jobs=4
fi
if [[ $bench == true ]]; then
stack build $args \
--fast \
--ghc-options="+RTS -A256m -n2m -RTS" \
--test \
--no-run-tests \
--no-haddock-deps \
--bench \
--jobs=4
fi