@@ -143,12 +143,8 @@ class Config:
143
143
# Allowed keys in configuration dictionaries
144
144
# (targets can have any kind of keys, so this validation is not applicable to them)
145
145
__allowed_keys = {
146
- "library" : set (["name" , "config" , "target_overrides" , "macros" , "__config_path" ]
147
- + [a + '_add' for a in Target ._Target__cumulative_attributes ]
148
- + [a + '_remove' for a in Target ._Target__cumulative_attributes ]),
149
- "application" : set (["config" , "custom_targets" , "target_overrides" , "macros" , "__config_path" ]
150
- + [a + '_add' for a in Target ._Target__cumulative_attributes ]
151
- + [a + '_remove' for a in Target ._Target__cumulative_attributes ]),
146
+ "library" : set (["name" , "config" , "target_overrides" , "macros" , "__config_path" ]),
147
+ "application" : set (["config" , "custom_targets" , "target_overrides" , "macros" , "__config_path" ])
152
148
}
153
149
154
150
# The initialization arguments for Config are:
@@ -226,6 +222,22 @@ def _process_config_and_overrides(self, data, params, unit_name, unit_kind):
226
222
for label , overrides in data .get ("target_overrides" , {}).items ():
227
223
# If the label is defined by the target or it has the special value "*", process the overrides
228
224
if (label == '*' ) or (label in self .target_labels ):
225
+ # Parse out cumulative attributes
226
+ for attr in Target ._Target__cumulative_attributes :
227
+ attrs = getattr (self .target_instance , attr )
228
+
229
+ if attr + '_add' in overrides :
230
+ attrs .extend (overrides [attr + '_add' ])
231
+ del overrides [attr + '_add' ]
232
+
233
+ if attr + '_remove' in overrides :
234
+ for a in overrides [attr + '_remove' ]:
235
+ attrs .remove (a )
236
+ del overrides [attr + '_remove' ]
237
+
238
+ setattr (self .target_instance , attr , attrs )
239
+
240
+ # Consider the others as overrides
229
241
for name , v in overrides .items ():
230
242
# Get the full name of the parameter
231
243
full_name = ConfigParameter .get_full_name (name , unit_name , unit_kind , label )
@@ -277,20 +289,6 @@ def _process_macros(self, mlist, macros, unit_name, unit_kind):
277
289
raise ConfigException ("Macro '%s' defined in both '%s' and '%s' with incompatible values" % (m .macro_name , macros [m .macro_name ].defined_by , full_unit_name ))
278
290
macros [m .macro_name ] = m
279
291
280
- # Helper function: process target attributes in config files
281
- # data: dict of cumulative attributes
282
- # unit_name: the unit (library/application) that defines this macro
283
- # unit_kind: the kind of the unit ("library" or "application")
284
- def _process_attributes (self , data , unit_name , unit_kind ):
285
- for attr in Target ._Target__cumulative_attributes :
286
- attrs = getattr (self .target_instance , attr )
287
-
288
- attrs .extend (data .get (attr + '_add' , []))
289
- for a in data .get (attr + '_remove' , []):
290
- attrs .remove (a )
291
-
292
- setattr (self .target_instance , attr , attrs )
293
-
294
292
# Read and interpret configuration data defined by libs
295
293
# It is assumed that "add_config_files" above was already called and the library configuration data
296
294
# exists in self.lib_config_data
@@ -301,7 +299,6 @@ def get_lib_config_data(self):
301
299
if unknown_keys :
302
300
raise ConfigException ("Unknown key(s) '%s' in %s" % ("," .join (unknown_keys ), lib_name ))
303
301
all_params .update (self ._process_config_and_overrides (lib_data , {}, lib_name , "library" ))
304
- self ._process_attributes (lib_data , lib_name , "library" )
305
302
self ._process_macros (lib_data .get ("macros" , []), macros , lib_name , "library" )
306
303
return all_params , macros
307
304
@@ -313,8 +310,6 @@ def get_app_config_data(self, params, macros):
313
310
app_cfg = self .app_config_data
314
311
# The application can have a "config_parameters" and a "target_config_overrides" section just like a library
315
312
self ._process_config_and_overrides (app_cfg , params , "app" , "application" )
316
- # The application can also defined attributes
317
- self ._process_attributes (app_cfg , "app" , "application" )
318
313
# The application can also defined macros
319
314
self ._process_macros (app_cfg .get ("macros" , []), macros , "app" , "application" )
320
315
0 commit comments