scons: Build the source filter factories dict in SourceFilter.
This is a little cleaner since it avoids an additional global variable.
Change-Id: I19d9a0afd12fdfeeda0b524bd71943d155ed5d7d
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/48375
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Hoa Nguyen <hoanguyen@ucdavis.edu>
Maintainer: Bobby R. Bruce <bbruce@ucdavis.edu>
diff --git a/src/SConscript b/src/SConscript
index 5afbb36..9dadd99 100644
--- a/src/SConscript
+++ b/src/SConscript
@@ -149,6 +149,7 @@
return tags
class SourceFilter(object):
+ factories = {}
def __init__(self, predicate):
self.predicate = predicate
@@ -160,10 +161,6 @@
return SourceFilter(lambda env, tags: self.predicate(env, tags) and
other.predicate(env, tags))
-def with_tags_that(predicate):
- '''Return a list of sources with tags that satisfy a predicate.'''
- return SourceFilter(predicate)
-
def with_any_tags(*tags):
'''Return a list of sources with any of the supplied tags.'''
return SourceFilter(lambda env, stags: \
@@ -186,16 +183,15 @@
'''Return a list of sources without the supplied tag.'''
return without_tags(*[tag])
-source_filter_factories = {
- 'with_tags_that': with_tags_that,
+SourceFilter.factories.update({
'with_any_tags': with_any_tags,
'with_all_tags': with_all_tags,
'with_tag': with_tag,
'without_tags': without_tags,
'without_tag': without_tag,
-}
+})
-Export(source_filter_factories)
+Export(SourceFilter.factories)
class SourceList(list):
def apply_filter(self, env, f):
@@ -204,7 +200,7 @@
return SourceList(filter(match, self))
def __getattr__(self, name):
- func = source_filter_factories.get(name, None)
+ func = SourceFilter.factories.get(name, None)
if not func:
raise AttributeError