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.
27 Verify that the swig tool generates file names that we expect.
35 test
= TestSCons
.TestSCons()
37 _python_
= TestSCons
._python
_
39 test
.write('myswig.py', """\
43 opts, args = getopt.getopt(sys.argv[1:], "c:o:v:")
49 elif opt == "-v" and arg == "ersion":
51 print("SWIG Version 0.1.2")
53 print("Compiled with g++ [x86_64-pc-linux-gnu]")
55 print("Configured options: +pcre")
57 print("Please see https://www.swig.org for reporting bugs "
58 "and further information")
61 with open(args[0], "r") as ifp, open(out, "w") as ofp:
63 if not line.startswith("swig"):
68 test
.write('SConstruct', """\
69 env = Environment(tools=["default", "swig"], SWIG=[r"%(_python_)s", "myswig.py"])
70 print(env.subst("Using SWIG $SWIGVERSION"))
71 env.Program(target="test1", source="test1.i")
72 env.CFile(target="test2", source="test2.i")
73 env.Clone(SWIGFLAGS="-c++").Program(target="test3", source="test3.i")
76 test
.write('test1.i', r
"""
80 main(int argc, char *argv[]) {
88 test
.write('test2.i', r
"""test2.i
92 test
.write('test3.i', r
"""
96 main(int argc, char *argv[]) {
104 test
.run(arguments
='.', stderr
=None, stdout
=r
'.*Using SWIG 0.1.2.*',
105 match
=TestSCons
.match_re_dotall
)
107 test
.run(program
=test
.workpath('test1' + _exe
), stdout
="test1.i\n")
108 test
.must_exist(test
.workpath('test1_wrap.c'))
109 test
.must_exist(test
.workpath('test1_wrap' + _obj
))
111 test
.must_match('test2_wrap.c', "test2.i\n", mode
='r')
113 test
.run(program
=test
.workpath('test3' + _exe
), stdout
="test3.i\n")
114 test
.must_exist(test
.workpath('test3_wrap.cc'))
115 test
.must_exist(test
.workpath('test3_wrap' + _obj
))
121 # indent-tabs-mode:nil
123 # vim: set expandtab tabstop=4 shiftwidth=4: