utils/brmake: add option to run in docker

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>
This commit is contained in:
Arnout Vandecappelle 2024-10-23 14:22:34 +02:00 committed by Thomas Petazzoni
parent 119fe4a3c0
commit 8aad67f157
2 changed files with 10 additions and 1 deletions

View File

@ -12,7 +12,13 @@ main() {
start=${SECONDS}
( exec 2>&1; unbuffer make "${@}"; ) \
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 \

View File

@ -7,6 +7,9 @@ brmake
front of each line, redirects all of the build output to a file
("'br.log' in the current directory), and just outputs the Buildroot
messages (those lines starting with >>>) on stdout.
To run this within a container using docker-run (see below), set
BR2_DOCKER=y in the environment, i.e. call it as
`BR2_DOCKER=y utils/brmake`.
Do not run this script for interactive configuration (e.g. menuconfig)
or on an unconfigured directory. The output is redirected so you will see
nothing.