mirror of
https://gitlab.com/ita1024/waf.git
synced 2024-11-21 17:35:55 +01:00
Process Qt files according to the Qt documentation
This commit is contained in:
parent
6b2e837bc2
commit
ae8253f571
@ -19,6 +19,7 @@ NEW IN WAF 1.9 preview 2
|
||||
- Task generators are now processed group-by-group, so the next group is processed
|
||||
when all tasks in the previous group are complete; bld.post_mode=POST_LAZY
|
||||
is now the default (playground/dynamic_build/ examples)
|
||||
- Process Qt5 files in the way suggested by the Qt documentation
|
||||
|
||||
* Performance highlights:
|
||||
- Reduce the key size in bld.task_sigs by adding bld.node_sigs and bld.imp_sigs
|
||||
|
3
TODO
3
TODO
@ -1,6 +1,5 @@
|
||||
Waf 1.9
|
||||
-------
|
||||
|
||||
* Rework qt5
|
||||
* Other issues listed on https://github.com/waf-project/waf/issues
|
||||
Update the documentation
|
||||
|
||||
|
@ -18,3 +18,4 @@ Bar_private::Bar_private() : QWidget(NULL) {
|
||||
}
|
||||
|
||||
#include "foo.moc"
|
||||
|
||||
|
@ -25,13 +25,18 @@ def configure(conf):
|
||||
msg='Try again with -fPIE', okmsg='-fPIE seems to be required')
|
||||
|
||||
def build(bld):
|
||||
# According to the Qt5 documentation:
|
||||
# Qt classes in foo.h -> declare foo.h as a header to be processed by moc
|
||||
# add the resulting moc_foo.cpp to the source files
|
||||
# Qt classes in foo.cpp -> include foo.moc at the end of foo.cpp
|
||||
#
|
||||
bld(
|
||||
features = 'qt5 cxx cxxprogram',
|
||||
use = 'QT5CORE QT5GUI QT5SVG QT5WIDGETS',
|
||||
source = 'main.cpp res.qrc but.ui foo.cpp',
|
||||
moc = 'foo.h',
|
||||
target = 'window',
|
||||
includes = '.',
|
||||
defines = 'WAF=1', # test
|
||||
lang = bld.path.ant_glob('linguist/*.ts'),
|
||||
langname = 'somefile', # include the .qm files from somefile.qrc
|
||||
)
|
||||
|
@ -75,11 +75,11 @@ else:
|
||||
import os, sys
|
||||
from waflib.Tools import cxx
|
||||
from waflib import Task, Utils, Options, Errors, Context
|
||||
from waflib.TaskGen import feature, after_method, extension
|
||||
from waflib.TaskGen import feature, after_method, extension, before_method
|
||||
from waflib.Configure import conf
|
||||
from waflib import Logs
|
||||
|
||||
MOC_H = ['.h', '.hpp', '.hxx', '.hh']
|
||||
MOC_H = ['.cpp', '.h', '.hpp', '.hxx', '.hh']
|
||||
"""
|
||||
File extensions associated to the .moc files
|
||||
"""
|
||||
@ -171,9 +171,6 @@ class qxx(Task.classes['cxx']):
|
||||
If several libraries use the same classes, it is possible that moc will run several times (Issue 1318)
|
||||
It is not possible to change the file names, but we can assume that the moc transformation will be identical,
|
||||
and the moc tasks can be shared in a global cache.
|
||||
|
||||
The defines passed to moc will then depend on task generator order. If this is not acceptable, then
|
||||
use the tool slow_qt5 instead (and enjoy the slow builds... :-( )
|
||||
"""
|
||||
try:
|
||||
moc_cache = self.generator.bld.moc_cache
|
||||
@ -186,6 +183,7 @@ class qxx(Task.classes['cxx']):
|
||||
tsk = moc_cache[h_node] = Task.classes['moc'](env=self.env, generator=self.generator)
|
||||
tsk.set_inputs(h_node)
|
||||
tsk.set_outputs(m_node)
|
||||
tsk.env.append_unique('MOC_FLAGS', '-i')
|
||||
|
||||
if self.generator:
|
||||
self.generator.tasks.append(tsk)
|
||||
@ -321,6 +319,19 @@ def add_lang(self, node):
|
||||
"""add all the .ts file into self.lang"""
|
||||
self.lang = self.to_list(getattr(self, 'lang', [])) + [node]
|
||||
|
||||
@feature('qt5')
|
||||
@before_method('process_source')
|
||||
def process_mocs(self):
|
||||
lst = self.to_nodes(getattr(self, 'moc', []))
|
||||
self.source = self.to_list(getattr(self, 'source', []))
|
||||
for x in lst:
|
||||
prefix = x.name[:x.name.rfind('.')] # foo.h -> foo
|
||||
moc_target = 'moc_%s.cpp' % prefix # moc_foo.cpp
|
||||
moc_node = x.parent.find_or_declare(moc_target)
|
||||
self.source.append(moc_target)
|
||||
|
||||
self.create_task('moc', x, moc_node)
|
||||
|
||||
@feature('qt5')
|
||||
@after_method('apply_link')
|
||||
def apply_qt5(self):
|
||||
|
Loading…
Reference in New Issue
Block a user