-function btr-help {
- btr-banner
- echo
- echo "Usage: $(basename $0) [-hyvqcC] [<options>]"
- echo
- echo " -h, --help Display this help"
- echo " -y, --yes Always assume yes"
- echo " -v, --verbose Be more verbose"
- echo " -q, --quiet Be more quiet"
- echo " -c, --clean Clean build"
- echo " -C, --vcsclean Clean repo/branch"
- echo
- echo " Options:"
- echo " -f, --config=<file> Read configuration from a file"
- echo " -s, --source=<rules> Use the specified source ruleset"
- echo " -b, --build=<rules> Use the specified build ruleset"
- echo " -r, --report=<rules> Use the specifued report ruleset"
- echo " -T, --test=<args> Provide test runner arguments"
- echo " -B, --branch=<branch> Checkout this branch"
- echo " -D, --directory=<directory> Use this directory as work root"
- echo " -S, --suffix=<suffix> Append suffix to the build name"
- echo
- echo " Rules format:"
- echo " type=argument e.g: git=git@github.com:m6w6/btr.git"
- echo " irc=irc://btr@chat.freenode.org/#btr"
- echo " mail=\"-c copy@to rcpt@to\""
- echo " notify-send=\"-u low\""
- echo
- echo " Note though, that some rules do not use any argument."
- echo
- echo " Rulesets:"
- for ruleset in source build report
- do
- printf " %10s: %s\n" $ruleset \
- "$(find "$BTR_LIBDIR/$ruleset" -name '*.mk' -exec basename {} .mk \; | sort | xargs)"
- done
- echo
- exit
-}
-export -f btr-help
-
-function btr-parseopts {
- local shortoptions="hvqycCf:T:B:D:S:s:b:r:"
- local longoptions="help,verbose,quiet,yes,clean,vcsclean,config:,test:,branch:,directory:,suffix:,source:,build:,report:"
- local options=$(getopt \
- --options "$shortoptions" \
- --longoptions "$longoptions" \
- -- "$@" \
- )
-
- if test $? -ne 0 ; then
- help
- fi
-
- eval set -- "$options"
-
- while test $# -gt 0
- do
- case "$1" in
- -h|--help)
- btr-help
- ;;
- -v|--verbose)
- BTR_QUIET=false
- BTR_VERBOSE=true
- ;;
- -q|--quiet)
- BTR_QUIET=true
- BTR_VERBOSE=false
- ;;
- -y|--yes)
- BTR_FORCEYES=true
- ;;
- -c|--clean)
- BTR_BUILD_CLEAN=true
- ;;
- -C|--vcsclean)
- BTR_SOURCE_CLEAN=true
- ;;
- ####
- -f|--config)
- source "$2"
- shift
- ;;
- ####
- -B|--branch)
- BTR_BRANCH="$2"
- shift
- ;;
- -D|--directory)
- BTR_RUNDIR="$2"
- shift
- ;;
- -S|--suffix)
- BTR_SUFFIX="$2"
- shift
- ;;
- -T|--test)
- BTR_TEST_ARGS="$2"
- shift
- ;;
- ####
- -s|--source)
- case "$2" in
- git*)
- test -z "$BTR_BRANCH" && BTR_BRANCH=master
- ;;
- svn*)
- test -z "$BTR_BRANCH" && BTR_BRANCH=trunk
- ;;
- cvs*)
- test -z "$BTR_BRANCH" && BTR_BRANCH=HEAD
- ;;
- esac
- BTR_SOURCE_RULES="$(cut -d= -f1 <<<$2)"
- BTR_SOURCE_ARGS="$(cut -s -d= -f2- <<<$2)"
- shift
- ;;
- -b|--build)
- BTR_BUILD_RULES="$(cut -d= -f1 <<<$2)"
- BTR_BUILD_ARGS="$(cut -s -d= -f2- <<<$2)"
- shift
- ;;
- -r|--report)
- BTR_REPORT_RULES="$(cut -d= -f1 <<<$2)"
- BTR_REPORT_ARGS="$(cut -s -d= -f2- <<<$2)"
- shift
- ;;
- ####
- --)
- # legacy
- if test "$2"
- then
- BTR_SOURCE_ARGS="$2"
- fi
- shift
- ;;
- esac
- shift
- done
-}
-export -f btr-parseopts
-
-function btr-setup {