mirror of
https://git.busybox.net/buildroot.git
synced 2024-11-23 05:23:39 +08:00
8aad67f157
At the moment, it is difficult to combine brmake with docker-run. `docker-run brmake ...` doesn't work because our docker image doesn't have unbuffer. In addition, inside the container the timezone is UTC, but you probably want the timestamps added by brmake to be in local time. Therefore, it's better to have the call to docker-run nested inside brmake. Currently, brmake doesn't have any way to pass parameters, all of "$@" is passed unchanged to the `make` invocation. Thus, there is no established way to pass in the option whether or not to use docker. We choose to use an environment variable to pass in the option. The convention is that such a buildroot-specific environment variable should start with BR2_, so we choose BR2_DOCKER. Run make inside docker-run if the BR2_DOCKER environment variable is set. Update utils/readme.txt (the only existing documentation of brmake) with this information. Signed-off-by: Arnout Vandecappelle <arnout@mind.be> Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
49 lines
1.1 KiB
Bash
Executable File
49 lines
1.1 KiB
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 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}
|
|
|
|
if [ -n "$BR2_DOCKER" ]; then
|
|
docker=("${0%/*}/docker-run")
|
|
else
|
|
docker=()
|
|
fi
|
|
|
|
( exec 2>&1; unbuffer "${docker[@]}" make "${@}"; ) \
|
|
> >( while read -r 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" ${d}
|
|
|
|
if [ ${ret} -ne 0 ]; then
|
|
printf " (error code: %s)" ${ret}
|
|
fi
|
|
printf "\n"
|
|
|
|
return ${ret}
|
|
}
|
|
|
|
main "${@}"
|