3
# Thomas Nagy, 2008-2010 (ita)
6
Execute the tasks with gcc -MD, read the dependencies from the .d file
7
and prepare the dependency calculation for the next run
10
import os, re, threading
11
import Task, Logs, Utils, preproc
12
from TaskGen import before, after, feature
14
lock = threading.Lock()
16
preprocessor_flag = '-MD'
21
if self.env.get_flat('CCFLAGS').find(preprocessor_flag) < 0:
22
self.env.append_value('CCFLAGS', preprocessor_flag)
26
def add_mmd_cxx(self):
27
if self.env.get_flat('CXXFLAGS').find(preprocessor_flag) < 0:
28
self.env.append_value('CXXFLAGS', preprocessor_flag)
31
"the scanner does not do anything initially"
32
nodes = self.generator.bld.node_deps.get(self.unique_id(), [])
36
re_o = re.compile("\.o$")
37
re_src = re.compile("^(\.\.)[\\/](.*)$")
40
# The following code is executed by threads, it is not safe, so a lock is needed...
42
if getattr(self, 'cached', None):
43
return Task.Task.post_run(self)
45
name = self.outputs[0].abspath(self.env)
46
name = re_o.sub('.d', name)
47
txt = Utils.readf(name)
50
txt = txt.replace('\\\n', '')
52
lst = txt.strip().split(':')
53
val = ":".join(lst[1:])
57
bld = self.generator.bld
59
f = re.compile("^("+self.env.variant()+"|\.\.)[\\/](.*)$")
63
if not preproc.go_absolute:
68
node = bld.root.find_resource(x)
72
g = re.search(re_src, x)
77
node = bld.bldnode.parent.find_resource(x)
86
node = bld.srcnode.find_resource(x)
90
if id(node) == id(self.inputs[0]):
91
# ignore the source file, it is already in the dependencies
92
# this way, successful config tests may be retrieved from the cache
96
raise ValueError('could not find %r for %r' % (x, self))
100
Logs.debug('deps: real scanner for %s returned %s' % (str(self), str(nodes)))
102
bld.node_deps[self.unique_id()] = nodes
103
bld.raw_deps[self.unique_id()] = []
110
Task.Task.post_run(self)
112
import Constants, Utils
113
def sig_implicit_deps(self):
115
return Task.Task.sig_implicit_deps(self)
116
except Utils.WafError:
117
return Constants.SIG_NIL
119
for name in 'cc cxx'.split():
121
cls = Task.TaskBase.classes[name]
125
cls.post_run = post_run
127
cls.sig_implicit_deps = sig_implicit_deps