summaryrefslogtreecommitdiffstats
path: root/extras/slow_qt4.py
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2019-03-17 17:31:05 +0100
committerDavid Robillard <d@drobilla.net>2019-03-17 17:31:05 +0100
commit406f89271452fdb573c7e28113b1ed08ff2b4eda (patch)
treed2dcbaf61f3749f73dc7a5e10d3fc6cd5e6e129a /extras/slow_qt4.py
parent7983a5aae615290d04fd43cbc2752f8cf4a46d10 (diff)
downloadsuil-406f89271452fdb573c7e28113b1ed08ff2b4eda.tar.gz
suil-406f89271452fdb573c7e28113b1ed08ff2b4eda.tar.bz2
suil-406f89271452fdb573c7e28113b1ed08ff2b4eda.zip
Squashed 'waflib/' changes from 915dcb1..e7a29b6
e7a29b6 Upgrade to waf 2.0.15 8280f9d Add command for running executables from the build directory 8073c1a Make make_simple_dox() safe in case of exception 70d03b8 Avoid use of global counter hacks for configuration display b7d689a Rewrite test framework 94deadf Automatically add options and move add_flags() to options context f4259ee Reduce system include path noise 927b608 Automatically display configuration header c44b8f3 Set line justification from a constant in the wscript a48e26f Automatically detect if wscript has a test hook ef66724 Save runtime variables in the environment 63bcbcd Clean up TestContext b1d9505 Add ExecutionContext for setting runtime environment 387c1df Add show_diff() and test_file_equals() utilities 29d4d29 Fix in-tree library paths 9fde01f Add custom configuration context 6d3612f Add lib_path_name constant git-subtree-dir: waflib git-subtree-split: e7a29b6b9b2f842314244c23c14d8f8f560904e1
Diffstat (limited to 'extras/slow_qt4.py')
-rw-r--r--extras/slow_qt4.py96
1 files changed, 96 insertions, 0 deletions
diff --git a/extras/slow_qt4.py b/extras/slow_qt4.py
new file mode 100644
index 0000000..ec7880b
--- /dev/null
+++ b/extras/slow_qt4.py
@@ -0,0 +1,96 @@
+#! /usr/bin/env python
+# Thomas Nagy, 2011 (ita)
+
+"""
+Create _moc.cpp files
+
+The builds are 30-40% faster when .moc files are included,
+you should NOT use this tool. If you really
+really want it:
+
+def configure(conf):
+ conf.load('compiler_cxx qt4')
+ conf.load('slow_qt4')
+
+See playground/slow_qt/wscript for a complete example.
+"""
+
+from waflib.TaskGen import extension
+from waflib import Task
+import waflib.Tools.qt4
+import waflib.Tools.cxx
+
+@extension(*waflib.Tools.qt4.EXT_QT4)
+def cxx_hook(self, node):
+ return self.create_compiled_task('cxx_qt', node)
+
+class cxx_qt(Task.classes['cxx']):
+ def runnable_status(self):
+ ret = Task.classes['cxx'].runnable_status(self)
+ if ret != Task.ASK_LATER and not getattr(self, 'moc_done', None):
+
+ try:
+ cache = self.generator.moc_cache
+ except AttributeError:
+ cache = self.generator.moc_cache = {}
+
+ deps = self.generator.bld.node_deps[self.uid()]
+ for x in [self.inputs[0]] + deps:
+ if x.read().find('Q_OBJECT') > 0:
+
+ # process "foo.h -> foo.moc" only if "foo.cpp" is in the sources for the current task generator
+ # this code will work because it is in the main thread (runnable_status)
+ if x.name.rfind('.') > -1: # a .h file...
+ name = x.name[:x.name.rfind('.')]
+ for tsk in self.generator.compiled_tasks:
+ if tsk.inputs and tsk.inputs[0].name.startswith(name):
+ break
+ else:
+ # no corresponding file, continue
+ continue
+
+ # the file foo.cpp could be compiled for a static and a shared library - hence the %number in the name
+ cxx_node = x.parent.get_bld().make_node(x.name.replace('.', '_') + '_%d_moc.cpp' % self.generator.idx)
+ if cxx_node in cache:
+ continue
+ cache[cxx_node] = self
+
+ tsk = Task.classes['moc'](env=self.env, generator=self.generator)
+ tsk.set_inputs(x)
+ tsk.set_outputs(cxx_node)
+
+ if x.name.endswith('.cpp'):
+ # moc is trying to be too smart but it is too dumb:
+ # why forcing the #include when Q_OBJECT is in the cpp file?
+ gen = self.generator.bld.producer
+ gen.outstanding.append(tsk)
+ gen.total += 1
+ self.set_run_after(tsk)
+ else:
+ cxxtsk = Task.classes['cxx'](env=self.env, generator=self.generator)
+ cxxtsk.set_inputs(tsk.outputs)
+ cxxtsk.set_outputs(cxx_node.change_ext('.o'))
+ cxxtsk.set_run_after(tsk)
+
+ try:
+ self.more_tasks.extend([tsk, cxxtsk])
+ except AttributeError:
+ self.more_tasks = [tsk, cxxtsk]
+
+ try:
+ link = self.generator.link_task
+ except AttributeError:
+ pass
+ else:
+ link.set_run_after(cxxtsk)
+ link.inputs.extend(cxxtsk.outputs)
+ link.inputs.sort(key=lambda x: x.abspath())
+
+ self.moc_done = True
+
+ for t in self.run_after:
+ if not t.hasrun:
+ return Task.ASK_LATER
+
+ return ret
+