Skip to content

Commit e996350

Browse files
rwalton-armPatater
authored andcommitted
config: Fix requires handling
We were previously replacing the list of "requires" if we happened to find a set of requires not in the app config. This meant occasionally some config macros would not be defined for baremetal apps depending on the order the config files were discovered and parsed. Now we always append to the list of requires, which is how it's supposed to work.
1 parent 89f60b3 commit e996350

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed

news/20210729080119.bugfix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix handling of baremetal "requires" configuration.

src/mbed_tools/build/_internal/config/config.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ def __setitem__(self, key: Hashable, item: Any) -> None:
2929
self._handle_overrides(item)
3030
elif key == MACROS_SECTION:
3131
self.data[MACROS_SECTION] = self.data.get(MACROS_SECTION, set()) | item
32+
elif key == REQUIRES_SECTION:
33+
self.data[REQUIRES_SECTION] = self.data.get(REQUIRES_SECTION, set()) | item
3234
else:
3335
super().__setitem__(key, item)
3436

@@ -71,6 +73,7 @@ def _update_config_section(self, config_settings: List[ConfigSetting]) -> None:
7173
CONFIG_SECTION = "config"
7274
MACROS_SECTION = "macros"
7375
OVERRIDES_SECTION = "overrides"
76+
REQUIRES_SECTION = "requires"
7477

7578

7679
def _apply_override(data: dict, override: Override) -> None:

tests/build/_internal/config/test_config.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,14 @@ def test_macros_are_appended_to(self):
111111

112112
assert conf["macros"] == {"A", "B"}
113113

114+
def test_requires_are_appended_to(self):
115+
conf = Config({"requires": {"A"}})
116+
117+
conf.update({"requires": {"B"}})
118+
conf.update({"requires": {"C"}})
119+
120+
assert conf["requires"] == {"A", "B", "C"}
121+
114122
def test_warns_and_skips_override_for_undefined_config_parameter(self, caplog):
115123
conf = Config()
116124
override_name = "this-does-not-exist"

0 commit comments

Comments
 (0)