]> rtime.felk.cvut.cz Git - coffee/buildroot.git/blob - utils/brmake
libkcapi: depends on BR2_TOOLCHAIN_HAS_SYNC_4
[coffee/buildroot.git] / utils / brmake
1 #!/bin/bash
2 # (C) 2016, "Yann E. MORIN" <yann.morin.1998@free.fr>
3 # License: WTFPL, https://spdx.org/licenses/WTFPL.html
4
5 main() {
6     local found ret start d h m mf
7
8     if ! which unbuffer >/dev/null 2>&1; then
9         printf "you need to install 'unbuffer' (from package expect or expect-dev)\n" >&2
10         exit 1
11     fi
12
13     start=${SECONDS}
14
15     ( exec 2>&1; unbuffer make "${@}"; ) \
16     > >( while read line; do
17              printf "%(%Y-%m-%dT%H:%M:%S)T %s\n" -1 "${line}"
18          done \
19          |tee -a br.log \
20          |grep --colour=never -E '>>>'
21        )
22     ret=${?}
23
24     d=$((SECONDS-start))
25     printf "Done in "
26     h=$((d/3600))
27     d=$((d%3600))
28     [ ${h} -eq 0 ] || { printf "%dh " ${h}; mf="02"; }
29     m=$((d/60))
30     d=$((d%60))
31     [ ${m} -eq 0 ] || { printf "%${mf}dmin " ${m}; sf="02"; }
32     printf "%${sf}ds" ${d}
33
34     if [ ${ret} -ne 0 ]; then
35         printf "  (error code: %s)" ${ret}
36     fi
37     printf "\n"
38
39     return ${ret}
40 }
41
42 main "${@}"