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 dependencies on SWIG-generated .java files work correctly.
29 Test case courtesy Jonathan (toolshed@tigris.org).
34 test
= TestSCons
.TestSCons()
36 swig
= test
.where_is('swig')
38 test
.skip_test('Can not find installed "swig", skipping test.\n')
40 where_javac
, java_version
= test
.java_where_javac()
41 where_java_include
=test
.java_where_includes()
47 test
.write(['SConstruct'], """\
50 _ = DefaultEnvironment(tools=[])
51 env = Environment(ENV=os.environ)
52 if env['PLATFORM'] != 'win32':
53 env.Append(CPPFLAGS=' -g -Wall')
54 env['CPPPATH'] = '$JAVAINCLUDES'
58 SConscript('#foo/SConscript')
59 SConscript('#java/SConscript')
62 test
.write(['foo', 'SConscript'], """\
65 env.SharedLibrary('foo', 'foo.cpp')
68 test
.write(['foo', 'foo.cpp'], """\
71 int fooAdd(int a, int b) {
76 test
.write(['foo', 'foo.h'], """\
83 test
.write(['java', 'Java_foo_interface.i'], """\
101 test
.write(['java', 'SConscript'], """\
109 env.Prepend(CPPPATH = ['#foo',])
115 #swigflags = '-c++ -java -Wall -package foopack -Ifoo'
116 swigflags = '-c++ -java -Wall -Ifoo -DTEST_$PLATFORM'
118 Java_foo_interface = env.SharedLibrary(
119 'Java_foo_interface',
120 'Java_foo_interface.i',
123 SWIGFLAGS = swigflags,
124 SWIGOUTDIR = Dir('build'),
125 SWIGCXXFILESUFFIX = "_wrap.cpp")
127 foopack_jar_javac = env.Java('classes', 'build')
129 env['JARCHDIR'] = 'java/classes'
130 foopack_jar = env.Jar(target = 'foopack.jar', source = 'classes')
133 # Disable looking at stderr because some combinations of SWIG/gcc
134 # generate a warning about the sWIG_JavaThrowException() function
135 # being defined but not used.
137 test
.run(arguments
= '.', stderr
=None)
139 # catch exception which is causing failure for issue not related to java.
140 # Bug ticket reported also this seems work fine when running outsite
142 test
.skip_test('Throwing no result for this test because of bug ' +
143 'related here: https://github.com/SCons/scons/issues/2907\n')
144 #test.must_exist(['java', 'classes', 'foopack', 'foopack.class'])
145 #test.must_exist(['java', 'classes', 'foopack', 'foopackJNI.class'])
146 test
.must_exist(['java', 'classes', 'foopack.class'])
147 test
.must_exist(['java', 'classes', 'foopackJNI.class'])
149 test
.up_to_date(arguments
= '.')
155 # indent-tabs-mode:nil
157 # vim: set expandtab tabstop=4 shiftwidth=4: