Skip to content

Commit 36ac663

Browse files
authored
Merge pull request #1906 from geky/config-features
[build tools] Added support for cumulative attributes in configs directly
2 parents df0c855 + 2d38065 commit 36ac663

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

tools/config.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ def __init__(self, target, top_level_dirs = []):
176176
self.processed_configs = {}
177177
self.target = target if isinstance(target, str) else target.name
178178
self.target_labels = Target.get_target(self.target).get_labels()
179+
self.target_instance = Target.get_target(self.target)
179180

180181
# Add one or more configuration files
181182
def add_config_files(self, flist):
@@ -221,6 +222,27 @@ def _process_config_and_overrides(self, data, params, unit_name, unit_kind):
221222
for label, overrides in data.get("target_overrides", {}).items():
222223
# If the label is defined by the target or it has the special value "*", process the overrides
223224
if (label == '*') or (label in self.target_labels):
225+
# Parse out cumulative attributes
226+
for attr in Target._Target__cumulative_attributes:
227+
attrs = getattr(self.target_instance, attr)
228+
229+
if attr in overrides:
230+
del attrs[:]
231+
attrs.extend(overrides[attr])
232+
del overrides[attr]
233+
234+
if attr+'_add' in overrides:
235+
attrs.extend(overrides[attr+'_add'])
236+
del overrides[attr+'_add']
237+
238+
if attr+'_remove' in overrides:
239+
for a in overrides[attr+'_remove']:
240+
attrs.remove(a)
241+
del overrides[attr+'_remove']
242+
243+
setattr(self.target_instance, attr, attrs)
244+
245+
# Consider the others as overrides
224246
for name, v in overrides.items():
225247
# Get the full name of the parameter
226248
full_name = ConfigParameter.get_full_name(name, unit_name, unit_kind, label)

0 commit comments

Comments
 (0)