[riot-notifications] [RIOT-OS/RIOT] make: handle emulator backend in Makefile.include (#15486)

Alexandre Abadie notifications at github.com
Fri Nov 20 15:58:28 CET 2020


<!--
The RIOT community cares a lot about code quality.
Therefore, before describing what your contribution is about, we would like
you to make sure that your modifications are compliant with the RIOT
coding conventions, see https://github.com/RIOT-OS/RIOT/wiki/Coding-conventions.
-->

### Contribution description

This PR contains several changes to improve the handling of multiple emulators in the build system. It introduces the RIOT_EMULATOR variable, similar to the RIOT_TERMINAL which will allow (in the future maybe) to select the emulator to use.

The inclusion of an emulator related variables is done from Makefile.include after the boards Makefile.include are parsed. This avoid having to include in each board that provides support for an emulator (as suggested in https://github.com/RIOT-OS/RIOT/pull/15459#discussion_r525507044).

By default renode is the default emulator, since it provides the widest hardware abstraction.

<!--
Put here the description of your contribution:
- describe which part(s) of RIOT is (are) involved
- if it's a bug fix, describe the bug that it solves and how it is solved
- you can also give more information to reviewers about how to test your changes
-->


### Testing procedure

- The emulator logic should still work with microbit (qemu) and cc2538dk (renode):

<details><summary>microbit</summary>

```
$ BUILD_IN_DOCKER=1 make BOARD=microbit -C examples/hello-world all emulate --no-print-directory 
Launching build container using image "riot/riotbuild:latest".
docker run --rm --tty --user $(id -u) -v '/usr/share/zoneinfo/Europe/Paris:/etc/localtime:ro' -v '/work/riot/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' -e 'RIOTCPU=/data/riotbuild/riotbase/cpu' -e 'RIOTBOARD=/data/riotbuild/riotbase/boards' -e 'RIOTMAKE=/data/riotbuild/riotbase/makefiles'      -e 'BOARD=microbit'  -w '/data/riotbuild/riotbase/examples/hello-world/' 'riot/riotbuild:latest' make 'BOARD=microbit'    all
Building application "hello-world" for "microbit" with MCU "nrf51".

"make" -C /data/riotbuild/riotbase/boards/microbit
"make" -C /data/riotbuild/riotbase/core
"make" -C /data/riotbuild/riotbase/cpu/nrf51
"make" -C /data/riotbuild/riotbase/cpu/cortexm_common
"make" -C /data/riotbuild/riotbase/cpu/cortexm_common/periph
"make" -C /data/riotbuild/riotbase/cpu/nrf51/periph
"make" -C /data/riotbuild/riotbase/cpu/nrf5x_common
"make" -C /data/riotbuild/riotbase/cpu/nrf5x_common/periph
"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/newlib_syscalls_default
"make" -C /data/riotbuild/riotbase/sys/stdio_uart
   text	   data	    bss	    dec	    hex	filename
   8116	    108	   2296	  10520	   2918	/data/riotbuild/riotbase/examples/hello-world/bin/microbit/hello-world.elf
qemu-system-arm -machine microbit -device loader,file=/work/riot/RIOT/examples/hello-world/bin/microbit/hello-world.elf -serial stdio -monitor telnet::45454,server,nowait -nographic
main(): This is RIOT! (Version: 2021.01-devel-1009-gba882-pr/make/emulator_enh)
Hello World!
You are running RIOT on a(n) microbit board.
This board features a(n) nrf51 MCU.
```

</details>

<details><summary>cc2538dk</summary>

```
$ BUILD_IN_DOCKER=1 make BOARD=cc2538dk -C examples/hello-world all emulate --no-print-directory 
Launching build container using image "riot/riotbuild:latest".
docker run --rm --tty --user $(id -u) -v '/usr/share/zoneinfo/Europe/Paris:/etc/localtime:ro' -v '/work/riot/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' -e 'RIOTCPU=/data/riotbuild/riotbase/cpu' -e 'RIOTBOARD=/data/riotbuild/riotbase/boards' -e 'RIOTMAKE=/data/riotbuild/riotbase/makefiles'      -e 'BOARD=cc2538dk'  -w '/data/riotbuild/riotbase/examples/hello-world/' 'riot/riotbuild:latest' make 'BOARD=cc2538dk'    all
Building application "hello-world" for "cc2538dk" with MCU "cc2538".

"make" -C /data/riotbuild/riotbase/boards/cc2538dk
"make" -C /data/riotbuild/riotbase/core
"make" -C /data/riotbuild/riotbase/cpu/cc2538
"make" -C /data/riotbuild/riotbase/cpu/cc2538/periph
"make" -C /data/riotbuild/riotbase/cpu/cortexm_common
"make" -C /data/riotbuild/riotbase/cpu/cortexm_common/periph
"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/newlib_syscalls_default
"make" -C /data/riotbuild/riotbase/sys/pm_layered
"make" -C /data/riotbuild/riotbase/sys/stdio_uart
   text	   data	    bss	    dec	    hex	filename
   8852	    112	   2296	  11260	   2bfc	/data/riotbuild/riotbase/examples/hello-world/bin/cc2538dk/hello-world.elf
/work/riot/RIOT/dist/tools/renode/run-renode.sh start
### Starting Renode ###
sh: 1: renode: not found
```

</details>

<!--
Details steps to test your contribution:
- which test/example to compile for which board and is there a 'test' command
- how to know that it was not working/available in master
- the expected success test output
-->


### Issues/PRs references

Will limit the changes required in #15459.

<!--
Examples: Fixes #1234. See also #5678. Depends on PR #9876.

Please use keywords (e.g., fixes, resolve) with the links to the issues you
resolved, this way they will be automatically closed when your pull request
is merged. See https://help.github.com/articles/closing-issues-using-keywords/.
-->

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

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

-- Commit Summary --

  * makefiles/tools/qemu: add common qemu makefile
  * boards/microbit: use common qemu include
  * Makefile.include: include emulator logic when emulate target is used
  * boards/cc2538dk: remove useless include of renode
  * boards/microbit: use qemu as default emulator

-- File Changes --

    M Makefile.include (7)
    M boards/cc2538dk/Makefile.include (3)
    M boards/microbit/Makefile.include (6)
    A makefiles/tools/qemu.inc.mk (9)

-- Patch Links --

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


More information about the notifications mailing list