merge current upstream
[scons.git] / test / QT / manual.py
blobc5cf74e8a89a59422243f528d370a05846488553
1 #!/usr/bin/env python
3 # __COPYRIGHT__
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__"
27 """
28 Test the manual QT builder calls.
29 """
31 import TestSCons
33 test = TestSCons.TestSCons()
35 test.subdir('include', 'ui')
37 test.Qt_dummy_installation()
39 aaa_exe = 'aaa' + TestSCons._exe
41 test.Qt_create_SConstruct('SConstruct')
43 test.write('SConscript', r"""
44 Import("env")
45 sources = ['aaa.cpp', 'bbb.cpp', 'ddd.cpp', 'eee.cpp', 'main.cpp']
47 # normal invocation
48 sources.append(env.Moc('include/aaa.h'))
49 moc = env.Moc('bbb.cpp')
50 env.Ignore( moc, moc )
51 sources.extend(env.Uic('ui/ccc.ui')[1:])
53 # manual target specification
54 sources.append(env.Moc('moc-ddd.cpp', 'include/ddd.h',
55 QT_MOCHPREFIX='')) # Watch out !
56 moc = env.Moc('moc_eee.cpp', 'eee.cpp')
57 env.Ignore( moc, moc )
58 sources.extend(env.Uic(['include/uic_fff.hpp', 'fff.cpp', 'fff.moc.cpp'],
59 'ui/fff.ui')[1:])
61 print(list(map(str,sources)))
62 env.Program(target='aaa',
63 source=sources,
64 CPPPATH=['$CPPPATH', './include'],
65 QT_AUTOSCAN=0)
66 """)
68 test.write('aaa.cpp', r"""
69 #include "aaa.h"
70 """)
72 test.write(['include', 'aaa.h'], r"""
73 #include "my_qobject.h"
74 void aaa(void) Q_OBJECT;
75 """)
77 test.write('bbb.h', r"""
78 void bbb(void);
79 """)
81 test.write('bbb.cpp', r"""
82 #include "my_qobject.h"
83 void bbb(void) Q_OBJECT
84 #include "bbb.moc"
85 """)
87 test.write(['ui', 'ccc.ui'], r"""
88 void ccc(void)
89 """)
91 test.write('ddd.cpp', r"""
92 #include "ddd.h"
93 """)
95 test.write(['include', 'ddd.h'], r"""
96 #include "my_qobject.h"
97 void ddd(void) Q_OBJECT;
98 """)
100 test.write('eee.h', r"""
101 void eee(void);
102 """)
104 test.write('eee.cpp', r"""
105 #include "my_qobject.h"
106 void eee(void) Q_OBJECT
107 #include "moc_eee.cpp"
108 """)
110 test.write(['ui', 'fff.ui'], r"""
111 void fff(void)
112 """)
114 test.write('main.cpp', r"""
115 #include "aaa.h"
116 #include "bbb.h"
117 #include "ui/ccc.h"
118 #include "ddd.h"
119 #include "eee.h"
120 #include "uic_fff.hpp"
122 int main(void) {
123 aaa(); bbb(); ccc(); ddd(); eee(); fff(); return 0;
125 """)
127 test.run(arguments = aaa_exe)
129 # normal invocation
130 test.must_exist(test.workpath('include', 'moc_aaa.cc'))
131 test.must_exist(test.workpath('bbb.moc'))
132 test.must_exist(test.workpath('ui', 'ccc.h'))
133 test.must_exist(test.workpath('ui', 'uic_ccc.cc'))
134 test.must_exist(test.workpath('ui', 'moc_ccc.cc'))
136 # manual target spec.
137 test.must_exist(test.workpath('moc-ddd.cpp'))
138 test.must_exist(test.workpath('moc_eee.cpp'))
139 test.must_exist(test.workpath('include', 'uic_fff.hpp'))
140 test.must_exist(test.workpath('fff.cpp'))
141 test.must_exist(test.workpath('fff.moc.cpp'))
143 test.pass_test()
145 # Local Variables:
146 # tab-width:4
147 # indent-tabs-mode:nil
148 # End:
149 # vim: set expandtab tabstop=4 shiftwidth=4: