From b967a4a50e7ad193583412bc5a585acde1fddbe7 Mon Sep 17 00:00:00 2001 From: Steven Knight Date: Sun, 6 Apr 2003 15:40:59 +0000 Subject: Java! --- doc/man/scons.1 | 63 ++++++++++- src/CHANGES.txt | 4 + src/engine/MANIFEST.in | 2 + src/engine/SCons/Tool/__init__.py | 1 + src/engine/SCons/Tool/jar.py | 58 +++++++++++ src/engine/SCons/Tool/javac.py | 82 +++++++++++++++ test/JAR.py | 212 +++++++++++++++++++++++++++++++++++++ test/JARFLAGS.py | 69 ++++++++++++ test/JAVAC.py | 214 ++++++++++++++++++++++++++++++++++++++ test/JAVACFLAGS.py | 61 +++++++++++ 10 files changed, 764 insertions(+), 2 deletions(-) create mode 100644 src/engine/SCons/Tool/jar.py create mode 100644 src/engine/SCons/Tool/javac.py create mode 100644 test/JAR.py create mode 100644 test/JARFLAGS.py create mode 100644 test/JAVAC.py create mode 100644 test/JAVACFLAGS.py diff --git a/doc/man/scons.1 b/doc/man/scons.1 index e40036b..410dd8d 100644 --- a/doc/man/scons.1 +++ b/doc/man/scons.1 @@ -856,6 +856,8 @@ ilink gas gcc gnulink +jar +javac latex lex linkloc @@ -954,9 +956,9 @@ env.Program('bar.c') .EE It is possible to override or add construction variables when calling a -builder by passing additional keyword arguments. These overriden or added +builder by passing additional keyword arguments. These overridden or added variables will only be in effect when building the target, so they will not -effect other parts of the build. For example, if you want to add additional +affect other parts of the build. For example, if you want to add additional libraries for just one program: .ES @@ -1244,6 +1246,21 @@ env.CXXFile(target = 'foo.cc', source = 'foo.ll') env.CXXFile(target = 'bar', source = 'bar.yy') .EE +.IP Jar +Builds a Java archive (.jar) file +from a source tree of .class files. +.ES +env.Jar(target = 'foo.jar', source = 'classes') +.EE + +.IP Java +Builds one or more Java class files +from a source tree of .java files. + +.ES +env.Java(target = 'classes', source = 'src') +.EE + .IP DVI Builds a .dvi file from a .tex, .ltx or .latex input file. The suffix .dvi @@ -2240,6 +2257,48 @@ is the construction environment (a dictionary of construction values) in force for this file installation. +.IP JAR +The Java archive tool. + +.IP JARCOM +The command line used to call the Java archive tool. + +.IP JARFLAGS +General options passed to the Java archive tool. +By default this is set to +.B cf +to create the necessary +.I jar +file. + +.IP JARSUFFIX +The suffix for Java archives: +.B .jar +by default. + +.IP JAVAC +The Java compiler. + +.IP JAVACCOM +The command line used to compile a directory tree containing +Java source files to +corresponding Java class files. +Any options specified in the $JAVACFLAGS construction variable +are included on this command line. + +.IP JAVACFLAGS +General options that are passed to the Java compiler. + +.IP JAVACLASSSUFFIX +The suffix for Java class files; +.B .class +by default. + +.IP JAVASUFFIX +The suffix for Java files; +.B .java +by default. + .IP LATEX The LaTeX structured formatter and typesetter. diff --git a/src/CHANGES.txt b/src/CHANGES.txt index 68d1108..a036568 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -10,6 +10,10 @@ RELEASE 0.14 - XXX + From Steven Knight: + + - Add support for Java (javac and jar). + RELEASE 0.13 - Mon, 31 Mar 2003 20:22:00 -0600 diff --git a/src/engine/MANIFEST.in b/src/engine/MANIFEST.in index 0759d8c..8bed06f 100644 --- a/src/engine/MANIFEST.in +++ b/src/engine/MANIFEST.in @@ -43,6 +43,8 @@ SCons/Tool/g77.py SCons/Tool/gas.py SCons/Tool/gcc.py SCons/Tool/gnulink.py +SCons/Tool/javac.py +SCons/Tool/jar.py SCons/Tool/icc.py SCons/Tool/ifl.py SCons/Tool/ilink.py diff --git a/src/engine/SCons/Tool/__init__.py b/src/engine/SCons/Tool/__init__.py index 5eed7f1..ca28471 100644 --- a/src/engine/SCons/Tool/__init__.py +++ b/src/engine/SCons/Tool/__init__.py @@ -202,6 +202,7 @@ def tool_list(platform, env): other_tools = FindAllTools(['BitKeeper', 'CVS', 'dvipdf', 'dvips', + 'jar', 'javac', 'latex', 'lex', 'pdflatex', 'pdftex', 'Perforce', 'RCS', 'SCCS', diff --git a/src/engine/SCons/Tool/jar.py b/src/engine/SCons/Tool/jar.py new file mode 100644 index 0000000..496a823 --- /dev/null +++ b/src/engine/SCons/Tool/jar.py @@ -0,0 +1,58 @@ +"""SCons.Tool.jar + +Tool-specific initialization for jar. + +There normally shouldn't be any need to import this module directly. +It will usually be imported through the generic SCons.Tool.Tool() +selection method. + +""" + +# +# __COPYRIGHT__ +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +import glob +import os.path + +import SCons.Builder + +def generate(env, platform): + """Add Builders and construction variables for jar to an Environment.""" + try: + bld = env['BUILDERS']['Jar'] + except KeyError: + JarBuilder = SCons.Builder.Builder(action = '$JARCOM', + source_factory = SCons.Node.FS.default_fs.Entry, + suffix = '$JARSUFFIX') + + env['BUILDERS']['Jar'] = JarBuilder + + env['JAR'] = 'jar' + env['JARFLAGS'] = 'cf' + env['JARCOM'] = '$JAR $JARFLAGS $TARGET $SOURCE' + env['JARSUFFIX'] = '.jar' + +def exists(env): + return env.Detect('jar') diff --git a/src/engine/SCons/Tool/javac.py b/src/engine/SCons/Tool/javac.py new file mode 100644 index 0000000..fff6de5 --- /dev/null +++ b/src/engine/SCons/Tool/javac.py @@ -0,0 +1,82 @@ +"""SCons.Tool.javac + +Tool-specific initialization for javac. + +There normally shouldn't be any need to import this module directly. +It will usually be imported through the generic SCons.Tool.Tool() +selection method. + +""" + +# +# __COPYRIGHT__ +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +import glob +import os.path + +import SCons.Builder + +def generate(env, platform): + """Add Builders and construction variables for javac to an Environment.""" + try: + bld = env['BUILDERS']['Java'] + except KeyError: + def emit_java_files(target, source, env): + """Create and return lists of source java files + and their corresponding target class files. + """ + env['_JAVACLASSDIR'] = target[0] + env['_JAVASRCDIR'] = source[0] + java_suffix = env.get('JAVASUFFIX', '.java') + class_suffix = env.get('JAVACLASSSUFFIX', '.class') + slist = [] + def visit(arg, dirname, names, js=java_suffix): + java_files = filter(lambda n, js=js: n[-len(js):] == js, names) + java_paths = map(lambda f, d=dirname: + os.path.join(d, f), + java_files) + arg.extend(java_paths) + os.path.walk(source[0], visit, slist) + tlist = map(lambda x, t=target[0], cs=class_suffix: + os.path.join(t, x[:-5] + cs), + slist) + + return tlist, slist + + JavaBuilder = SCons.Builder.Builder(action = '$JAVACCOM', + emitter = emit_java_files, + target_factory = SCons.Node.FS.default_fs.File, + source_factory = SCons.Node.FS.default_fs.File) + + env['BUILDERS']['Java'] = JavaBuilder + + env['JAVAC'] = 'javac' + env['JAVACFLAGS'] = '' + env['JAVACCOM'] = '$JAVAC $JAVACFLAGS -d $_JAVACLASSDIR -sourcepath $_JAVASRCDIR $SOURCES' + env['JAVACLASSSUFFIX'] = '.class' + env['JAVASUFFIX'] = '.java' + +def exists(env): + return env.Detect('javac') diff --git a/test/JAR.py b/test/JAR.py new file mode 100644 index 0000000..f5b3048 --- /dev/null +++ b/test/JAR.py @@ -0,0 +1,212 @@ +#!/usr/bin/env python +# +# __COPYRIGHT__ +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +import os +import string +import sys +import TestSCons + +python = TestSCons.python + +test = TestSCons.TestSCons() + + +test.write('myjar.py', r""" +import sys +args = sys.argv[1:] +while args: + a = args[0] + if a == 'cf': + out = args[1] + args = args[1:] + else: + break + args = args[1:] +outfile = open(out, 'wb') +for file in args: + infile = open(file, 'rb') + for l in infile.readlines(): + if l[:7] != '/*jar*/': + outfile.write(l) +sys.exit(0) +""") + +test.write('SConstruct', """ +env = Environment(tools = ['jar'], + JAR = r'%s myjar.py') +env.Jar(target = 'test1.jar', source = 'test1.class') +""" % (python)) + +test.write('test1.class', """\ +test1.class +/*jar*/ +line 3 +""") + +test.run(arguments = '.', stderr = None) + +test.fail_test(test.read('test1.jar') != "test1.class\nline 3\n") + +if os.path.normcase('.class') == os.path.normcase('.CLASS'): + + test.write('SConstruct', """ +env = Environment(tools = ['jar'], + JAR = r'%s myjar.py') +env.Program(target = 'test2.jar', source = 'test2.CLASS') +""" % (python)) + + test.write('test2.CLASS', """\ +test2.CLASS +/*jar*/ +line 3 +""") + + test.run(arguments = '.', stderr = None) + + test.fail_test(test.read('test2' + _exe) != "test2.CLASS\nline 3\n") + + + + +test.write("wrapper.py", """\ +import os +import string +import sys +open('%s', 'ab').write("wrapper.py %%s\\n" %% string.join(sys.argv[1:])) +os.system(string.join(sys.argv[1:], " ")) +""" % string.replace(test.workpath('wrapper.out'), '\\', '\\\\')) + +test.write('SConstruct', """ +foo = Environment(tools = ['javac', 'jar'], + JAVAC = '/usr/local/j2sdk1.3.1/bin/javac', + JAR = '/usr/local/j2sdk1.3.1/bin/jar') +jar = foo.Dictionary('JAR') +bar = foo.Copy(JAR = r'%s wrapper.py ' + jar) +foo.Java(target = 'classes', source = 'com/sub/foo') +bar.Java(target = 'classes', source = 'com/sub/bar') +foo.Jar(target = 'foo', source = 'classes/com/sub/foo') +bar.Jar(target = 'bar', source = 'classes/com/sub/bar') +""" % python) + +test.subdir('com', + ['com', 'sub'], + ['com', 'sub', 'foo'], + ['com', 'sub', 'bar']) + +test.write(['com', 'sub', 'foo', 'Example1.java'], """\ +package com.sub.foo; + +public class Example1 +{ + + public static void main(String[] args) + { + + } + +} +""") + +test.write(['com', 'sub', 'foo', 'Example2.java'], """\ +package com.sub.foo; + +public class Example2 +{ + + public static void main(String[] args) + { + + } + +} +""") + +test.write(['com', 'sub', 'foo', 'Example3.java'], """\ +package com.sub.foo; + +public class Example3 +{ + + public static void main(String[] args) + { + + } + +} +""") + +test.write(['com', 'sub', 'bar', 'Example4.java'], """\ +package com.sub.bar; + +public class Example4 +{ + + public static void main(String[] args) + { + + } + +} +""") + +test.write(['com', 'sub', 'bar', 'Example5.java'], """\ +package com.sub.bar; + +public class Example5 +{ + + public static void main(String[] args) + { + + } + +} +""") + +test.write(['com', 'sub', 'bar', 'Example6.java'], """\ +package com.sub.bar; + +public class Example6 +{ + + public static void main(String[] args) + { + + } + +} +""") + +test.run(arguments = '.') + +test.fail_test(test.read('wrapper.out') != "wrapper.py /usr/local/j2sdk1.3.1/bin/jar cf bar.jar classes/com/sub/bar\n") + +test.fail_test(not os.path.exists(test.workpath('foo.jar'))) +test.fail_test(not os.path.exists(test.workpath('bar.jar'))) + +test.up_to_date(arguments = '.') + +test.pass_test() diff --git a/test/JARFLAGS.py b/test/JARFLAGS.py new file mode 100644 index 0000000..af5b89d --- /dev/null +++ b/test/JARFLAGS.py @@ -0,0 +1,69 @@ +#!/usr/bin/env python +# +# __COPYRIGHT__ +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +import os.path + +import TestSCons + +test = TestSCons.TestSCons() + +test.subdir('src') + +test.write('SConstruct', """ +env = Environment(tools = ['javac', 'jar'], + JAVAC = '/usr/local/j2sdk1.3.1/bin/javac', + JAR = '/usr/local/j2sdk1.3.1/bin/jar', + JARFLAGS = 'cvf') +env['JARFLAGS'] = 'cvf' +class_files = env.Java(target = 'classes', source = 'src') +env.Jar(target = 'test.jar', source = class_files) +""") + +test.write(['src', 'Example1.java'], """\ +package src; + +public class Example1 +{ + + public static void main(String[] args) + { + + } + +} +""") + +test.run(arguments = '.', + stdout = test.wrap_stdout("""\ +/usr/local/j2sdk1.3.1/bin/javac -d classes -sourcepath src src/Example1.java +/usr/local/j2sdk1.3.1/bin/jar cvf test.jar classes/src/Example1.class +added manifest +adding: classes/src/Example1.class(in = 265) (out= 199)(deflated 24%) +""")) + +test.fail_test(not os.path.exists(test.workpath('test.jar'))) + +test.pass_test() diff --git a/test/JAVAC.py b/test/JAVAC.py new file mode 100644 index 0000000..61d8d4b --- /dev/null +++ b/test/JAVAC.py @@ -0,0 +1,214 @@ +#!/usr/bin/env python +# +# __COPYRIGHT__ +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +import os +import string +import sys +import TestSCons + +python = TestSCons.python + +test = TestSCons.TestSCons() + + + +test.write('myjavac.py', r""" +import sys +args = sys.argv[1:] +while args: + a = args[0] + if a == '-d': + args = args[1:] + elif a == '-sourcepath': + args = args[1:] + else: + break + args = args[1:] +for file in args: + infile = open(file, 'rb') + outfile = open(file[:-5] + '.class', 'wb') + for l in infile.readlines(): + if l[:9] != '/*javac*/': + outfile.write(l) +sys.exit(0) +""") + +test.write('SConstruct', """ +env = Environment(tools = ['javac'], + JAVAC = r'%s myjavac.py') +env.Java(target = '.', source = '.') +""" % (python)) + +test.write('test1.java', """\ +test1.java +/*javac*/ +line 3 +""") + +test.run(arguments = '.', stderr = None) + +test.fail_test(test.read('test1.class') != "test1.java\nline 3\n") + +if os.path.normcase('.java') == os.path.normcase('.JAVA'): + + test.write('SConstruct', """\ +env = Environment(tools = ['javac'], + JAVAC = r'%s myjavac.py') +env.Java(target = '.', source = '.') +""" % (python, python)) + + test.write('test2.JAVA', """\ +test2.JAVA +/*javac*/ +line 3 +""") + + test.run(arguments = '.', stderr = None) + + test.fail_test(test.read('test2.class') != "test2.JAVA\nline3\n") + + + + +test.write("wrapper.py", """\ +import os +import string +import sys +open('%s', 'ab').write("wrapper.py %%s\\n" %% string.join(sys.argv[1:])) +os.system(string.join(sys.argv[1:], " ")) +""" % string.replace(test.workpath('wrapper.out'), '\\', '\\\\')) + +test.write('SConstruct', """ +foo = Environment(tools = ['javac'], + JAVAC = '/usr/local/j2sdk1.3.1/bin/javac') +javac = foo.Dictionary('JAVAC') +bar = foo.Copy(JAVAC = r'%s wrapper.py ' + javac) +foo.Java(target = 'classes', source = 'com/sub/foo') +bar.Java(target = 'classes', source = 'com/sub/bar') +""" % python) + +test.subdir('com', ['com', 'sub'], + ['com', 'sub', 'foo'], + ['com', 'sub', 'bar']) + +test.write(['com', 'sub', 'foo', 'Example1.java'], """\ +package com.sub.foo; + +public class Example1 +{ + + public static void main(String[] args) + { + + } + +} +""") + +test.write(['com', 'sub', 'foo', 'Example2.java'], """\ +package com.sub.foo; + +public class Example2 +{ + + public static void main(String[] args) + { + + } + +} +""") + +test.write(['com', 'sub', 'foo', 'Example3.java'], """\ +package com.sub.foo; + +public class Example3 +{ + + public static void main(String[] args) + { + + } + +} +""") + +test.write(['com', 'sub', 'bar', 'Example4.java'], """\ +package com.sub.bar; + +public class Example4 +{ + + public static void main(String[] args) + { + + } + +} +""") + +test.write(['com', 'sub', 'bar', 'Example5.java'], """\ +package com.sub.bar; + +public class Example5 +{ + + public static void main(String[] args) + { + + } + +} +""") + +test.write(['com', 'sub', 'bar', 'Example6.java'], """\ +package com.sub.bar; + +public class Example6 +{ + + public static void main(String[] args) + { + + } + +} +""") + +test.run(arguments = '.') + +test.fail_test(test.read('wrapper.out') != "wrapper.py /usr/local/j2sdk1.3.1/bin/javac -d classes -sourcepath com/sub/bar com/sub/bar/Example4.java com/sub/bar/Example5.java com/sub/bar/Example6.java\n") + +test.fail_test(not os.path.exists(test.workpath('classes', 'com', 'sub', 'foo', 'Example1.class'))) +test.fail_test(not os.path.exists(test.workpath('classes', 'com', 'sub', 'foo', 'Example2.class'))) +test.fail_test(not os.path.exists(test.workpath('classes', 'com', 'sub', 'foo', 'Example3.class'))) +test.fail_test(not os.path.exists(test.workpath('classes', 'com', 'sub', 'bar', 'Example4.class'))) +test.fail_test(not os.path.exists(test.workpath('classes', 'com', 'sub', 'bar', 'Example5.class'))) +test.fail_test(not os.path.exists(test.workpath('classes', 'com', 'sub', 'bar', 'Example6.class'))) + +test.up_to_date(arguments = '.') + +test.pass_test() diff --git a/test/JAVACFLAGS.py b/test/JAVACFLAGS.py new file mode 100644 index 0000000..1a05e2c --- /dev/null +++ b/test/JAVACFLAGS.py @@ -0,0 +1,61 @@ +#!/usr/bin/env python +# +# __COPYRIGHT__ +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +import os.path + +import TestSCons + +test = TestSCons.TestSCons() + +test.subdir('src') + +test.write('SConstruct', """ +env = Environment(tools = ['javac'], + JAVAC = '/usr/local/j2sdk1.3.1/bin/javac', + JAVACFLAGS = '-O') +env.Java(target = 'classes', source = 'src') +""") + +test.write(['src', 'Example1.java'], """\ +package src; + +public class Example1 +{ + + public static void main(String[] args) + { + + } + +} +""") + +test.run(arguments = '.', + stdout = test.wrap_stdout("/usr/local/j2sdk1.3.1/bin/javac -O -d classes -sourcepath src src/Example1.java\n")) + +test.fail_test(not os.path.exists(test.workpath('classes', 'src', 'Example1.class'))) + +test.pass_test() -- cgit v0.12