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 use of $JAVASOURCEPATH allows finding Java .class
28 files in alternate locations by adding the -classpath option
29 to the javac command line.
36 _python_
= TestSCons
._python
_
38 test
= TestSCons
.TestSCons()
40 where_javac
, java_version
= test
.java_where_javac()
41 where_javah
= test
.java_where_javah()
43 # TODO rework for 'javac -h', for now skip
44 # The logical test would be: if java_version > 9:
45 # but java_where_javah() roots around and will find from an older version
46 if not test
.Environment().WhereIs('javah'):
47 test
.skip_test("No Java javah for version > 9, skipping test.\n")
49 # On some systems, the alternatives system does not remove javah even if the
50 # preferred Java doesn't have it, so try another check
51 javacdir
= pathlib
.Path(where_javac
).parent
52 javahdir
= pathlib
.Path(where_javah
).parent
53 if javacdir
!= javahdir
:
54 test
.skip_test("Cannot find Java javah matching javac, skipping test.\n")
56 test
.write('SConstruct', """
57 DefaultEnvironment(tools=[])
58 env = Environment(tools=['javac', 'javah'])
59 j1 = env.Java(target='class1', source='com.1/Example1.java')
60 j2 = env.Java(target='class2', source='com.2/Example2.java')
61 env.JavaH(target='outdir', source=[j1, j2], JAVACLASSPATH='class2')
64 test
.subdir('com.1', 'com.2')
66 test
.write(['com.1', 'Example1.java'], """\
72 public static void main(String[] args)
80 test
.write(['com.2', 'Example2.java'], """\
86 public static void main(String[] args)
94 test
.run(arguments
= '.')
96 test
.must_exist(['class1', 'com', 'Example1.class'])
97 test
.must_exist(['class2', 'com', 'Example2.class'])
99 test
.must_exist(['outdir', 'com_Example1.h'])
100 test
.must_exist(['outdir', 'com_Example2.h'])
102 test
.up_to_date(arguments
= '.')
108 # indent-tabs-mode:nil
110 # vim: set expandtab tabstop=4 shiftwidth=4: