[build tools] Fixed masked out configuration error

pull/1940/head
Christopher Haster 2016-06-15 07:10:32 -05:00
parent f45dc15aa8
commit 41daccf8d9
2 changed files with 14 additions and 0 deletions

View File

@ -121,6 +121,7 @@ def get_config(src_path, target, toolchain_name):
resources += resources.features[feature]
prev_features = features
config.validate_config()
cfg, macros = config.get_config_data()
features = config.get_features()
@ -229,6 +230,7 @@ def build_project(src_path, build_path, target, toolchain_name,
resources += resources.features[feature]
prev_features = features
config.validate_config()
# And add the configuration macros to the toolchain
toolchain.add_macros(config.get_config_data_macros())
@ -394,6 +396,7 @@ def build_library(src_paths, build_path, target, toolchain_name,
resources += resources.features[feature]
prev_features = features
config.validate_config()
# And add the configuration macros to the toolchain
toolchain.add_macros(config.get_config_data_macros())

View File

@ -40,6 +40,7 @@ class ConfigParameter:
self.value = data.get("value", None)
self.required = data.get("required", False)
self.macro_name = data.get("macro_name", "MBED_CONF_%s" % self.sanitize(self.name.upper()))
self.config_errors = []
# Return the full (prefixed) name of a parameter.
# If the parameter already has a prefix, check if it is valid
@ -242,6 +243,7 @@ class Config:
# unit_name: the unit (library/application) that defines this parameter
# unit_kind: the kind of the unit ("library" or "application")
def _process_config_and_overrides(self, data, params, unit_name, unit_kind):
self.config_errors = []
self._process_config_parameters(data.get("config", {}), params, unit_name, unit_kind)
for label, overrides in data.get("target_overrides", {}).items():
# If the label is defined by the target or it has the special value "*", process the overrides
@ -268,6 +270,9 @@ class Config:
full_name = ConfigParameter.get_full_name(name, unit_name, unit_kind, label)
if full_name in params:
params[full_name].set_value(v, unit_name, unit_kind, label)
else:
self.config_errors.append(ConfigException("Attempt to override undefined parameter '%s' in '%s'"
% (full_name, ConfigParameter.get_display_name(unit_name, unit_kind, label))))
return params
# Read and interpret configuration data defined by targets
@ -376,4 +381,10 @@ class Config:
raise ConfigException("Feature '%s' is not a supported features" % feature)
return features
# Validate configuration settings. This either returns True or raises an exception
def validate_config(self):
if self.config_errors:
raise self.config_errors[0]
return True