@@ -140,7 +140,24 @@ def __getattr_helper(self, attrname):
140
140
v .extend (data [attrname + "_add" ])
141
141
# Do we have anything to remove ?
142
142
if data .has_key (attrname + "_remove" ):
143
- [v .remove (e ) for e in data [attrname + "_remove" ]]
143
+ # Macros can be defined either without a value (MACRO) or with a value (MACRO=10).
144
+ # When removing, we specify only the name of the macro, without the value. So we need
145
+ # to create a mapping between the macro name and its value. This will work for
146
+ # extra_labels and other type of arrays as well, since they fall into the "macros
147
+ # without a value" category (simple definitions without a value).
148
+ name_def_map = {}
149
+ for crtv in v :
150
+ if crtv .find ('=' ) != - 1 :
151
+ temp = crtv .split ('=' )
152
+ if len (temp ) != 2 :
153
+ raise ValueError ("Invalid macro definition '%s'" % crtv )
154
+ name_def_map [temp [0 ]] = crtv
155
+ else :
156
+ name_def_map [crtv ] = crtv
157
+ for e in data [attrname + "_remove" ]:
158
+ if not e in name_def_map :
159
+ raise ValueError ("Unable to remove '%s' in '%s.%s' since it doesn't exist" % (e , self .name , attrname ))
160
+ v .remove (name_def_map [e ])
144
161
return v
145
162
# Look for the attribute in the class and its parents, as defined by the resolution order
146
163
v = None
@@ -191,7 +208,7 @@ def init_hooks(self, hook, toolchain_name):
191
208
# A hook was found. The hook's name is in the format "classname.functionname"
192
209
temp = hook_data ["function" ].split ("." )
193
210
if len (temp ) != 2 :
194
- raise HookException ("Invalid format for hook '%s' in target '%s' (must be 'class_name.function_name')" % (hook_data ["function" ], self .name ))
211
+ raise HookError ("Invalid format for hook '%s' in target '%s' (must be 'class_name.function_name')" % (hook_data ["function" ], self .name ))
195
212
class_name , function_name = temp [0 ], temp [1 ]
196
213
# "class_name" must refer to a class in this file, so check if the class exists
197
214
mdata = self .get_module_data ()
0 commit comments