@@ -68,6 +68,19 @@ class ConfigException(Exception):
68
68
errors"""
69
69
pass
70
70
71
+ class UndefinedParameter (ConfigException ):
72
+ def __init__ (self , param , name , kind , label ):
73
+ self .param = param
74
+ self .name = name
75
+ self .kind = kind
76
+ self .label = label
77
+
78
+ def __str__ (self ):
79
+ return "Attempt to override undefined parameter '{}' in '{}'" .format (
80
+ self .param ,
81
+ ConfigParameter .get_display_name (self .name , self .kind , self .label ),
82
+ )
83
+
71
84
class ConfigParameter (object ):
72
85
"""This class keeps information about a single configuration parameter"""
73
86
@@ -430,6 +443,7 @@ def __init__(self, tgt, top_level_dirs=None, app_config=None):
430
443
search for a configuration file).
431
444
"""
432
445
config_errors = []
446
+ self .config_errors = []
433
447
self .app_config_location = app_config
434
448
if self .app_config_location is None and top_level_dirs :
435
449
self .app_config_location = self .find_app_config (top_level_dirs )
@@ -571,7 +585,7 @@ def sectors(self):
571
585
raise ConfigException ("No sector info available" )
572
586
573
587
def _get_cmsis_part (self ):
574
- if not self .target . bootloader_supported :
588
+ if not getattr ( self .target , " bootloader_supported" , False ) :
575
589
raise ConfigException ("Bootloader not supported on this target." )
576
590
if not hasattr (self .target , "device_name" ):
577
591
raise ConfigException ("Bootloader not supported on this target: "
@@ -788,7 +802,6 @@ def _process_config_and_overrides(self, data, params, unit_name, unit_kind):
788
802
unit_name - the unit (library/application) that defines this parameter
789
803
unit_kind - the kind of the unit ("library" or "application")
790
804
"""
791
- self .config_errors = []
792
805
_process_config_parameters (data .get ("config" , {}), params , unit_name ,
793
806
unit_kind )
794
807
for label , overrides in data .get ("target_overrides" , {}).items ():
@@ -857,13 +870,8 @@ def _process_config_and_overrides(self, data, params, unit_name, unit_kind):
857
870
continue
858
871
else :
859
872
self .config_errors .append (
860
- ConfigException (
861
- "Attempt to override undefined parameter" +
862
- (" '%s' in '%s'"
863
- % (full_name ,
864
- ConfigParameter .get_display_name (unit_name ,
865
- unit_kind ,
866
- label )))))
873
+ UndefinedParameter (
874
+ full_name , unit_name , unit_kind , label ))
867
875
868
876
for cumulatives in self .cumulative_overrides .values ():
869
877
cumulatives .update_target (self .target )
@@ -911,10 +919,7 @@ def get_target_config_data(self):
911
919
continue
912
920
if (full_name not in params ) or \
913
921
(params [full_name ].defined_by [7 :] not in rel_names ):
914
- raise ConfigException (
915
- "Attempt to override undefined parameter '%s' in '%s'"
916
- % (name ,
917
- ConfigParameter .get_display_name (tname , "target" )))
922
+ raise UndefinedParameter (name , tname , "target" , "" )
918
923
# Otherwise update the value of the parameter
919
924
params [full_name ].set_value (val , tname , "target" )
920
925
return params
@@ -1050,8 +1055,13 @@ def validate_config(self):
1050
1055
1051
1056
Arguments: None
1052
1057
"""
1053
- if self .config_errors :
1054
- raise self .config_errors [0 ]
1058
+ params , _ = self .get_config_data ()
1059
+ for error in self .config_errors :
1060
+ if (isinstance (error , UndefinedParameter ) and
1061
+ error .param in params ):
1062
+ continue
1063
+ else :
1064
+ raise error
1055
1065
return True
1056
1066
1057
1067
@@ -1071,7 +1081,6 @@ def load_resources(self, resources):
1071
1081
"""
1072
1082
# Update configuration files until added features creates no changes
1073
1083
prev_features = set ()
1074
- self .validate_config ()
1075
1084
while True :
1076
1085
# Add/update the configuration with any .json files found while
1077
1086
# scanning
0 commit comments