@@ -36,7 +36,7 @@ class Exporter(object):
36
36
TEMPLATE_DIR = dirname (__file__ )
37
37
DOT_IN_RELATIVE_PATH = False
38
38
NAME = None
39
- TARGETS = None
39
+ TARGETS = set ()
40
40
TOOLCHAIN = None
41
41
42
42
@@ -178,19 +178,33 @@ def generate(self):
178
178
"""Generate an IDE/tool specific project file"""
179
179
raise NotImplemented ("Implement a generate function in Exporter child class" )
180
180
181
+ @classmethod
182
+ def is_target_supported (cls , target_name ):
183
+ """Query support for a particular target
181
184
182
- def filter_supported (compiler , whitelist ):
185
+ NOTE: override this method if your exporter does not provide a static list of targets
186
+
187
+ Positional Arguments:
188
+ target_name - the name of the target.
189
+ """
190
+ target = TARGET_MAP [target_name ]
191
+ return bool (set (target .resolution_order_names ).intersection (set (cls .TARGETS ))) \
192
+ and cls .TOOLCHAIN in target .supported_toolchains
193
+
194
+
195
+ @classmethod
196
+ def all_supported_targets (cls ):
197
+ return [t for t in TARGET_MAP .keys () if cls .is_target_supported (t )]
198
+
199
+
200
+ def apply_supported_whitelist (compiler , whitelist , target ):
183
201
"""Generate a list of supported targets for a given compiler and post-binary hook
184
202
white-list."""
185
- def supported_p (obj ):
186
- """Internal inner function used for filtering"""
187
- if compiler not in obj .supported_toolchains :
188
- return False
189
- if not hasattr (obj , "post_binary_hook" ):
190
- return True
191
- if obj .post_binary_hook ['function' ] in whitelist :
192
- return True
193
- else :
194
- return False
195
- return list (target for target , obj in TARGET_MAP .iteritems ()
196
- if supported_p (obj ))
203
+ if compiler not in target .supported_toolchains :
204
+ return False
205
+ if not hasattr (target , "post_binary_hook" ):
206
+ return True
207
+ if target .post_binary_hook ['function' ] in whitelist :
208
+ return True
209
+ else :
210
+ return False
0 commit comments