Files
buildroot/tools/brmake
Yann E. MORIN afdb545b28 tools: new tool to filter the output of make
Add brmake, a small script that redirects the build output log to a
file, keeping just Buildroot's own messages, with the date+time added
at the start of the line.

We need to unbuffer the output of make so that, when the script is
interrupted (SIGINT, ^C), there is no lingering output not yet digested
by the logger loop.

Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Cc: Maxime Hadjinlian <maxime.hadjinlian@gmail.com>
Cc: Arnout Vandecappelle <arnout@mind.be>
Cc: Ricardo Martincoski <ricardo.martincoski@gmail.com>
Cc: Samuel Martin <s.martin49@gmail.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
2017-07-01 17:56:11 +02:00

38 lines
881 B
Bash
Executable File

#!/bin/bash
# (C) 2016, "Yann E. MORIN" <yann.morin.1998@free.fr>
# License: WTFPL, https://spdx.org/licenses/WTFPL.html
main() {
local found ret start d h m mf
if ! which unbuffer >/dev/null 2>&1; then
printf "you need to install 'unbuffer' (from package expect or expect-dev)\n" >&2
exit 1
fi
start=${SECONDS}
( exec 2>&1; unbuffer make "${@}"; ) \
> >( while read line; do
printf "%(%Y-%m-%dT%H:%M:%S)T %s\n" -1 "${line}"
done \
|tee -a br.log \
|grep --colour=never -E '>>>'
)
ret=${?}
d=$((SECONDS-start))
printf "Done in "
h=$((d/3600))
d=$((d%3600))
[ ${h} -eq 0 ] || { printf "%dh " ${h}; mf="02"; }
m=$((d/60))
d=$((d%60))
[ ${m} -eq 0 ] || { printf "%${mf}dmin " ${m}; sf="02"; }
printf "%${sf}ds\n" ${d}
return ${ret}
}
main "${@}"