5 # Permission is hereby granted, free of charge, to any person obtaining
6 # a copy of this software and associated documentation files (the
7 # "Software"), to deal in the Software without restriction, including
8 # without limitation the rights to use, copy, modify, merge, publish,
9 # distribute, sublicense, and/or sell copies of the Software, and to
10 # permit persons to whom the Software is furnished to do so, subject to
11 # the following conditions:
13 # The above copyright notice and this permission notice shall be included
14 # in all copies or substantial portions of the Software.
16 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
17 # KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
18 # WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19 # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20 # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21 # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22 # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
28 Testing the configuration mechanisms of the 'qt' tool.
33 _python_ = TestSCons._python_
36 test = TestSCons.TestSCons()
38 test.subdir( 'qt', ['qt', 'bin'], ['qt', 'include'], ['qt', 'lib'],
41 test.Qt_dummy_installation()
43 test.run(chdir=test.workpath('qt','lib'), arguments = '.',
44 stderr=TestSCons.noisy_ar,
45 match=TestSCons.match_re_dotall)
47 QT = test.workpath('qt')
49 QT_MOC = '%s %s' % (_python_, test.workpath('qt','bin','mymoc.py'))
50 QT_UIC = '%s %s' % (_python_, test.workpath('qt','bin','myuic.py'))
52 def createSConstruct(test,place,overrides):
54 env = Environment(QTDIR = r'%s',
59 tools=['default','qt'])
60 if ARGUMENTS.get('variant_dir', 0):
61 if ARGUMENTS.get('chdir', 0):
65 VariantDir('build', '.', duplicate=1)
66 sconscript = Dir('build').File('SConscript')
68 sconscript = File('SConscript')
70 SConscript( sconscript )
71 """ % (QT, QT_LIB, QT_MOC, QT_UIC, overrides))
74 createSConstruct(test, ['work1', 'SConstruct'],
75 """QT_UICIMPLFLAGS='-x',
77 QT_MOCFROMHFLAGS='-z',
78 QT_MOCFROMCXXFLAGS='-i -w',
79 QT_UICDECLPREFIX='uic-',
80 QT_UICDECLSUFFIX='.hpp',
82 QT_UICIMPLSUFFIX='.cxx',
85 QT_MOCCXXPREFIX='moc',
86 QT_MOCCXXSUFFIX='.inl',
87 QT_UISUFFIX='.myui',""")
88 test.write(['work1', 'SConscript'],"""
90 env.Program('mytest', ['mocFromH.cpp',
93 'another_ui_file.myui',
97 test.write(['work1', 'mocFromH.hpp'], """
98 #include "my_qobject.h"
99 void mocFromH() Q_OBJECT
102 test.write(['work1', 'mocFromH.cpp'], """
103 #include "mocFromH.hpp"
106 test.write(['work1', 'mocFromCpp.cpp'], """
107 #include "my_qobject.h"
108 void mocFromCpp() Q_OBJECT
109 #include "mocmocFromCpp.inl"
112 test.write(['work1', 'an_ui_file.myui'], """
116 test.write(['work1', 'another_ui_file.myui'], """
117 void another_ui_file()
120 test.write(['work1', 'another_ui_file.desc.hpp'], """
121 /* just a dependency checker */
124 test.write(['work1', 'main.cpp'], """
125 #include "mocFromH.hpp"
126 #include "uic-an_ui_file.hpp"
127 #include "uic-another_ui_file.hpp"
138 test.run(chdir = 'work1', arguments = "mytest" + _exe)
140 test.must_exist(['work1', 'mmmmocFromH.cxx'],
141 ['work1', 'mocmocFromCpp.inl'],
142 ['work1', 'an_ui_file.cxx'],
143 ['work1', 'uic-an_ui_file.hpp'],
144 ['work1', 'mmman_ui_file.cxx'],
145 ['work1', 'another_ui_file.cxx'],
146 ['work1', 'uic-another_ui_file.hpp'],
147 ['work1', 'mmmanother_ui_file.cxx'])
149 def _flagTest(test,fileToContentsStart):
150 for f,c in fileToContentsStart.items():
151 if test.read(test.workpath('work1', f)).find(c) != 0:
155 test.fail_test(_flagTest(test, {'mmmmocFromH.cxx':'/* mymoc.py -z */',
156 'mocmocFromCpp.inl':'/* mymoc.py -w */',
157 'an_ui_file.cxx':'/* myuic.py -x */',
158 'uic-an_ui_file.hpp':'/* myuic.py -y */',
159 'mmman_ui_file.cxx':'/* mymoc.py -z */'}))
161 test.write(['work2', 'SConstruct'], """
163 env1 = Environment(tools=['qt'],
164 QTDIR = r'%(QTDIR)s',
165 QT_BINPATH='$QTDIR/bin64',
166 QT_LIBPATH='$QTDIR/lib64',
167 QT_CPPPATH='$QTDIR/h64')
169 cpppath = env1.subst('$CPPPATH')
170 if os.path.normpath(cpppath) != os.path.join(r'%(QTDIR)s', 'h64'):
173 libpath = env1.subst('$LIBPATH')
174 if os.path.normpath(libpath) != os.path.join(r'%(QTDIR)s', 'lib64'):
177 qt_moc = env1.subst('$QT_MOC')
178 if os.path.normpath(qt_moc) != os.path.join(r'%(QTDIR)s', 'bin64', 'moc'):
182 env2 = Environment(tools=['default', 'qt'],
188 env2.Program('main.cpp')
191 test.write(['work2', 'main.cpp'], """
192 int main() { return 0; }
195 # Ignore stderr, because if Qt is not installed,
196 # there may be a warning about an empty QTDIR on stderr.
197 test.run(chdir='work2', stderr=None)
199 test.must_exist(['work2', 'main' + _exe])
205 # indent-tabs-mode:nil
207 # vim: set expandtab tabstop=4 shiftwidth=4: