mirror of
https://gitlab.com/ita1024/waf.git
synced 2024-11-22 09:57:15 +01:00
Match file extensions in the order of declaration
This commit is contained in:
parent
8f24d28534
commit
b13e98f1e4
@ -31,8 +31,11 @@ class task_gen(object):
|
||||
* The attribute 'idx' is a counter of task generators in the same path
|
||||
"""
|
||||
|
||||
mappings = {}
|
||||
mappings = Utils.ordered_iter_dict()
|
||||
"""Mappings are global file extension mappings, they are retrieved in the order of definition"""
|
||||
|
||||
prec = Utils.defaultdict(list)
|
||||
"""Dict holding the precedence rules for task generator methods"""
|
||||
|
||||
def __init__(self, *k, **kw):
|
||||
"""
|
||||
@ -64,6 +67,7 @@ class task_gen(object):
|
||||
self.mappings = {}
|
||||
"""
|
||||
List of mappings {extension -> function} for processing files by extension
|
||||
This is very rarely used, so we do not use an ordered dict here
|
||||
"""
|
||||
|
||||
self.features = []
|
||||
@ -235,6 +239,7 @@ class task_gen(object):
|
||||
:rtype: function
|
||||
"""
|
||||
name = node.name
|
||||
if self.mappings:
|
||||
for k in self.mappings:
|
||||
if name.endswith(k):
|
||||
return self.mappings[k]
|
||||
@ -337,7 +342,7 @@ def declare_chain(name='', rule=None, reentrant=None, color='BLUE',
|
||||
tsk = self.create_task(name, node)
|
||||
cnt = 0
|
||||
|
||||
keys = list(self.mappings.keys()) + list(self.__class__.mappings.keys())
|
||||
keys = set(self.mappings.keys()) | set(self.__class__.mappings.keys())
|
||||
for x in ext:
|
||||
k = node.change_ext(x, ext_in=_ext_in)
|
||||
tsk.outputs.append(k)
|
||||
@ -346,6 +351,7 @@ def declare_chain(name='', rule=None, reentrant=None, color='BLUE',
|
||||
if cnt < int(reentrant):
|
||||
self.source.append(k)
|
||||
else:
|
||||
# reinject downstream files into the build
|
||||
for y in keys: # ~ nfile * nextensions :-/
|
||||
if k.name.endswith(y):
|
||||
self.source.append(k)
|
||||
|
@ -102,6 +102,34 @@ except ImportError:
|
||||
value = self.default_factory()
|
||||
self[key] = value
|
||||
return value
|
||||
try:
|
||||
from collections import OrderedDico as ordered_iter_dict
|
||||
except ImportError:
|
||||
class ordered_iter_dict(dict):
|
||||
def __init__(self, *k, **kw):
|
||||
self.lst = []
|
||||
dict.__init__(self, *k, **kw)
|
||||
def clear(self):
|
||||
dict.clear(self)
|
||||
self.lst = []
|
||||
def __setitem__(self, key, value):
|
||||
dict.__setitem__(self, key, value)
|
||||
try:
|
||||
self.lst.remove(key)
|
||||
except ValueError:
|
||||
pass
|
||||
self.lst.append(key)
|
||||
def __delitem__(self, key):
|
||||
dict.__delitem__(self, key)
|
||||
try:
|
||||
self.lst.remove(key)
|
||||
except ValueError:
|
||||
pass
|
||||
def __iter__(self):
|
||||
for x in self.lst:
|
||||
yield x
|
||||
def keys(self):
|
||||
return self.lst
|
||||
|
||||
is_win32 = sys.platform in ('win32', 'cli')
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user