mirror of
https://gitlab.com/ita1024/waf.git
synced 2024-11-25 03:09:30 +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
|
- 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
|
when all tasks in the previous group are complete; bld.post_mode=POST_LAZY
|
||||||
is now the default (playground/dynamic_build/ examples)
|
is now the default (playground/dynamic_build/ examples)
|
||||||
|
- Process Qt5 files in the way suggested by the Qt documentation
|
||||||
|
|
||||||
* Performance highlights:
|
* Performance highlights:
|
||||||
- Reduce the key size in bld.task_sigs by adding bld.node_sigs and bld.imp_sigs
|
- 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
|
Waf 1.9
|
||||||
-------
|
-------
|
||||||
|
|
||||||
* Rework qt5
|
Update the documentation
|
||||||
* Other issues listed on https://github.com/waf-project/waf/issues
|
|
||||||
|
|
||||||
|
@ -18,3 +18,4 @@ Bar_private::Bar_private() : QWidget(NULL) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#include "foo.moc"
|
#include "foo.moc"
|
||||||
|
|
||||||
|
@ -25,13 +25,18 @@ def configure(conf):
|
|||||||
msg='Try again with -fPIE', okmsg='-fPIE seems to be required')
|
msg='Try again with -fPIE', okmsg='-fPIE seems to be required')
|
||||||
|
|
||||||
def build(bld):
|
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(
|
bld(
|
||||||
features = 'qt5 cxx cxxprogram',
|
features = 'qt5 cxx cxxprogram',
|
||||||
use = 'QT5CORE QT5GUI QT5SVG QT5WIDGETS',
|
use = 'QT5CORE QT5GUI QT5SVG QT5WIDGETS',
|
||||||
source = 'main.cpp res.qrc but.ui foo.cpp',
|
source = 'main.cpp res.qrc but.ui foo.cpp',
|
||||||
|
moc = 'foo.h',
|
||||||
target = 'window',
|
target = 'window',
|
||||||
includes = '.',
|
includes = '.',
|
||||||
defines = 'WAF=1', # test
|
|
||||||
lang = bld.path.ant_glob('linguist/*.ts'),
|
lang = bld.path.ant_glob('linguist/*.ts'),
|
||||||
langname = 'somefile', # include the .qm files from somefile.qrc
|
langname = 'somefile', # include the .qm files from somefile.qrc
|
||||||
)
|
)
|
||||||
|
@ -75,11 +75,11 @@ else:
|
|||||||
import os, sys
|
import os, sys
|
||||||
from waflib.Tools import cxx
|
from waflib.Tools import cxx
|
||||||
from waflib import Task, Utils, Options, Errors, Context
|
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.Configure import conf
|
||||||
from waflib import Logs
|
from waflib import Logs
|
||||||
|
|
||||||
MOC_H = ['.h', '.hpp', '.hxx', '.hh']
|
MOC_H = ['.cpp', '.h', '.hpp', '.hxx', '.hh']
|
||||||
"""
|
"""
|
||||||
File extensions associated to the .moc files
|
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)
|
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,
|
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.
|
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:
|
try:
|
||||||
moc_cache = self.generator.bld.moc_cache
|
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 = moc_cache[h_node] = Task.classes['moc'](env=self.env, generator=self.generator)
|
||||||
tsk.set_inputs(h_node)
|
tsk.set_inputs(h_node)
|
||||||
tsk.set_outputs(m_node)
|
tsk.set_outputs(m_node)
|
||||||
|
tsk.env.append_unique('MOC_FLAGS', '-i')
|
||||||
|
|
||||||
if self.generator:
|
if self.generator:
|
||||||
self.generator.tasks.append(tsk)
|
self.generator.tasks.append(tsk)
|
||||||
@ -321,6 +319,19 @@ def add_lang(self, node):
|
|||||||
"""add all the .ts file into self.lang"""
|
"""add all the .ts file into self.lang"""
|
||||||
self.lang = self.to_list(getattr(self, 'lang', [])) + [node]
|
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')
|
@feature('qt5')
|
||||||
@after_method('apply_link')
|
@after_method('apply_link')
|
||||||
def apply_qt5(self):
|
def apply_qt5(self):
|
||||||
|
Loading…
Reference in New Issue
Block a user