[riot-notifications] [RIOT-OS/RIOT] Makefile.include: avoid recursive expansion of USEMODULE [backport 2021.01] (#15864)

Leandro Lanzieri notifications at github.com
Wed Jan 27 10:20:00 CET 2021


# Backport of #15835

### Contribution description
The desired behaviour of `DEFAULT_MODULES` during the dependency resolution is to be evaluated once before the dependency resolution occurs and once after that.

Currently `USEMODULE` is appended using `+=` which makes it recursively expanded. [1] That means that it keeps a reference to `DEFAULT_MODULES`, during the first iteration of the process. This breaks the intended behaviour. For example, if some dependency adds a module to `DEFAULT_MODULES` during the first iteration, on a following check `USEMODULE` is updated with that module instantly.

This can be fixed by making `USEMODULE` simply expanded before the dependency resolution starts.

**edit**
[1]: According to the [GNU make documentation](https://www.gnu.org/software/make/manual/make.html):
>For the append operator ‘+=’, the right-hand side is considered immediate if the variable was previously set as a simple variable (‘:=’ or ‘::=’), and deferred otherwise.

In the particular case of `USEMODULE` it turns it into a deferred assignment. 

### Testing procedure
- Green CI
- Although this is the correct behaviour, we should watch out for dependencies that may have been working because of this error

### Issues/PRs references
None
You can view, comment on, or merge this pull request online at:

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

-- Commit Summary --

  * makefile.include: avoid recursive expansion of USEMODULE
  * makefiles: allow boards and CPUs to define default modules
  * boards/e104-bt50xxa-tb: move default module to Makefile.default
  * cpu/msp430: move default module to Makefile.default
  * sys/Makefile.dep: default saul_init_devs to y when saul_default is used

-- File Changes --

    M Makefile.include (3)
    A boards/common/e104-bt50xxa-tb/Makefile.default (2)
    M boards/common/e104-bt50xxa-tb/Makefile.dep (2)
    A boards/e104-bt5010a-tb/Makefile.default (1)
    A boards/e104-bt5011a-tb/Makefile.default (1)
    A cpu/msp430_common/Makefile.default (2)
    M cpu/msp430_common/Makefile.dep (3)
    A cpu/msp430fxyz/Makefile.default (1)
    M makefiles/defaultmodules.inc.mk (6)
    M sys/Makefile.dep (1)

-- Patch Links --

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


More information about the notifications mailing list