waf/demos/qt5/wscript

58 lines
1.5 KiB
Python

#! /usr/bin/env python
# encoding: utf-8
# Thomas Nagy, 2016 (ita)
# Federico Pellegrin, 2019 (fedepell)
VERSION='0.0.1'
APPNAME='qt5_test'
top = '.'
out = 'build'
def options(opt):
opt.load('compiler_cxx qt5 waf_unit_test')
def configure(conf):
conf.load('compiler_cxx qt5 waf_unit_test')
#conf.env.append_value('CXXFLAGS', ['-g']) # test
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 = '.',
lang = bld.path.ant_glob('linguist/*.ts'),
langname = 'somefile', # include the .qm files from somefile.qrc
)
# Example of integration of Qt5 Unit tests using Qt5Test using waf_unit_test
bld(
features = 'qt5 cxx cxxprogram test',
use = 'QT5CORE QT5WIDGETS QT5TEST',
source = 'foo.cpp testqt5.cpp',
moc = 'foo.h',
target = 'footest',
includes = '.',
# ut_str = './${SRC} -o test-report.xml,xunitxml', # put output to a xunit xml
)
bld.add_post_fun(print_test_results) # print output of test runner to user
def print_test_results(bld):
lst = getattr(bld, 'utest_results', [])
if not lst:
return
for (f, code, out, err) in lst:
print(out.decode('utf-8'))
print(err.decode('utf-8'))