waf

FORK: waf with some random patches
git clone https://git.neptards.moe/neptards/waf.git
Log | Files | Refs | README

wscript (2432B)


      1 #! /usr/bin/env python
      2 # encoding: utf-8
      3 # Thomas Nagy, 2016 (ita)
      4 # Federico Pellegrin, 2019 (fedepell)
      5 
      6 VERSION='0.0.1'
      7 APPNAME='qt5_test'
      8 
      9 top = '.'
     10 out = 'build'
     11 
     12 def options(opt):
     13 	opt.load('compiler_cxx qt5 waf_unit_test')
     14 
     15 def configure(conf):
     16 	conf.load('compiler_cxx qt5 waf_unit_test')
     17 	#conf.env.append_value('CXXFLAGS', ['-g']) # test
     18 
     19 	if not conf.env.QT_LRELEASE:
     20 		# While qt5 detects most Qt tools, most of them are optional
     21 		conf.fatal('lrelease was not found')
     22 
     23 	# These tests would run on Ubuntu but not on other platforms
     24 	conf.check(
     25 		define_name  = 'XYZ_QT5_TESTS',
     26 		mandatory    = False,
     27 		execute      = True,
     28 		features     = 'qt5 cxx cxxprogram',
     29 		includes     = '.',
     30 		defines      = 'QT_WIDGETS_LIB',
     31 		use          = 'QT5CORE QT5GUI QT5WIDGETS QT5TEST',
     32 		msg          = 'Checking whether Qt5 tests can run',
     33 		fragment     = '''
     34 #include <QtTest/QtTest>
     35 class TestQt5Test: public QObject {
     36         Q_OBJECT
     37         private:
     38                 void testGui() {
     39 			QWidget *widget = NULL;
     40 			QTest::mouseClick(widget, Qt::LeftButton, Qt::NoModifier, QPoint(5,5), 0);
     41 		}
     42 };
     43 
     44 QTEST_MAIN(TestQt5Test)
     45 #include "test.moc"
     46 ''')
     47 
     48 def build(bld):
     49 	# According to the Qt5 documentation:
     50 	#   Qt classes in foo.h   -> declare foo.h as a header to be processed by moc
     51 	#			    add the resulting moc_foo.cpp to the source files
     52 	#   Qt classes in foo.cpp -> include foo.moc at the end of foo.cpp
     53 	#
     54 	bld(
     55 		features = 'qt5 cxx cxxprogram',
     56 		use      = 'QT5CORE QT5GUI QT5SVG QT5WIDGETS',
     57 		source   = 'main.cpp res.qrc but.ui foo.cpp',
     58 		moc      = 'foo.h',
     59 		target   = 'window',
     60 		includes = '.',
     61 		lang     = bld.path.ant_glob('linguist/*.ts'),
     62 		langname = 'somefile', # include the .qm files from somefile.qrc
     63 	)
     64 
     65 	if bld.env.XYZ_QT5_TESTS:
     66 		# Example of integration of Qt5 Unit tests using Qt5Test using waf_unit_test
     67 		bld(
     68 			features = 'qt5 cxx cxxprogram test',
     69 			use      = 'QT5CORE QT5GUI QT5WIDGETS QT5TEST',
     70 			defines  = 'QT_WIDGETS_LIB',
     71 			source   = 'foo.cpp testqt5.cpp',
     72 			moc      = 'foo.h',
     73 			target   = 'footest',
     74 			includes = '.',
     75 			# ut_str   = './${SRC} -o test-report.xml,xunitxml', # put output to a xunit xml
     76 		)
     77 
     78 		bld.add_post_fun(print_test_results)	# print output of test runner to user
     79 
     80 
     81 def print_test_results(bld):
     82 	lst = getattr(bld, 'utest_results', [])
     83 	if not lst:
     84 		return
     85 	for (f, code, out, err) in lst:
     86 		print(out.decode('utf-8'))
     87 		print(err.decode('utf-8'))
     88