[riot-notifications] [RIOT-OS/RIOT] makefiles/docker.inc.mk: add a 'docker_volume' function (#12241)

Gaëtan Harter notifications at github.com
Mon Sep 16 11:23:07 CEST 2019


### Contribution description

Refactor the '--volume' mounting handling.
This prepares for using a global 'DOCKER_VOLUME_OPTIONS'.

The goal is to have only one point where to change '--volume' mount options for https://github.com/RIOT-OS/RIOT/pull/12218

### Testing procedure

I am running a test procedure with external board, cpu, and modules.

Prepare external board and cpu, and run a test in 'tests/external_module_dirs':

```
mkdir -p /tmp/out
cp -r boards/  /tmp/out/
cp -r cpu  /tmp/out/
```

```
RIOTCPU=/tmp/out/cpu RIOTBOARD=/tmp/out/boards BUILD_IN_DOCKER=1 DOCKER="sudo docker" RIOT_VERSION=buildtest make --no-print-directory -C tests/external_module_dirs/
```

Difference by default between this PR and master is quotes being added:

``` diff
--- master      2019-09-16 11:11:24.388013256 +0200
+++ pr  2019-09-16 11:16:41.889835701 +0200
@@ -1,7 +1,7 @@
 RIOTCPU=/tmp/out/cpu RIOTBOARD=/tmp/out/boards BUILD_IN_DOCKER=1 DOCKER="sudo docker" RIOT_VERSION=buildtest make --no-print-directory -C tests/external_module_dirs/
 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' -v '/tmp/out/cpu:/data/riotbuild/riotcpu' -e 'RIOTCPU=/data/riotbuild/riotcpu' -v '/tmp/out/boards:/data/riotbuild/riotboard' -e 'RIOTBOARD=/data/riotbuild/riotboard' -e 'RIOTMAKE=/data/riotbuild/riotbase/makefiles' -v /home/harter/.gitcache:/data/riotbuild/gitcache -e GIT_CACHE_DIR=/data/riotbuild/gitcache   \
+    -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' -v '/tmp/out/cpu:/data/riotbuild/riotcpu' -e 'RIOTCPU=/data/riotbuild/riotcpu' -v '/tmp/out/boards:/data/riotbuild/riotboard' -e 'RIOTBOARD=/data/riotbuild/riotboard' -e 'RIOTMAKE=/data/riotbuild/riotbase/makefiles' -v '/home/harter/.gitcache:/data/riotbuild/gitcache' -e 'GIT_CACHE_DIR=/data/riotbuild/gitcache'   \
     -e 'RIOT_VERSION=buildtest' \
     -w '/data/riotbuild/riotbase/tests/external_module_dirs/' \
     'riot/riotbuild:latest' make   'EXTERNAL_MODULE_DIRS=/data/riotbuild/riotbase/tests/external_module_dirs/external_module'
```

<details><summary>With PR</summary>

```
RIOTCPU=/tmp/out/cpu RIOTBOARD=/tmp/out/boards BUILD_IN_DOCKER=1 DOCKER="sudo docker" RIOT_VERSION=buildtest make --no-print-directory -C tests/external_module_dirs/
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' -v '/tmp/out/cpu:/data/riotbuild/riotcpu' -e 'RIOTCPU=/data/riotbuild/riotcpu' -v '/tmp/out/boards:/data/riotbuild/riotboard' -e 'RIOTBOARD=/data/riotbuild/riotboard' -e 'RIOTMAKE=/data/riotbuild/riotbase/makefiles' -v '/home/harter/.gitcache:/data/riotbuild/gitcache' -e 'GIT_CACHE_DIR=/data/riotbuild/gitcache'   \
    -e 'RIOT_VERSION=buildtest' \
    -w '/data/riotbuild/riotbase/tests/external_module_dirs/' \
    'riot/riotbuild:latest' make   'EXTERNAL_MODULE_DIRS=/data/riotbuild/riotbase/tests/external_module_dirs/external_module'
Building application "external_module_dirs" for "native" with MCU "native".

"make" -C /data/riotbuild/riotbase/core
"make" -C /data/riotbuild/riotbase/drivers
"make" -C /data/riotbuild/riotbase/drivers/periph_common
"make" -C /data/riotbuild/riotbase/sys
"make" -C /data/riotbuild/riotbase/sys/auto_init
"make" -C /data/riotbuild/riotbase/sys/luid
"make" -C /data/riotbuild/riotbase/sys/random
"make" -C /data/riotbuild/riotbase/tests/external_module_dirs/external_module
"make" -C /data/riotbuild/riotboard/native
"make" -C /data/riotbuild/riotboard/native/drivers
"make" -C /data/riotbuild/riotcpu/native
"make" -C /data/riotbuild/riotcpu/native/periph
"make" -C /data/riotbuild/riotcpu/native/vfs
   text    data     bss     dec     hex filename
  21654     576   47660   69890   11102 /data/riotbuild/riotbase/tests/external_module_dirs/bin/native/external_module_dirs.elf
```
</details>

<details><summary>With master</summary>

```
RIOTCPU=/tmp/out/cpu RIOTBOARD=/tmp/out/boards BUILD_IN_DOCKER=1 DOCKER="sudo docker" make --no-print-directory -C tests/external_module_dirs/
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' -v '/tmp/out/cpu:/data/riotbuild/riotcpu' -e 'RIOTCPU=/data/riotbuild/riotcpu' -v '/tmp/out/boards:/data/riotbuild/riotboard' -e 'RIOTBOARD=/data/riotbuild/riotboard' -e 'RIOTMAKE=/data/riotbuild/riotbase/makefiles' -v /home/harter/.gitcache:/data/riotbuild/gitcache -e GIT_CACHE_DIR=/data/riotbuild/gitcache   \
     \
    -w '/data/riotbuild/riotbase/tests/external_module_dirs/' \
    'riot/riotbuild:latest' make   'EXTERNAL_MODULE_DIRS=/data/riotbuild/riotbase/tests/external_module_dirs/external_module'
Building application "external_module_dirs" for "native" with MCU "native".

"make" -C /data/riotbuild/riotbase/core
"make" -C /data/riotbuild/riotbase/drivers
"make" -C /data/riotbuild/riotbase/drivers/periph_common
"make" -C /data/riotbuild/riotbase/sys
"make" -C /data/riotbuild/riotbase/sys/auto_init
"make" -C /data/riotbuild/riotbase/sys/luid
"make" -C /data/riotbuild/riotbase/sys/random
"make" -C /data/riotbuild/riotbase/tests/external_module_dirs/external_module
"make" -C /data/riotbuild/riotboard/native
"make" -C /data/riotbuild/riotboard/native/drivers
"make" -C /data/riotbuild/riotcpu/native
"make" -C /data/riotbuild/riotcpu/native/periph
"make" -C /data/riotbuild/riotcpu/native/vfs
   text    data     bss     dec     hex filename
  21666     576   47660   69902   1110e /data/riotbuild/riotbase/tests/external_module_dirs/bin/native/external_module_dirs.elf
```
</details>


#### Support for mount options:

When setting 'DOCKER_VOLUME_OPTIONS=delegated', the value is used everywhere, except for 'localtime' where it stays 'ro'. (this is the current implementation)

<details><summary>PR with adding <code>DOCKER_VOLUME_OPTIONS</code></summary>

```
RIOTCPU=/tmp/out/cpu RIOTBOARD=/tmp/out/boards  DOCKER_VOLUME_OPTIONS=delegated BUILD_IN_DOCKER=1 DOCKER="sudo docker" RIOT_VERSION=buildtest make --no-print-directory -C tests/external_module_dirs/
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:delegated' -e 'RIOTBASE=/data/riotbuild/riotbase' -e 'CCACHE_BASEDIR=/data/riotbuild/riotbase' -e 'BUILD_DIR=/data/riotbuild/riotbase/build' -e 'RIOTPROJECT=/data/riotbuild/riotbase' -v '/tmp/out/cpu:/data/riotbuild/riotcpu:delegated' -e 'RIOTCPU=/data/riotbuild/riotcpu' -v '/tmp/out/boards:/data/riotbuild/riotboard:delegated' -e 'RIOTBOARD=/data/riotbuild/riotboard' -e 'RIOTMAKE=/data/riotbuild/riotbase/makefiles' -v '/home/harter/.gitcache:/data/riotbuild/gitcache:delegated' -e 'GIT_CACHE_DIR=/data/riotbuild/gitcache'   \
    -e 'RIOT_VERSION=buildtest' \
    -w '/data/riotbuild/riotbase/tests/external_module_dirs/' \
    'riot/riotbuild:latest' make   'EXTERNAL_MODULE_DIRS=/data/riotbuild/riotbase/tests/external_module_dirs/external_module'
Building application "external_module_dirs" for "native" with MCU "native".

"make" -C /data/riotbuild/riotbase/core
"make" -C /data/riotbuild/riotbase/drivers
"make" -C /data/riotbuild/riotbase/drivers/periph_common
"make" -C /data/riotbuild/riotbase/sys
"make" -C /data/riotbuild/riotbase/sys/auto_init
"make" -C /data/riotbuild/riotbase/sys/luid
"make" -C /data/riotbuild/riotbase/sys/random
"make" -C /data/riotbuild/riotbase/tests/external_module_dirs/external_module
"make" -C /data/riotbuild/riotboard/native
"make" -C /data/riotbuild/riotboard/native/drivers
"make" -C /data/riotbuild/riotcpu/native
"make" -C /data/riotbuild/riotcpu/native/periph
"make" -C /data/riotbuild/riotcpu/native/vfs
   text    data     bss     dec     hex filename
  21654     576   47660   69890   11102 /data/riotbuild/riotbase/tests/external_module_dirs/bin/native/external_module_dirs.elf
```
</details>

### Issues/PRs references

Refactoring prior to https://github.com/RIOT-OS/RIOT/pull/12218
You can view, comment on, or merge this pull request online at:

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

-- Commit Summary --

  * makefiles/docker.inc.mk: always use quotes around -e and -v options
  * makefiles/docker.inc.mk: add a 'docker_volume' function
  * makefiles/docker.inc.mk: use 'docker_volume' function

-- File Changes --

    M makefiles/docker.inc.mk (19)

-- Patch Links --

https://github.com/RIOT-OS/RIOT/pull/12241.patch
https://github.com/RIOT-OS/RIOT/pull/12241.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/12241
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20190916/34ece3de/attachment-0001.htm>


More information about the notifications mailing list