[riot-notifications] [RIOT-OS/RIOT] makefiles/buildtest: always execute 'buildtest' loop on host machine (#11857)

Gaëtan Harter notifications at github.com
Wed Jul 17 16:34:44 CEST 2019


### Contribution description 

This remove executing buildtest `for` loop in docker.

When building completely in docker, 'buildtest' would hide issues when
the host toolchain would be used when doing `make all` directly.

A side effect is also that now `BUILDTEST_MAKE_REDIRECT` would work when
doing `buildtest` with docker.
This also now removes passing `BOARDS` as it was added and needed only
for 'buildtest', and should work without the specific handling. https://github.com/RIOT-OS/RIOT/pull/11385


The side effect is that now one `docker` instance should be started per compilation but makes it more consistent with  doing `BUILD_IN_DOCKER=1 BOARD=board_name make` for each board.

### Testing procedure

I locally used `DOCKER="sudo docker"` but did not include it in the tests commands displayed below.


#### Normal buildtest uses

Running `buildtest` with `BUILD_IN_DOCKER=1` still works.

```
BUILD_IN_DOCKER=1 make --no-print-directory -C examples/hello-world/ buildtest
Building for acd52832 ... success.
Building for airfy-beacon ... success.
...
Building for wsn430-v1_3b ... success.
Building for wsn430-v1_4 ... success.
Building for yunjia-nrf51822 ... success.
Building for z1 ... success.
```

`BOARDS` can still be limited:

```
BUILD_IN_DOCKER=1 BOARDS='native samr21-xpro pic32-wifire' make --no-print-directory -C examples/hello-world/ buildtest
Building for native ... success.
Building for samr21-xpro ... success.
Building for pic32-wifire ... success.
```

When setting `BUILDTEST_MAKE_REDIRECT=` in the environment it will be taken into account

<details><summary><code>BUILDTEST_MAKE_REDIRECT= BUILD_IN_DOCKER=1 BOARDS='native samr21-xpro' make --no-print-directory -C examples/default</code></summary>

```
BUILDTEST_MAKE_REDIRECT= BUILD_IN_DOCKER=1 BOARDS='native samr21-xpro' make --no-print-directory -C examples/default
 buildtest
Building for native ... Launching build container using image "riot/riotbuild:latest".
sudo docker run --rm -t -u "$(id -u)" \
    -v '/usr/share/zoneinfo/Europe/Berlin:/etc/localtime:ro' -v '/home/harter/work/git/RIOT:/data/riotbuild/riotbase' -e 'RIOTBASE=/data/riotbuild/riotbase' -e 'CCACHE_BASEDIR=/data/riotbuild/riotbase' -e 'BUILD_DIR=/data/riotbuild/riotbase/build' -e 'RIOTPROJECT=/data/riotbuild/riotbase' -e 'RIOTCPU=/data/riotbuild/riotbase/cpu' -e 'RIOTBOARD=/data/riotbuild/riotbase/boards' -e 'RIOTMAKE=/data/riotbuild/riotbase/makefiles' -v /home/harter/.gitcache:/data/riotbuild/gitcache -e GIT_CACHE_DIR=/data/riotbuild/gitcache   \
    -e 'BOARD=native' -e 'RIOT_CI_BUILD=1' \
    -w '/data/riotbuild/riotbase/examples/default/' \
    'riot/riotbuild:latest' make all
Building application "default" for "native" with MCU "native".

   text    data     bss     dec     hex filename
  90210    1104   72024  163338   27e0a /data/riotbuild/riotbase/examples/default/bin/native/default.elf
success.
Building for samr21-xpro ... Launching build container using image "riot/riotbuild:latest".
sudo docker run --rm -t -u "$(id -u)" \
    -v '/usr/share/zoneinfo/Europe/Berlin:/etc/localtime:ro' -v '/home/harter/work/git/RIOT:/data/riotbuild/riotbase' -e 'RIOTBASE=/data/riotbuild/riotbase' -e 'CCACHE_BASEDIR=/data/riotbuild/riotbase' -e 'BUILD_DIR=/data/riotbuild/riotbase/build' -e 'RIOTPROJECT=/data/riotbuild/riotbase' -e 'RIOTCPU=/data/riotbuild/riotbase/cpu' -e 'RIOTBOARD=/data/riotbuild/riotbase/boards' -e 'RIOTMAKE=/data/riotbuild/riotbase/makefiles' -v /home/harter/.gitcache:/data/riotbuild/gitcache -e GIT_CACHE_DIR=/data/riotbuild/gitcache   \
    -e 'BOARD=samr21-xpro' -e 'RIOT_CI_BUILD=1' \
    -w '/data/riotbuild/riotbase/examples/default/' \
    'riot/riotbuild:latest' make all
Building application "default" for "samr21-xpro" with MCU "samd21".

   text    data     bss     dec     hex filename
  40856     508    6048   47412    b934 /data/riotbuild/riotbase/examples/default/bin/samr21-xpro/default.elf
success.
```
</details>


In master it was showing the `docker` command first to run `buildtest` now `all` is run with `docker` for each board.

<details><summary>Master: <code>BUILDTEST_MAKE_REDIRECT= BUILD_IN_DOCKER=1 BOARDS='native samr21-xpro' make --no-print-directory -C examples/hello-world/ buildtest</code></summary>

```
BUILDTEST_MAKE_REDIRECT= BUILD_IN_DOCKER=1 BOARDS='native samr21-xpro' make --no-print-directory -C examples/hello-world/ buildtest
Launching build container using image "riot/riotbuild:latest".
mkdir -p /home/harter/work/git/worktree/riot_master/build
sudo docker run --rm -t -u "$(id -u)" \
    -v '/usr/share/zoneinfo/Europe/Berlin:/etc/localtime:ro' -v '/home/harter/work/git/worktree/riot_master:/data/riotbuild/riotbase' -e 'RIOTBASE=/data/riotbuild/riotbase' -e 'CCACHE_BASEDIR=/data/riotbuild/riotbase' -e 'BUILD_DIR=/data/riotbuild/riotbase/build' -e 'RIOTPROJECT=/data/riotbuild/riotbase' -e 'RIOTCPU=/data/riotbuild/riotbase/cpu' -e 'RIOTBOARD=/data/riotbuild/riotbase/boards' -e 'RIOTMAKE=/data/riotbuild/riotbase/makefiles' -v /home/harter/.gitcache:/data/riotbuild/gitcache -e GIT_CACHE_DIR=/data/riotbuild/gitcache  -v /home/harter/work/git/RIOT/.git:/home/harter/work/git/RIOT/.git \
    -e 'BOARDS=native samr21-xpro' \
    -w '/data/riotbuild/riotbase/examples/hello-world/' \
    'riot/riotbuild:latest' make buildtest  
Building for native ... success.
Building for samr21-xpro ... success.
```
</details>

#### Removes errors hiding

Use a PATH where you do not have `arm-none-eabi-gcc`
```
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin arm-none-eabi-gcc

Command 'arm-none-eabi-gcc' not found, but can be installed with:

sudo apt install gcc-arm-none-eabi
```

It now correctly fails with `buildtest` with `BUILD_IN_DOCKER=1` as the host toolchain is used by that application.

<details><summary><code>PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin BUILD_IN_DOCKER=1 BUILDTEST_MAKE_REDIRECT='>/dev/null' make -C tests/mcuboot/ buildtest</code></summary>

```
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin BUILD_IN_DOCKER=1 BUILDTEST_MAKE_REDIRECT='>/dev/null' make -C tests/mcuboot/ buildtest
make: Entering directory '/home/harter/work/git/RIOT/tests/mcuboot'
Building for nrf52dk ... /bin/sh: 1: arm-none-eabi-gcc: not found
make[1]: *** [mcuboot] Error 127
failed!
/home/harter/work/git/RIOT/makefiles/buildtests.inc.mk:6: recipe for target 'buildtest' failed
make: *** [buildtest] Error 1
make: Leaving directory '/home/harter/work/git/RIOT/tests/mcuboot'
```
</details>

When it was hiding the error and correctly compiling in `master`

<details><summary><code>PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin BUILD_IN_DOCKER=1 make -C tests/mcuboot/ buildtest</code></summary>

```
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin BUILD_IN_DOCKER=1 make -C tests/mcuboot/ buildtest
make: Entering directory '/home/harter/work/git/worktree/riot_master/tests/mcuboot'
Launching build container using image "riot/riotbuild:latest".
mkdir -p /home/harter/work/git/worktree/riot_master/build
sudo docker run --rm -t -u "$(id -u)" \
    -v '/usr/share/zoneinfo/Europe/Berlin:/etc/localtime:ro' -v '/home/harter/work/git/worktree/riot_master:/data/riotbuild/riotbase' -e 'RIOTBASE=/data/riotbuild/riotbase' -e 'CCACHE_BASEDIR=/data/riotbuild/riotbase' -e 'BUILD_DIR=/data/riotbuild/riotbase/build' -e 'RIOTPROJECT=/data/riotbuild/riotbase' -e 'RIOTCPU=/data/riotbuild/riotbase/cpu' -e 'RIOTBOARD=/data/riotbuild/riotbase/boards' -e 'RIOTMAKE=/data/riotbuild/riotbase/makefiles' -v /home/harter/.gitcache:/data/riotbuild/gitcache -e GIT_CACHE_DIR=/data/riotbuild/gitcache  -v /home/harter/work/git/RIOT/.git:/home/harter/work/git/RIOT/.git \
     \
    -w '/data/riotbuild/riotbase/tests/mcuboot/' \
    'riot/riotbuild:latest' make buildtest  
Building for nrf52dk ... success.
make: Leaving directory '/home/harter/work/git/worktree/riot_master/tests/mcuboot'
```
</details>


### Issues/PRs references

Found that `BUILD_IN_DOCKER=1 make buildtest` was hiding expected errors during 2019.07-RC1 testing https://github.com/RIOT-OS/Release-Specs/issues/128#issuecomment-511388172

You can view, comment on, or merge this pull request online at:

  https://github.com/RIOT-OS/RIOT/pull/11857

-- Commit Summary --

  * makefiles/buildtest: always execute 'buildtest' loop on host machine

-- File Changes --

    M makefiles/buildtests.inc.mk (4)
    M makefiles/docker.inc.mk (2)

-- Patch Links --

https://github.com/RIOT-OS/RIOT/pull/11857.patch
https://github.com/RIOT-OS/RIOT/pull/11857.diff

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/RIOT-OS/RIOT/pull/11857
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20190717/b3d092d5/attachment-0001.html>


More information about the notifications mailing list