#
#   .cdrc -- Configure environment for this project
#

_MMPRODUCT=`basename $PWD`
if [ "${PATH/$_MMPRODUCT\/build//}" = "${PATH}" ] ; then
    export CDPATH="$CDPATH:$PWD:$PWD/src"
    _MMOS=`uname | sed 's/CYGWIN.*/windows/;s/Darwin/macosx/' | tr '[A-Z]' '[a-z]'`
    _MMARCH=`uname -m | sed 's/i.86/x86/;s/x86_64/x64/;s/arm.*/arm/;s/mips.*/mips/'`
    export PATH="$PWD/build/${_MMOS}-${_MMARCH}-release/bin:$PWD/build/${_MMOS}-${_MMARCH}-debug/bin:paks/assist:$PATH"
    echo Switching to \"${_MMPRODUCT}\" profile
fi

if [ -z "${CI}" ] ; then
    if [ -f .profile ] ; then
        PROFILE=$(cat .profile)
    else
        PROFILE=prod
        echo "${PROFILE}" >.profile
        echo "Using default profile \"${PROFILE}\". Edit \".profile\" to change."
    fi
    export PROFILE
    export AWS_DEFAULT_REGION=us-east-1
    export AWS_PROFILE=ACCOUNT_NAME

    # export TF_VAR_profile=${PROFILE}
    export TF_VAR_profile=prod
    export TF_VAR_aws_profile=${AWS_PROFILE}
    export TF_VAR_region=${AWS_DEFAULT_REGION}
fi
