Skip to content

Commit f2051b2

Browse files
committed
Modified config to explicitly update cumulative attributes in targets
Modified '_process_config_and_overrides' to update cumulative attributes based on cumulative overrides found during walking config files. This should remove most of the disparity between the config target cumulative overrides and cumulative attributes set in targets.json. These cumulative overrides are updated after the global target instantiation though, which may cause internal build tool state dependent on cumulative attributes to not correctly reflect all cumulative overrides.
1 parent 0fcb20e commit f2051b2

File tree

1 file changed

+14
-17
lines changed

1 file changed

+14
-17
lines changed

tools/config.py

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ def __init__(self, name, additions=set(), removals=set(), strict=False):
146146
self.strict = strict
147147

148148
# Add attr to the cumulative override
149-
def remove_cumulative_override(self, overrides):
149+
def remove_cumulative_overrides(self, overrides):
150150
for override in overrides:
151151
if override in self.additions:
152152
raise ConfigException("Configuration conflict. The %s %s both added and removed." % (self.name, override))
@@ -163,12 +163,13 @@ def add_cumulative_overrides(self, overrides):
163163

164164
# Enable strict set of cumulative overrides for the specified attr
165165
def strict_cumulative_overrides(self, overrides):
166-
self.remove_cumulative_override(self.additions - set(overrides))
167-
self.add_cumulative_override(overrides)
166+
self.remove_cumulative_overrides(self.additions - set(overrides))
167+
self.add_cumulative_overrides(overrides)
168168
self.strict = True
169169

170-
def get_cumulative_overrides(self, target):
171-
return set(getattr(target, self.name)) | self.additions - self.removals
170+
def update_target(self, target):
171+
setattr(target, self.name, list(
172+
set(getattr(target, self.name, [])) | self.additions - self.removals))
172173

173174

174175
# 'Config' implements the mbed configuration mechanism
@@ -290,6 +291,10 @@ def _process_config_and_overrides(self, data, params, unit_name, unit_kind):
290291
else:
291292
self.config_errors.append(ConfigException("Attempt to override undefined parameter '%s' in '%s'"
292293
% (full_name, ConfigParameter.get_display_name(unit_name, unit_kind, label))))
294+
295+
for cumulatives in self.cumulative_overrides.itervalues():
296+
cumulatives.update_target(Target.get_target(self.target))
297+
293298
return params
294299

295300
# Read and interpret configuration data defined by targets
@@ -400,20 +405,12 @@ def config_to_macros(config):
400405
def get_config_data_macros(self):
401406
return self.config_to_macros(self.get_config_data())
402407

403-
# Returns any cumulative overrides in the configuration data
404-
def get_cumulative_overrides(self, attr):
405-
if attr not in self.cumulative_overrides:
406-
return None
407-
408-
params, _ = self.get_config_data()
409-
self._check_required_parameters(params)
410-
411-
return self.cumulative_overrides[attr].get_cumulative_overrides(
412-
Target.get_target(self.target))
413-
414408
# Returns any features in the configuration data
415409
def get_features(self):
416-
features = self.get_cumulative_overrides('features')
410+
params, _ = self.get_config_data()
411+
self._check_required_parameters(params)
412+
self.cumulative_overrides['features'].update_target(Target.get_target(self.target))
413+
features = Target.get_target(self.target).features
417414

418415
for feature in features:
419416
if feature not in self.__allowed_features:

0 commit comments

Comments
 (0)