mirror of
https://gitlab.com/ita1024/waf.git
synced 2024-11-21 17:35:55 +01:00
Update more examples
This commit is contained in:
parent
69049d83b8
commit
b47fceb86a
@ -35,4 +35,3 @@ Bar_private::Bar_private() : QWidget(NULL) {
|
||||
}
|
||||
|
||||
#include "foo.moc"
|
||||
|
||||
|
@ -1,33 +0,0 @@
|
||||
#! /usr/bin/env python
|
||||
# encoding: utf-8
|
||||
# Thomas Nagy, 2005, 2011 (ita)
|
||||
|
||||
"""
|
||||
Including the moc files *is* the best practice (KDE), not doing it is easy,
|
||||
but makes the compilations about 30-40% slower on average.
|
||||
|
||||
This is the slow version that creates _moc.cpp files (a bad idea!)
|
||||
"""
|
||||
|
||||
VERSION='0.0.2'
|
||||
APPNAME='qt4_test2'
|
||||
|
||||
top = '.'
|
||||
out = 'build'
|
||||
|
||||
def options(opt):
|
||||
opt.load('compiler_cxx qt4')
|
||||
|
||||
def configure(conf):
|
||||
conf.load('compiler_cxx qt4')
|
||||
conf.load('slow_qt4')
|
||||
|
||||
def build(bld):
|
||||
bld(
|
||||
features = 'qt4 cxx cxxprogram',
|
||||
uselib = 'QTCORE QTGUI QTOPENGL QTSVG',
|
||||
source = 'main.cpp foo.cpp',
|
||||
includes = '.',
|
||||
target = 'window',
|
||||
)
|
||||
|
@ -20,5 +20,4 @@ FooP::FooP() {
|
||||
|
||||
}
|
||||
|
||||
#include "foo_cpp_moc.cpp"
|
||||
|
||||
#include "foo_cpp_mywindow_moc.cpp"
|
35
playground/slow_qt_example/wscript
Normal file
35
playground/slow_qt_example/wscript
Normal file
@ -0,0 +1,35 @@
|
||||
#! /usr/bin/env python
|
||||
# encoding: utf-8
|
||||
# Thomas Nagy, 2005, 2011 (ita)
|
||||
|
||||
"""
|
||||
Process Q_OBJECT classes in source (foo.cpp) and header (foo.h) files.
|
||||
The generated files can be included or they will be built as additional files.
|
||||
|
||||
The file slow_qt.py assumes that C++ files will include the generated code,
|
||||
and that header files will not.
|
||||
"""
|
||||
|
||||
VERSION='0.0.3'
|
||||
APPNAME='slow_qt'
|
||||
|
||||
top = '.'
|
||||
out = 'build'
|
||||
|
||||
def options(opt):
|
||||
opt.load('compiler_cxx qt5')
|
||||
|
||||
def configure(conf):
|
||||
conf.load('compiler_cxx qt5')
|
||||
conf.load('slow_qt')
|
||||
|
||||
def build(bld):
|
||||
bld(
|
||||
features = 'qt5 cxx cxxprogram',
|
||||
uselib = 'QT5CORE QT5GUI QT5OPENGL QT5SVG',
|
||||
source = 'main.cpp foo.cpp',
|
||||
deps = 'foo.h',
|
||||
includes = '.',
|
||||
target = 'window',
|
||||
name = 'mywindow',
|
||||
)
|
@ -9,7 +9,6 @@ def configure(conf):
|
||||
|
||||
def build(bld):
|
||||
bld.env.A = "test (change me) "
|
||||
bld(rule="echo '${A}' > ${TGT}", target='foo.txt', name='foo')
|
||||
bld(rule='echo `cat ${SRC} ${SRC}` > ${SRC}', source='foo.txt', name='one')
|
||||
bld(rule='echo `cat ${SRC} ${SRC}` > ${SRC}', source='foo.txt', after=['one'], name='two')
|
||||
|
||||
bld(rule="echo '${A}' > ${TGT}", target='foo.txt', name='foo', cls_keyword=lambda _: "step 1")
|
||||
bld(rule='echo `cat ${SRC} ${SRC}` > ${SRC}', source='foo.txt', name='one', cls_keyword=lambda _:"step_2")
|
||||
bld(rule='echo `cat ${SRC} ${SRC}` > ${SRC}', source='foo.txt', after=['one'], name='two', cls_keyword=lambda _:"step_3")
|
||||
|
@ -619,9 +619,13 @@ def process_rule(self):
|
||||
cls = Task.task_factory(name, rule, _vars, shell=shell, color=color)
|
||||
|
||||
if cls_str:
|
||||
if isinstance(cls_str, str):
|
||||
raise ValueError('cls_str should be a function %r' % self)
|
||||
setattr(cls, '__str__', self.cls_str)
|
||||
|
||||
if cls_keyword:
|
||||
if isinstance(cls_keyword, str):
|
||||
raise ValueError('cls_keyword should be a function %r' % self)
|
||||
setattr(cls, 'keyword', self.cls_keyword)
|
||||
|
||||
if deep_inputs:
|
||||
|
@ -4,23 +4,23 @@
|
||||
"""
|
||||
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:
|
||||
The builds are 30-40% faster when .moc files are directly included,
|
||||
so the usage of this tool is discouraged.
|
||||
|
||||
def configure(conf):
|
||||
conf.load('compiler_cxx qt4')
|
||||
conf.load('slow_qt4')
|
||||
conf.load('compiler_cxx qt5')
|
||||
conf.load('slow_qt')
|
||||
|
||||
See playground/slow_qt/wscript for a complete example.
|
||||
See playground/slow_qt/wscript for a complete example,
|
||||
and run with "waf --zones=slow_qt" to display the moc files that should be generated
|
||||
"""
|
||||
|
||||
from waflib.TaskGen import extension
|
||||
from waflib import Task
|
||||
import waflib.Tools.qt4
|
||||
from waflib import Task, Logs
|
||||
import waflib.Tools.qt5
|
||||
import waflib.Tools.cxx
|
||||
|
||||
@extension(*waflib.Tools.qt4.EXT_QT4)
|
||||
@extension(*waflib.Tools.qt5.EXT_QT5)
|
||||
def cxx_hook(self, node):
|
||||
return self.create_compiled_task('cxx_qt', node)
|
||||
|
||||
@ -28,7 +28,6 @@ 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:
|
||||
@ -49,19 +48,23 @@ class cxx_qt(Task.classes['cxx']):
|
||||
# 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)
|
||||
# the file foo.cpp could be compiled for a static and a shared library
|
||||
# one workaround is to use a %number in the name
|
||||
#cxx_node = x.parent.get_bld().make_node(x.name.replace('.', '_') + '_%d_moc.cpp' % self.generator.idx)
|
||||
|
||||
# another workaround is to add the target name
|
||||
cxx_node = x.parent.get_bld().make_node(x.name.replace('.', '_') + '_%s_moc.cpp' % self.generator.name)
|
||||
if cxx_node in cache:
|
||||
continue
|
||||
cache[cxx_node] = self
|
||||
|
||||
Logs.debug('slow_qt: will create a file named %s', cxx_node.abspath())
|
||||
|
||||
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
|
||||
@ -93,4 +96,3 @@ class cxx_qt(Task.classes['cxx']):
|
||||
return Task.ASK_LATER
|
||||
|
||||
return ret
|
||||
|
Loading…
Reference in New Issue
Block a user