Last active
August 29, 2015 14:06
-
-
Save tranma/99ebac32b2fd9c2bdf0f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
REPOS=$(dirname $(pwd)) | |
echo_color() { | |
local t=$1 | |
INFO='\033[1;33m' | |
NC='\033[0m' | |
echo -e "${INFO}$t${NC}" | |
} | |
REPO=$1 # Repo to set up, default pwd | |
DEV_ROOT=$2 # Dir containing all repos, default dirname pwd | |
PROFILING=$3 | |
# Defaults | |
if [[ -z $REPO_DIR ]] | |
then | |
echo_color "Setting up $REPO_DIR..." | |
REPO_DIR=$(pwd) | |
fi | |
if [[ -z $DEV_DIR ]] | |
then | |
DEV_DIR=$(dirname $REPO_DIR) | |
echo_color "No dev root given, assuming $DEV_DIR..." | |
fi | |
if [[ -z $PROFILING ]] | |
then | |
CONFIGURE_CMD="cabal configure 2>&1" | |
INSTALL_CMD="cabal install --only-dependencies -j 2>&1" | |
else | |
CONFIGURE_CMD="cabal configure --enable-library-profiling --enable-executable-profiling 2>&1" | |
INSTALL_CMD="cabal install --only-dependencies -j -p 2>&1" | |
fi | |
INIT_CMD="rm -rf .cabal_sandbox; cabal sandbox init" | |
# Do it | |
cd $REPO_DIR | |
echo_color "Running: $INIT_CMD" | |
eval $INIT_CMD | |
echo_color "Running: $CONFIGURE_CMD" | |
eval $CONFIGURE_CMD > /dev/null | |
done=0 | |
echo_color "Finding dependencies..." | |
while [ $done == 0 ] ; do | |
echo_color "Running: $INSTALL_CMD" | |
uh=$(eval $INSTALL_CMD) | |
done=1 | |
for dependency in ${uh//,\n/ } ; do | |
echo_color "saw $dependency" | |
if [[ " ${REPOS[*]} " == *" $dependency"* ]]; | |
then | |
done=0 | |
dependency_repo=$DEV_DIR/$dependency | |
echo_color "Found local dependency $dependency_repo. Adding..." | |
cabal sandbox add-source $dependency_repo | |
echo_color "Running: $CONFIGURE_CMD" | |
eval $CONFIGURE_CMD > /dev/null | |
echo_color "Running: $INSTALL_CMD" | |
uh=$INSTALL_CMD | |
fi | |
done | |
done | |
echo_color "Builing..." | |
cabal build |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Runs
./setup.sh "" "" "true"