summaryrefslogtreecommitdiff
path: root/buildtools/wafsamba/gccdeps.py
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2010-03-17 20:12:16 +1100
committerAndrew Tridgell <tridge@samba.org>2010-04-06 20:26:48 +1000
commit844acb226086e55de9a2442396a4e002471295e8 (patch)
treef84eef86a64b5f1c34f44999bea6b1913d47e864 /buildtools/wafsamba/gccdeps.py
parent845e0cbe6f43e2762796c644035ac6bc2b07cf17 (diff)
downloadsamba-844acb226086e55de9a2442396a4e002471295e8.tar.gz
samba-844acb226086e55de9a2442396a4e002471295e8.tar.bz2
samba-844acb226086e55de9a2442396a4e002471295e8.zip
build: waf quicktest nearly works
Rewrote wafsamba using a new dependency handling system, and started adding the waf test code
Diffstat (limited to 'buildtools/wafsamba/gccdeps.py')
-rw-r--r--buildtools/wafsamba/gccdeps.py108
1 files changed, 108 insertions, 0 deletions
diff --git a/buildtools/wafsamba/gccdeps.py b/buildtools/wafsamba/gccdeps.py
new file mode 100644
index 0000000000..bd03da4f8b
--- /dev/null
+++ b/buildtools/wafsamba/gccdeps.py
@@ -0,0 +1,108 @@
+#!/usr/bin/env python
+# encoding: utf-8
+# Thomas Nagy, 2008-2010 (ita)
+
+"""
+Execute the tasks with gcc -MD, read the dependencies from the .d file
+and prepare the dependency calculation for the next run
+"""
+
+import os, re, threading
+import Task, Logs, Utils, preproc
+
+lock = threading.Lock()
+
+
+def detect(conf):
+ conf.env.append_unique('CCFLAGS', '-MD')
+
+def scan(self):
+ "the scanner does not do anything initially"
+ nodes = self.generator.bld.node_deps.get(self.unique_id(), [])
+ names = []
+ return (nodes, names)
+
+re_src = re.compile("^(\.\.)[\\/](.*)$")
+
+def post_run(self):
+ # The following code is executed by threads, it is not safe, so a lock is needed...
+
+ if getattr(self, 'cached', None):
+ return Task.Task.post_run(self)
+
+ name = self.outputs[0].abspath(self.env)
+ name = name.rstrip('.o') + '.d'
+ txt = Utils.readf(name)
+ #os.unlink(name)
+
+ txt = txt.replace('\\\n', '')
+
+ lst = txt.strip().split(':')
+ val = ":".join(lst[1:])
+ val = val.split()
+
+ nodes = []
+ bld = self.generator.bld
+
+ f = re.compile("^("+self.env.variant()+"|\.\.)[\\/](.*)$")
+ for x in val:
+ if os.path.isabs(x):
+
+ if not preproc.go_absolute:
+ continue
+
+ lock.acquire()
+ try:
+ node = bld.root.find_resource(x)
+ finally:
+ lock.release()
+ else:
+ g = re.search(re_src, x)
+ if g:
+ x = g.group(2)
+ lock.acquire()
+ try:
+ node = bld.bldnode.parent.find_resource(x)
+ finally:
+ lock.release()
+ else:
+ g = re.search(f, x)
+ if g:
+ x = g.group(2)
+ lock.acquire()
+ try:
+ node = bld.srcnode.find_resource(x)
+ finally:
+ lock.release()
+
+ if id(node) == id(self.inputs[0]):
+ # ignore the source file, it is already in the dependencies
+ # this way, successful config tests may be retrieved from the cache
+ continue
+
+ if not node:
+ raise ValueError('could not find %r for %r' % (x, self))
+ else:
+ nodes.append(node)
+
+ Logs.debug('deps: real scanner for %s returned %s' % (str(self), str(nodes)))
+
+ bld.node_deps[self.unique_id()] = nodes
+ bld.raw_deps[self.unique_id()] = []
+
+ try:
+ del self.cache_sig
+ except:
+ pass
+
+ Task.Task.post_run(self)
+
+for name in 'cc cxx'.split():
+ try:
+ cls = Task.TaskBase.classes[name]
+ except KeyError:
+ pass
+ else:
+ cls.post_run = post_run
+ cls.scan = scan
+