Skip to content

Commit 41daccf

Browse files
committed
[build tools] Fixed masked out configuration error
1 parent f45dc15 commit 41daccf

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

tools/build_api.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ def get_config(src_path, target, toolchain_name):
121121
resources += resources.features[feature]
122122

123123
prev_features = features
124+
config.validate_config()
124125

125126
cfg, macros = config.get_config_data()
126127
features = config.get_features()
@@ -229,6 +230,7 @@ def build_project(src_path, build_path, target, toolchain_name,
229230
resources += resources.features[feature]
230231

231232
prev_features = features
233+
config.validate_config()
232234

233235
# And add the configuration macros to the toolchain
234236
toolchain.add_macros(config.get_config_data_macros())
@@ -394,6 +396,7 @@ def build_library(src_paths, build_path, target, toolchain_name,
394396
resources += resources.features[feature]
395397

396398
prev_features = features
399+
config.validate_config()
397400

398401
# And add the configuration macros to the toolchain
399402
toolchain.add_macros(config.get_config_data_macros())

tools/config.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ def __init__(self, name, data, unit_name, unit_kind):
4040
self.value = data.get("value", None)
4141
self.required = data.get("required", False)
4242
self.macro_name = data.get("macro_name", "MBED_CONF_%s" % self.sanitize(self.name.upper()))
43+
self.config_errors = []
4344

4445
# Return the full (prefixed) name of a parameter.
4546
# If the parameter already has a prefix, check if it is valid
@@ -242,6 +243,7 @@ def add_features(self, features):
242243
# unit_name: the unit (library/application) that defines this parameter
243244
# unit_kind: the kind of the unit ("library" or "application")
244245
def _process_config_and_overrides(self, data, params, unit_name, unit_kind):
246+
self.config_errors = []
245247
self._process_config_parameters(data.get("config", {}), params, unit_name, unit_kind)
246248
for label, overrides in data.get("target_overrides", {}).items():
247249
# If the label is defined by the target or it has the special value "*", process the overrides
@@ -268,6 +270,9 @@ def _process_config_and_overrides(self, data, params, unit_name, unit_kind):
268270
full_name = ConfigParameter.get_full_name(name, unit_name, unit_kind, label)
269271
if full_name in params:
270272
params[full_name].set_value(v, unit_name, unit_kind, label)
273+
else:
274+
self.config_errors.append(ConfigException("Attempt to override undefined parameter '%s' in '%s'"
275+
% (full_name, ConfigParameter.get_display_name(unit_name, unit_kind, label))))
271276
return params
272277

273278
# Read and interpret configuration data defined by targets
@@ -376,4 +381,10 @@ def get_features(self):
376381
raise ConfigException("Feature '%s' is not a supported features" % feature)
377382

378383
return features
384+
385+
# Validate configuration settings. This either returns True or raises an exception
386+
def validate_config(self):
387+
if self.config_errors:
388+
raise self.config_errors[0]
389+
return True
379390

0 commit comments

Comments
 (0)