on master help sign in
Support branch specific builds using git-cabal
d6e7c28Harendra Kumar
bench.sh+36−5
@@ -195,7 +195,7 @@ set_benchmarks() {
195find_report_prog() {
195find_report_prog() {
196 local prog_name="chart"
196 local prog_name="chart"
197 hash -r
197 hash -r
198− local prog_path=$($WHICH_COMMAND $prog_name)
198+ local prog_path=$($WHICH_COMMAND_REPORT $prog_name)
199 if test -x "$prog_path"
199 if test -x "$prog_path"
200 then
200 then
201 echo $prog_path
201 echo $prog_path
@@ -206,7 +206,7 @@ find_report_prog() {
206
206
207build_report_prog() {
207build_report_prog() {
208 local prog_name="chart"
208 local prog_name="chart"
209− local prog_path=$($WHICH_COMMAND $prog_name)
209+ local prog_path=$($WHICH_COMMAND_REPORT $prog_name)
210
210
211 hash -r
211 hash -r
212 if test ! -x "$prog_path" -a "$BUILD_ONCE" = "0"
212 if test ! -x "$prog_path" -a "$BUILD_ONCE" = "0"
@@ -437,8 +437,37 @@ CABAL_BUILD_FLAGS=""
437
437
438GHC_VERSION=$(ghc --numeric-version)
438GHC_VERSION=$(ghc --numeric-version)
439
439
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+
440cabal_which() {
457cabal_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
442}
471}
443
472
444#-----------------------------------------------------------------------------
473#-----------------------------------------------------------------------------
@@ -537,6 +566,7 @@ echo "Using benchmark suites [$BENCHMARKS]"
537if test "$USE_STACK" = "1"
566if test "$USE_STACK" = "1"
538then
567then
539 WHICH_COMMAND="stack exec which"
568 WHICH_COMMAND="stack exec which"
569+ WHICH_COMMAND_REPORT="stack exec which"
540 BUILD_CHART_EXE="stack build --flag streamly:dev"
570 BUILD_CHART_EXE="stack build --flag streamly:dev"
541 GET_BENCH_PROG=stack_bench_prog
571 GET_BENCH_PROG=stack_bench_prog
542 BUILD_BENCH="stack build $STACK_BUILD_FLAGS --bench --no-run-benchmarks"
572 BUILD_BENCH="stack build $STACK_BUILD_FLAGS --bench --no-run-benchmarks"
@@ -544,9 +574,10 @@ else
544 # XXX cabal issue "cabal v2-exec which" cannot find benchmark/test executables
574 # XXX cabal issue "cabal v2-exec which" cannot find benchmark/test executables
545 #WHICH_COMMAND="cabal v2-exec which"
575 #WHICH_COMMAND="cabal v2-exec which"
546 WHICH_COMMAND=cabal_which
576 WHICH_COMMAND=cabal_which
577+ WHICH_COMMAND_REPORT=cabal_which_report
547− BUILD_CHART_EXE="cabal v2-build --flags dev chart"
578+ BUILD_CHART_EXE="$CABAL_EXECUTABLE v2-build --flags dev chart"
548 GET_BENCH_PROG=cabal_bench_prog
579 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"
550fi
581fi
551
582
552#-----------------------------------------------------------------------------
583#-----------------------------------------------------------------------------