Merge pull request #4303 from RedwanFox/fix_textfile_encoding_issue
[scons.git] / test / QT / manual.py
blob84c6df8e04171137229785790c66ce81a3f20b49
1 #!/usr/bin/env python
3 # MIT License
5 # Copyright The SCons Foundation
7 # Permission is hereby granted, free of charge, to any person obtaining
8 # a copy of this software and associated documentation files (the
9 # "Software"), to deal in the Software without restriction, including
10 # without limitation the rights to use, copy, modify, merge, publish,
11 # distribute, sublicense, and/or sell copies of the Software, and to
12 # permit persons to whom the Software is furnished to do so, subject to
13 # the following conditions:
15 # The above copyright notice and this permission notice shall be included
16 # in all copies or substantial portions of the Software.
18 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
19 # KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
20 # WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21 # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
22 # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
23 # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24 # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 """
27 Test the manual QT builder calls.
28 """
30 import TestSCons
32 test = TestSCons.TestSCons()
34 test.subdir('include', 'ui')
36 test.Qt_dummy_installation()
38 aaa_exe = 'aaa' + TestSCons._exe
40 test.Qt_create_SConstruct('SConstruct')
42 test.write('SConscript', r"""
43 Import("env")
44 sources = ['aaa.cpp', 'bbb.cpp', 'ddd.cpp', 'eee.cpp', 'main.cpp']
46 # normal invocation
47 sources.append(env.Moc('include/aaa.h'))
48 moc = env.Moc('bbb.cpp')
49 env.Ignore( moc, moc )
50 sources.extend(env.Uic('ui/ccc.ui')[1:])
52 # manual target specification
53 sources.append(env.Moc('moc-ddd.cpp', 'include/ddd.h',
54 QT_MOCHPREFIX='')) # Watch out !
55 moc = env.Moc('moc_eee.cpp', 'eee.cpp')
56 env.Ignore( moc, moc )
57 sources.extend(env.Uic(['include/uic_fff.hpp', 'fff.cpp', 'fff.moc.cpp'],
58 'ui/fff.ui')[1:])
60 print(list(map(str,sources)))
61 env.Program(target='aaa',
62 source=sources,
63 CPPPATH=['$CPPPATH', './include'],
64 QT_AUTOSCAN=0)
65 """)
67 test.write('aaa.cpp', r"""
68 #include "aaa.h"
69 """)
71 test.write(['include', 'aaa.h'], r"""
72 #include "my_qobject.h"
73 void aaa(void) Q_OBJECT;
74 """)
76 test.write('bbb.h', r"""
77 void bbb(void);
78 """)
80 test.write('bbb.cpp', r"""
81 #include "my_qobject.h"
82 void bbb(void) Q_OBJECT
83 #include "bbb.moc"
84 """)
86 test.write(['ui', 'ccc.ui'], r"""
87 void ccc(void)
88 """)
90 test.write('ddd.cpp', r"""
91 #include "ddd.h"
92 """)
94 test.write(['include', 'ddd.h'], r"""
95 #include "my_qobject.h"
96 void ddd(void) Q_OBJECT;
97 """)
99 test.write('eee.h', r"""
100 void eee(void);
101 """)
103 test.write('eee.cpp', r"""
104 #include "my_qobject.h"
105 void eee(void) Q_OBJECT
106 #include "moc_eee.cpp"
107 """)
109 test.write(['ui', 'fff.ui'], r"""
110 void fff(void)
111 """)
113 test.write('main.cpp', r"""
114 #include "aaa.h"
115 #include "bbb.h"
116 #include "ui/ccc.h"
117 #include "ddd.h"
118 #include "eee.h"
119 #include "uic_fff.hpp"
121 int main(void) {
122 aaa(); bbb(); ccc(); ddd(); eee(); fff(); return 0;
124 """)
126 test.run(arguments="--warn=no-tool-qt-deprecated " + aaa_exe)
128 # normal invocation
129 test.must_exist(test.workpath('include', 'moc_aaa.cc'))
130 test.must_exist(test.workpath('bbb.moc'))
131 test.must_exist(test.workpath('ui', 'ccc.h'))
132 test.must_exist(test.workpath('ui', 'uic_ccc.cc'))
133 test.must_exist(test.workpath('ui', 'moc_ccc.cc'))
135 # manual target spec.
136 test.must_exist(test.workpath('moc-ddd.cpp'))
137 test.must_exist(test.workpath('moc_eee.cpp'))
138 test.must_exist(test.workpath('include', 'uic_fff.hpp'))
139 test.must_exist(test.workpath('fff.cpp'))
140 test.must_exist(test.workpath('fff.moc.cpp'))
142 test.pass_test()
144 # Local Variables:
145 # tab-width:4
146 # indent-tabs-mode:nil
147 # End:
148 # vim: set expandtab tabstop=4 shiftwidth=4: