Skip to content

Instantly share code, notes, and snippets.

@bitc
Created December 29, 2012 08:19
Show Gist options
  • Save bitc/4405418 to your computer and use it in GitHub Desktop.
Save bitc/4405418 to your computer and use it in GitHub Desktop.
A wrapper around the "cabal configure" command. It saves a hash of the configure arguments, and skips the actual configure if the arguments have not changed, thus shaving a few seconds off of your build time. Has support for hsenv. If you change your package database make sure to run "cabal-fast-configure --clean"
#!/bin/sh
set -e
if [ ! -f *.cabal ]
then
echo "You must run this script from the project root directory (where the .cabal file is)"
exit 2
fi
DIST_DIR=dist
if [ -n "$HSENV_NAME" ]
then
DIST_DIR="dist_$HSENV_NAME"
fi
if [ "$1" = "--clean" ]
then
rm -fv -- $DIST_DIR/setup-config.hash.*
exit 0
fi
configure_args_hash=`echo "$*" | sha256sum | cut -f 1 -d " "`
FINGERPRINT_FILE="$DIST_DIR/setup-config.hash.$configure_args_hash"
if [ ! -f "$FINGERPRINT_FILE" ]
then
cabal configure $*
sha256sum $DIST_DIR/setup-config > "$FINGERPRINT_FILE"
else
if ! sha256sum --quiet --check "$FINGERPRINT_FILE" > /dev/null 2>&1
then
cabal configure $*
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment