@@ -46,7 +46,7 @@ set_benchmarks() {
4646find_report_prog() {
4747 local prog_name="chart"
4848 hash -r
49− local prog_path=$($STACK exec which $prog_name)
49+ local prog_path=$($WHICH_COMMAND $prog_name)
5050 if test -x "$prog_path"
5151 then
5252 echo $prog_path
@@ -58,14 +58,14 @@ find_report_prog() {
5858# $1: benchmark name (linear, nested, base)
5959build_report_prog() {
6060 local prog_name="chart"
61− local prog_path=$($STACK exec which $prog_name)
61+ local prog_path=$($WHICH_COMMAND $prog_name)
6262
6363 hash -r
6464 if test ! -x "$prog_path" -a "$BUILD_ONCE" = "0"
6565 then
6666 echo "Building bench-graph executables"
6767 BUILD_ONCE=1
68− $STACK build --flag "streamly:dev" || die "build failed"
68+ $BUILD_CHART_EXE || die "build failed"
6969 elif test ! -x "$prog_path"
7070 then
7171 return 1
@@ -93,9 +93,20 @@ build_report_progs() {
9393# Use this command to find the exe if this script fails with an error:
9494# find .stack-work/ -type f -name "benchmarks"
9595
96−find_bench_prog () {
96+stack_bench_prog () {
9797 local bench_name=$1
98− local bench_prog=`$STACK path --dist-dir`/build/$bench_name/$bench_name
98+ local bench_prog=`stack path --dist-dir`/build/$bench_name/$bench_name
99+ if test -x "$bench_prog"
100+ then
101+ echo $bench_prog
102+ else
103+ return 1
104+ fi
105+}
106+
107+cabal_bench_prog () {
108+ local bench_name=$1
109+ local bench_prog=`$WHICH_COMMAND $1`
99110 if test -x "$bench_prog"
100111 then
101112 echo $bench_prog
@@ -126,7 +137,7 @@ run_bench () {
126137 local bench_name=$1
127138 local output_file=$(bench_output_file $bench_name)
128139 local bench_prog
129− bench_prog=$(find_bench_prog $bench_name) || \
140+ bench_prog=$($GET_BENCH_PROG $bench_name) || \
130141 die "Cannot find benchmark executable for benchmark $bench_name"
131142
132143 mkdir -p `dirname $output_file`
@@ -162,14 +173,14 @@ run_benches_comparing() {
162173 echo "Checking out base commit [$BASE] for benchmarking"
163174 git checkout "$BASE" || die "Checkout of base commit [$BASE] failed"
164175
165− $STACK build $STACK_BUILD_FLAGS --bench --no-run-benchmarks || die "build failed"
176+ $BUILD_BENCH || die "build failed"
166177 run_benches "$bench_list"
167178
168179 echo "Checking out candidate commit [$CANDIDATE] for benchmarking"
169180 git checkout "$CANDIDATE" || \
170181 die "Checkout of candidate [$CANDIDATE] commit failed"
171182
172− $STACK build $STACK_BUILD_FLAGS --bench --no-run-benchmarks || die "build failed"
183+ $BUILD_BENCH || die "build failed"
173184 run_benches "$bench_list"
174185 # XXX reset back to the original commit
175186}
@@ -233,10 +244,22 @@ GRAPH=0
233244MEASURE=1
234245SPEED_OPTIONS="--quick --min-samples 10 --time-limit 1 --min-duration 0"
235246
236−STACK=stack
237247GAUGE_ARGS=
238−
239248BUILD_ONCE=0
249+USE_STACK=0
250+
251+if test "$USE_STACK" = "1"
252+then
253+ WHICH_COMMAND="stack exec which"
254+ BUILD_CHART_EXE="stack build --flag streamly:dev"
255+ GET_BENCH_PROG=stack_bench_prog
256+ BUILD_BENCH="stack build $STACK_BUILD_FLAGS --bench --no-run-benchmarks"
257+else
258+ WHICH_COMMAND="cabal v2-exec which"
259+ BUILD_CHART_EXE="cabal v2-build --flags dev chart"
260+ GET_BENCH_PROG=cabal_bench_prog
261+ BUILD_BENCH="cabal v2-build $CABAL_BUILD_FLAGS --enable-benchmarks"
262+fi
240263
241264#-----------------------------------------------------------------------------
242265# Read command line
@@ -271,6 +294,7 @@ set_benchmarks
271294if echo "$BENCHMARKS" | grep -q base
272295then
273296 STACK_BUILD_FLAGS="--flag streamly:dev"
297+ CABAL_BUILD_FLAGS="--flags dev"
274298fi
275299
276300#-----------------------------------------------------------------------------
@@ -287,7 +311,7 @@ build_report_progs "$BENCHMARKS"
287311
288312if test "$MEASURE" = "1"
289313then
290− $STACK build $STACK_BUILD_FLAGS --bench --no-run-benchmarks || die "build failed"
314+ $BUILD_BENCH || die "build failed"
291315 run_measurements "$BENCHMARKS"
292316fi
293317