@@ -35,9 +35,8 @@ class ConfigParameter:
35
35
def __init__ (self , name , data , unit_name , unit_kind ):
36
36
self .name = self .get_full_name (name , unit_name , unit_kind , allow_prefix = False )
37
37
self .defined_by = self .get_display_name (unit_name , unit_kind )
38
- self .set_by = self . defined_by
38
+ self .set_value ( data . get ( "value" , None ), unit_name , unit_kind )
39
39
self .help_text = data .get ("help" , None )
40
- self .value = data .get ("value" , None )
41
40
self .required = data .get ("required" , False )
42
41
self .macro_name = data .get ("macro_name" , "MBED_CONF_%s" % self .sanitize (self .name .upper ()))
43
42
self .config_errors = []
@@ -93,13 +92,14 @@ def get_display_name(unit_name, unit_kind, label = None):
93
92
def sanitize (name ):
94
93
return name .replace ('.' , '_' ).replace ('-' , '_' )
95
94
96
- # Sets a value for this parameter, remember the place where it was set
95
+ # Sets a value for this parameter, remember the place where it was set.
96
+ # If the value is a boolean, it is converted to 1 (for True) or to 0 (for False).
97
97
# value: the value of the parameter
98
98
# unit_name: the unit (target/library/application) that defines this parameter
99
99
# unit_ kind: the kind of the unit ("target", "library" or "application")
100
100
# label: the name of the label in the 'target_config_overrides' section (optional)
101
101
def set_value (self , value , unit_name , unit_kind , label = None ):
102
- self .value = value
102
+ self .value = int ( value ) if isinstance ( value , bool ) else value
103
103
self .set_by = self .get_display_name (unit_name , unit_kind , label )
104
104
105
105
# Return the string representation of this configuration parameter
@@ -233,7 +233,7 @@ def remove_features(self, features):
233
233
# Remove features from the available features
234
234
def add_features (self , features ):
235
235
for feature in features :
236
- if (feature in self .removed_features
236
+ if (feature in self .removed_features
237
237
or (self .removed_unecessary_features and feature not in self .added_features )):
238
238
raise ConfigException ("Configuration conflict. Feature %s both added and removed." % feature )
239
239
@@ -273,7 +273,7 @@ def _process_config_and_overrides(self, data, params, unit_name, unit_kind):
273
273
if full_name in params :
274
274
params [full_name ].set_value (v , unit_name , unit_kind , label )
275
275
else :
276
- self .config_errors .append (ConfigException ("Attempt to override undefined parameter '%s' in '%s'"
276
+ self .config_errors .append (ConfigException ("Attempt to override undefined parameter '%s' in '%s'"
277
277
% (full_name , ConfigParameter .get_display_name (unit_name , unit_kind , label ))))
278
278
return params
279
279
@@ -396,7 +396,7 @@ def validate_config(self):
396
396
raise self .config_errors [0 ]
397
397
return True
398
398
399
-
399
+
400
400
# Loads configuration data from resources. Also expands resources based on defined features settings
401
401
def load_resources (self , resources ):
402
402
# Update configuration files until added features creates no changes
@@ -418,7 +418,7 @@ def load_resources(self, resources):
418
418
self .validate_config ()
419
419
420
420
return resources
421
-
421
+
422
422
423
423
# Return the configuration data converted to the content of a C header file,
424
424
# meant to be included to a C/C++ file. The content is returned as a string.
0 commit comments