3 # WARNING! Do not edit! https://waf.io/book/index.html#_obtaining_the_waf_file
7 # Thomas Nagy, 2011 (ita)
10 A make-like way of executing the build, following the relationships between inputs/outputs
12 This algorithm will lead to slower builds, will not be as flexible as "waf build", but
13 it might be useful for building data files (?)
15 It is likely to break in the following cases:
16 - files are created dynamically (no inputs or outputs)
18 - building two files from different groups
22 from waflib import Options, Task
23 from waflib.Build import BuildContext
25 class MakeContext(BuildContext):
26 '''executes tasks in a step-by-step manner, following dependencies between inputs/outputs'''
30 def __init__(self, **kw):
31 super(MakeContext, self).__init__(**kw)
32 self.files = Options.options.files
34 def get_build_iterator(self):
37 yield super(MakeContext, self).get_build_iterator()
43 except AttributeError:
52 for pat in self.files.split(','):
53 matcher = self.get_matcher(pat)
55 if isinstance(tg, Task.Task):
63 for node in tsk.inputs:
65 uses[node].append(tsk)
69 if matcher(node, output=False):
73 for node in tsk.outputs:
75 provides[node].append(tsk)
77 provides[node] = [tsk]
79 if matcher(node, output=True):
85 # so we have the tasks that we need to process, the list of all tasks,
86 # the map of the tasks providing nodes, and the map of tasks using nodes
89 # if there are no tasks matching, return everything in the current group
92 # this is like a big filter...
100 for node in tsk.inputs:
104 tosee |= set(provides.get(node, []))
106 result = list(result)
108 Task.set_file_constraints(result)
109 Task.set_precedence_constraints(result)
115 def get_matcher(self, pat):
116 # this returns a function
119 if pat.startswith('in:'):
121 pat = pat.replace('in:', '')
122 elif pat.startswith('out:'):
124 pat = pat.replace('out:', '')
126 anode = self.root.find_node(pat)
129 if not pat.startswith('^'):
131 if not pat.endswith('$'):
133 pattern = re.compile(pat)
135 def match(node, output):
136 if output and not out:
138 if not output and not inn:
144 return pattern.match(node.abspath())