소스 검색

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>
Arnout Vandecappelle 9 달 전
부모
커밋
8aad67f157
2개의 변경된 파일10개의 추가작업 그리고 1개의 파일을 삭제
  1. 7 1
      utils/brmake
  2. 3 0
      utils/readme.txt

+ 7 - 1
utils/brmake

@@ -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 \

+ 3 - 0
utils/readme.txt

@@ -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.