6 echo "Usage: $(basename $0) [-hyvqcC] [<options>]"
8 echo " -h, --help Display this help"
9 echo " -y, --yes Always assume yes"
10 echo " -v, --verbose Be more verbose"
11 echo " -q, --quiet Be more quiet"
12 echo " -c, --clean Clean build"
13 echo " -C, --vcsclean Clean repo/branch"
16 echo " -f, --config=<file> Read configuration from a file"
17 echo " -s, --source=<rules> Use the specified source ruleset"
18 echo " -b, --build=<rules> Use the specified build ruleset"
19 echo " -r, --report=<rules> Use the specifued report ruleset"
20 echo " -T, --test=<args> Provide test runner arguments"
21 echo " -B, --branch=<branch> Checkout this branch"
22 echo " -D, --directory=<directory> Use this directory as work root"
23 echo " -S, --suffix=<suffix> Append suffix to the build name"
26 echo " type=argument e.g: git=git@github.com:m6w6/btr.git"
27 echo " irc=irc://btr@chat.freenode.org/#btr"
28 echo " mail=\"-c copy@to rcpt@to\""
29 echo " notify-send=\"-u low\""
31 echo " Note though, that some rules do not use any argument."
34 for ruleset
in source build report
36 printf " %10s: %s\n" $ruleset \
37 "$(find "$BTR_LIBDIR/$ruleset" -name '*.mk' -exec basename {} .mk \; | sort | xargs)"
42 echo " Clone PHP's git, use PHP-5.5 branch, build with php ruleset and"
43 echo " run the test suite with valgrind (-m) on a debug build and report"
44 echo " the results with a simple OSD notification:"
45 echo " $ btr -s git=git@php.net:php/php-src.git -B PHP-5.5 \\"
46 echo " -b \"php=--enable-debug\" -T-m -r notify-send"
47 echo " See also php.example.conf"
49 echo " Clone CURL's git (use master), build with GNU autotools"
50 echo " ruleset which runs 'make check' and mail the report to the"
51 echo " current user. Verbosely show all actions taken:"
52 echo " $ btr -v -s git=https://github.com/bagder/curl.git -b gnu -r mail"
53 echo " See also curl.example.conf"
59 function btr-parseopts
{
60 local shortoptions
="hvqycCf:T:B:D:S:s:b:r:"
61 local longoptions
="help,verbose,quiet,yes,clean,vcsclean,config:,test:,branch:,directory:,suffix:,source:,build:,report:"
62 local options
=$
(getopt \
63 --options "$shortoptions" \
64 --longoptions "$longoptions" \
68 if test $?
-ne 0 ; then
72 eval set -- "$options"
123 test -z "$BTR_BRANCH" && BTR_BRANCH
=master
126 test -z "$BTR_BRANCH" && BTR_BRANCH
=trunk
129 test -z "$BTR_BRANCH" && BTR_BRANCH
=HEAD
132 BTR_SOURCE_RULES
="$(cut -d= -f1 <<<$2)"
133 BTR_SOURCE_ARGS
="$(cut -s -d= -f2- <<<$2)"
137 BTR_BUILD_RULES
="$(cut -d= -f1 <<<$2)"
138 BTR_BUILD_ARGS
="$(cut -s -d= -f2- <<<$2)"
142 BTR_REPORT_RULES
="$(cut -d= -f1 <<<$2)"
143 BTR_REPORT_ARGS
="$(cut -s -d= -f2- <<<$2)"
159 export -f btr-parseopts
162 if test -z "$BTR_SOURCE_RULES" -o -z "$BTR_BUILD_RULES" -o -z "$BTR_REPORT_RULES"
167 btr-setup-verbosity true
170 export BTR_SOURCE_RULES BTR_BUILD_RULES BTR_REPORT_RULES
171 test -z "$BTR_SOURCE_ARGS" ||
export BTR_SOURCE_ARGS
172 test -z "$BTR_SOURCE_CLEAN" ||
export BTR_SOURCE_CLEAN
173 test -z "$BTR_BUILD_ARGS" ||
export BTR_BUILD_ARGS
174 test -z "$BTR_BUILD_CLEAN" ||
export BTR_BUILD_CLEAN
175 test -z "$BTR_TEST_ARGS" ||
export BTR_TEST_ARGS
176 test -z "$BTR_REPORT_ARGS" ||
export BTR_REPORT_ARGS
177 BTR_REPO
=$
(basename $
(sed -re 's~^.*[/:#]~~' <<<"$BTR_SOURCE_ARGS") .git
)
178 BTR_SAFE_BRANCH
=$
(tr ":/" "_" <<<$
(basename "$BTR_BRANCH"))
179 export BTR_REPO BTR_BRANCH BTR_SAFE_BRANCH
181 if test -z "$BTR_SUFFIX"
183 export BTR_BUILD
="$BTR_REPO@$BTR_SAFE_BRANCH"
185 export BTR_BUILD
="$BTR_REPO@$BTR_SAFE_BRANCH-$BTR_SUFFIX"
188 export BTR_REPO_DIR
="$BTR_REPO"
189 export BTR_BRANCH_DIR
="$BTR_BUILD/checkout"
190 export BTR_BUILD_DIR
="$BTR_BUILD/build"
191 export BTR_LOG_DIR
="$BTR_BUILD/log"
192 export BTR_CONFIG_REPORT
="$BTR_LOG_DIR/config@$DATE.log"
193 export BTR_BUILD_REPORT
="$BTR_LOG_DIR/build@$DATE.log"
194 export BTR_TEST_REPORT
="$BTR_LOG_DIR/test@$DATE.log"
195 export BTR_LAST_REPORT
=$
(basename $
(ls -t "$BTR_RUNDIR/$BTR_LOG_DIR/test@"* 2>/dev
/null |
head -n1) 2>/dev
/null
)
196 export BTR_REPORT
="$BTR_LOG_DIR/report@$DATE.log"
200 function btr-conf-dump
{
201 echo "BTR_QUIET='$BTR_QUIET'"
202 echo "BTR_VERBOSE='$BTR_VEROSE'"
203 echo "BTR_FORCEYES='$BTR_FORCEYES'"
204 echo "BTR_BRANCH='$BTR_BRANCH'"
205 echo "BTR_SUFFIX='$BTR_SUFFIX'"
206 echo "BTR_RUNDIR='$BTR_RUNDIR'"
207 echo "BTR_SOURCE_RULES='$BTR_SOURCE_RULES'"
208 test ${BTR_SOURCE_ARGS+defined} && echo "BTR_SOURCE_ARGS='$BTR_SOURCE_ARGS'"
209 test ${BTR_SOURC_CLEAN+defined} && echo "BTR_SOURCE_CLEAN='$BTR_SOURCE_CLEAN'"
210 echo "BTR_BUILD_RULES='$BTR_BUILD_RULES'"
211 test ${BTR_BUILD_ARGS+defined} && echo "BTR_BUILD_ARGS='$BTR_BUILD_ARGS'"
212 test ${BTR_BUILD_CLEAN+defined} && echo "BTR_BUILD_CLEAN='$BTR_BUILD_CLEAN'"
213 test ${BTR_TEST_ARGS+defined} && echo "BTR_TEST_ARGS='$BTR_TEST_ARGS'"
214 echo "BTR_REPORT_RULES='$BTR_REPORT_RULES'"
215 test ${BTR_REPORT_ARGS+defined} && echo "BTR_REPORT_ARGS='$BTR_REPORT_ARGS'"
217 export -f btr-conf-dump
219 function btr-conf-show
{
221 echo "# Configuration:"
223 echo "BTR_RUNDIR = $BTR_RUNDIR"
224 echo "BTR_BINDIR = $BTR_BINDIR"
225 echo "BTR_LIBDIR = $BTR_LIBDIR"
227 echo "BTR_SOURCE_RULES = $BTR_SOURCE_RULES"
228 echo "BTR_SOURCE_ARGS = $BTR_SOURCE_ARGS"
229 echo "BTR_SOURCE_CLEAN = $BTR_SOURCE_CLEAN"
230 echo "BTR_BUILD_RULES = $BTR_BUILD_RULES"
231 echo "BTR_BUILD_ARGS = $BTR_BUILD_ARGS"
232 echo "BTR_BUILD_CLEAN = $BTR_BUILD_CLEAN"
233 echo "BTR_TEST_ARGS = $BTR_TEST_ARGS"
234 echo "BTR_REPORT_RULES = $BTR_REPORT_RULES"
235 echo "BTR_REPORT_ARGS = $BTR_REPORT_ARGS"
236 echo "BTR_REPO = $BTR_REPO"
237 echo "BTR_BRANCH = $BTR_BRANCH"
238 echo "BTR_SAFE_BRANCH = $BTR_SAFE_BRANCH"
239 echo "BTR_BUILD = $BTR_BUILD"
241 echo "BTR_REPO_DIR = $BTR_REPO_DIR"
242 echo "BTR_BRANCH_DIR = $BTR_BRANCH_DIR"
243 echo "BTR_BUILD_DIR = $BTR_BUILD_DIR"
244 echo "BTR_LOG_DIR = $BTR_LOG_DIR"
245 echo "BTR_CONFIG_REPORT = $BTR_CONFIG_REPORT"
246 echo "BTR_BUILD_REPORT = $BTR_BUILD_REPORT"
247 echo "BTR_TEST_REPORT = $BTR_TEST_REPORT"
248 echo "BTR_LAST_REPORT = $BTR_LAST_REPORT"
251 export -f btr-conf-show
255 make -e $BTR_SILENT_FLAG -C $BTR_RUNDIR -f $BTR_LIBDIR/source
/$BTR_SOURCE_RULES.mk
256 make -e $BTR_SILENT_FLAG -C $BTR_RUNDIR -f $BTR_LIBDIR/build
/$BTR_BUILD_RULES.mk
257 make -e $BTR_SILENT_FLAG -C $BTR_RUNDIR -f $BTR_LIBDIR/report
/$BTR_REPORT_RULES.mk