mirror of https://github.com/ARMmbed/mbed-os.git
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.pull/2215/head
parent
0fcb20e8c1
commit
f2051b217a
|
@ -146,7 +146,7 @@ class ConfigCumulativeOverride:
|
||||||
self.strict = strict
|
self.strict = strict
|
||||||
|
|
||||||
# Add attr to the cumulative override
|
# Add attr to the cumulative override
|
||||||
def remove_cumulative_override(self, overrides):
|
def remove_cumulative_overrides(self, overrides):
|
||||||
for override in overrides:
|
for override in overrides:
|
||||||
if override in self.additions:
|
if override in self.additions:
|
||||||
raise ConfigException("Configuration conflict. The %s %s both added and removed." % (self.name, override))
|
raise ConfigException("Configuration conflict. The %s %s both added and removed." % (self.name, override))
|
||||||
|
@ -163,12 +163,13 @@ class ConfigCumulativeOverride:
|
||||||
|
|
||||||
# Enable strict set of cumulative overrides for the specified attr
|
# Enable strict set of cumulative overrides for the specified attr
|
||||||
def strict_cumulative_overrides(self, overrides):
|
def strict_cumulative_overrides(self, overrides):
|
||||||
self.remove_cumulative_override(self.additions - set(overrides))
|
self.remove_cumulative_overrides(self.additions - set(overrides))
|
||||||
self.add_cumulative_override(overrides)
|
self.add_cumulative_overrides(overrides)
|
||||||
self.strict = True
|
self.strict = True
|
||||||
|
|
||||||
def get_cumulative_overrides(self, target):
|
def update_target(self, target):
|
||||||
return set(getattr(target, self.name)) | self.additions - self.removals
|
setattr(target, self.name, list(
|
||||||
|
set(getattr(target, self.name, [])) | self.additions - self.removals))
|
||||||
|
|
||||||
|
|
||||||
# 'Config' implements the mbed configuration mechanism
|
# 'Config' implements the mbed configuration mechanism
|
||||||
|
@ -290,6 +291,10 @@ class Config:
|
||||||
else:
|
else:
|
||||||
self.config_errors.append(ConfigException("Attempt to override undefined parameter '%s' in '%s'"
|
self.config_errors.append(ConfigException("Attempt to override undefined parameter '%s' in '%s'"
|
||||||
% (full_name, ConfigParameter.get_display_name(unit_name, unit_kind, label))))
|
% (full_name, ConfigParameter.get_display_name(unit_name, unit_kind, label))))
|
||||||
|
|
||||||
|
for cumulatives in self.cumulative_overrides.itervalues():
|
||||||
|
cumulatives.update_target(Target.get_target(self.target))
|
||||||
|
|
||||||
return params
|
return params
|
||||||
|
|
||||||
# Read and interpret configuration data defined by targets
|
# Read and interpret configuration data defined by targets
|
||||||
|
@ -400,20 +405,12 @@ class Config:
|
||||||
def get_config_data_macros(self):
|
def get_config_data_macros(self):
|
||||||
return self.config_to_macros(self.get_config_data())
|
return self.config_to_macros(self.get_config_data())
|
||||||
|
|
||||||
# Returns any cumulative overrides in the configuration data
|
|
||||||
def get_cumulative_overrides(self, attr):
|
|
||||||
if attr not in self.cumulative_overrides:
|
|
||||||
return None
|
|
||||||
|
|
||||||
params, _ = self.get_config_data()
|
|
||||||
self._check_required_parameters(params)
|
|
||||||
|
|
||||||
return self.cumulative_overrides[attr].get_cumulative_overrides(
|
|
||||||
Target.get_target(self.target))
|
|
||||||
|
|
||||||
# Returns any features in the configuration data
|
# Returns any features in the configuration data
|
||||||
def get_features(self):
|
def get_features(self):
|
||||||
features = self.get_cumulative_overrides('features')
|
params, _ = self.get_config_data()
|
||||||
|
self._check_required_parameters(params)
|
||||||
|
self.cumulative_overrides['features'].update_target(Target.get_target(self.target))
|
||||||
|
features = Target.get_target(self.target).features
|
||||||
|
|
||||||
for feature in features:
|
for feature in features:
|
||||||
if feature not in self.__allowed_features:
|
if feature not in self.__allowed_features:
|
||||||
|
|
Loading…
Reference in New Issue