@@ -0,0 +1,207 @@
3+ >&2 echo -e "Error: $1"
8+function run_verbose() {
24+#------------------------------------------------------------------------------
26+#------------------------------------------------------------------------------
29+ if test -n "$RUNNING_TESTS"
36+ if test -n "$RUNNING_BENCHMARKS"
43+ if test -n "$RUNNING_DEVBUILD"
49+# A group consisting of all known individual targets
51+ { for i in $GROUP_TARGETS
55+ echo $INDIVIDUAL_TARGETS
59+# All groups including all_grp
60+all_target_groups () {
67+ echo "Individual targets:"
76+list_target_groups () {
77+ echo "Target groups:"
78+ for i in $(all_target_groups)
89+ if test -z "$TARGETS"
91+ echo $DEFAULT_TARGETS
93+ for i in $(echo $TARGETS)
96+ *_grp) eval "echo -n \$${i}" ;;
97+ *_cmp) eval "echo -n \$${i} $i" ;;
105+# We run the benchmarks in isolation in a separate process so that different
106+# benchmarks do not interfere with other. To enable that we need to pass the
107+# benchmark exe path to gauge as an argument. Unfortunately it cannot find its
108+# own path currently.
110+# The path is dependent on the architecture and cabal version.
114+cabal_target_prog () {
115+ local target_prog=`$WHICH_COMMAND $1 $2`
116+ if test -x "$target_prog"
135+ GHC_VERSION=$(ghc --numeric-version)
137+ CABAL_BUILD_OPTIONS=""
138+ CABAL_EXECUTABLE=cabal
140+ # Use branch specific builds if git-cabal is present in PATH
141+ BUILD_DIR=dist-newstyle
142+ if which git-cabal 2>/dev/null
144+ echo "Using git-cabal for branch specific builds"
145+ CABAL_EXECUTABLE=git-cabal
146+ BUILD_DIR=$(git-cabal show-builddir)
150+# XXX cabal issue "cabal v2-exec which" cannot find benchmark/test executables
154+# $3: command to find
155+cabal_which_builddir() {
156+ find $1 -type f -path "*${GHC_VERSION}/${2}*/$3" 2>/dev/null
160+# $2: command to find
162+ cabal_which_builddir $BUILD_DIR $1 $2
167+# $3: component prefix
172+ local component_prefix=$3
178+ COMPONENTS+="$package:$component_prefix:$c "
180+ run_verbose $build_prog $COMPONENTS || die "build failed"
186+ local package_name=$1
187+ local target_name=$2
188+ local target_exe=$target_name
190+ target_prog=$(cabal_target_prog $package_name $target_exe) || \
191+ die "Cannot find executable for target $target_name"
193+ echo "Running executable $target_name ..."
194+ TARGET_EXE_EXTRA_ARGS="$RTS_OPTIONS"
196+ run_verbose $target_prog $TARGET_EXE_EXTRA_ARGS $TARGET_EXE_ARGS \
197+ || die "Target exe failed"