@@ -40,6 +40,7 @@ def __init__(self, name, data, unit_name, unit_kind):
40
40
self .value = data .get ("value" , None )
41
41
self .required = data .get ("required" , False )
42
42
self .macro_name = data .get ("macro_name" , "MBED_CONF_%s" % self .sanitize (self .name .upper ()))
43
+ self .config_errors = []
43
44
44
45
# Return the full (prefixed) name of a parameter.
45
46
# If the parameter already has a prefix, check if it is valid
@@ -242,6 +243,7 @@ def add_features(self, features):
242
243
# unit_name: the unit (library/application) that defines this parameter
243
244
# unit_kind: the kind of the unit ("library" or "application")
244
245
def _process_config_and_overrides (self , data , params , unit_name , unit_kind ):
246
+ self .config_errors = []
245
247
self ._process_config_parameters (data .get ("config" , {}), params , unit_name , unit_kind )
246
248
for label , overrides in data .get ("target_overrides" , {}).items ():
247
249
# 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):
268
270
full_name = ConfigParameter .get_full_name (name , unit_name , unit_kind , label )
269
271
if full_name in params :
270
272
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 ))))
271
276
return params
272
277
273
278
# Read and interpret configuration data defined by targets
@@ -376,4 +381,10 @@ def get_features(self):
376
381
raise ConfigException ("Feature '%s' is not a supported features" % feature )
377
382
378
383
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
379
390
0 commit comments