@@ -195,7 +195,7 @@ set_benchmarks() {
195195find_report_prog() {
196196 local prog_name="chart"
197197 hash -r
198− local prog_path=$($WHICH_COMMAND $prog_name)
198+ local prog_path=$($WHICH_COMMAND_REPORT $prog_name)
199199 if test -x "$prog_path"
200200 then
201201 echo $prog_path
@@ -206,7 +206,7 @@ find_report_prog() {
206206
207207build_report_prog() {
208208 local prog_name="chart"
209− local prog_path=$($WHICH_COMMAND $prog_name)
209+ local prog_path=$($WHICH_COMMAND_REPORT $prog_name)
210210
211211 hash -r
212212 if test ! -x "$prog_path" -a "$BUILD_ONCE" = "0"
@@ -437,8 +437,37 @@ CABAL_BUILD_FLAGS=""
437437
438438GHC_VERSION=$(ghc --numeric-version)
439439
440+CABAL_EXECUTABLE=cabal
441+
442+# Use branch specific builds if git-cabal is present in PATH
443+BUILD_DIR=dist-newstyle
444+if which git-cabal 2>/dev/null
445+then
446+ echo "Using git-cabal for branch specific builds"
447+ CABAL_EXECUTABLE=git-cabal
448+ BUILD_DIR=$(git-cabal show-builddir)
449+fi
450+
451+# $1: builddir
452+# $2: command to find
453+cabal_which_builddir() {
454+ find $1 -type f -path "*${GHC_VERSION}/streamly-benchmarks*/$2" 2>/dev/null
455+}
456+
440457cabal_which() {
441− find dist-newstyle -type f -path "*${GHC_VERSION}/streamly-benchmarks*/$1"
458+ cabal_which_builddir $BUILD_DIR $1
459+}
460+
461+# chart is expensive to build and usually not required to be rebuilt,
462+# use master branch as fallback
463+cabal_which_report() {
464+ local path=$(cabal_which $1)
465+ if test -z "$path"
466+ then
467+ cabal_which_builddir dist-newstyle $1
468+ else
469+ echo $path
470+ fi
442471}
443472
444473#-----------------------------------------------------------------------------
@@ -537,6 +566,7 @@ echo "Using benchmark suites [$BENCHMARKS]"
537566if test "$USE_STACK" = "1"
538567then
539568 WHICH_COMMAND="stack exec which"
569+ WHICH_COMMAND_REPORT="stack exec which"
540570 BUILD_CHART_EXE="stack build --flag streamly:dev"
541571 GET_BENCH_PROG=stack_bench_prog
542572 BUILD_BENCH="stack build $STACK_BUILD_FLAGS --bench --no-run-benchmarks"
@@ -544,9 +574,10 @@ else
544574 # XXX cabal issue "cabal v2-exec which" cannot find benchmark/test executables
545575 #WHICH_COMMAND="cabal v2-exec which"
546576 WHICH_COMMAND=cabal_which
547− BUILD_CHART_EXE="cabal v2-build --flags dev chart"
577+ WHICH_COMMAND_REPORT=cabal_which_report
578+ BUILD_CHART_EXE="$CABAL_EXECUTABLE v2-build --flags dev chart"
548579 GET_BENCH_PROG=cabal_bench_prog
549− BUILD_BENCH="cabal v2-build $CABAL_BUILD_FLAGS --enable-benchmarks"
580+ BUILD_BENCH="$CABAL_EXECUTABLE v2-build $CABAL_BUILD_FLAGS --enable-benchmarks"
550581fi
551582
552583#-----------------------------------------------------------------------------