From: stevenknight Date: Sun, 21 Nov 2004 21:14:41 +0000 (+0000) Subject: More command-line output customizability: , , , . X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=575f69102ce2e96a3ec3640701ef8c42989ad3f1;p=scons.git More command-line output customizability: , , , . git-svn-id: http://scons.tigris.org/svn/scons/trunk@1174 fdb21ef1-2011-0410-befe-b5e4ea1792b1 --- diff --git a/doc/man/scons.1 b/doc/man/scons.1 index e73bada0..2f504a69 100644 --- a/doc/man/scons.1 +++ b/doc/man/scons.1 @@ -5494,6 +5494,15 @@ option). .IP JARCOM The command line used to call the Java archive tool. +.IP JARCOMSTR +The string displayed when the Java archive tool +is called +If this is not set, then $JARCOM (the command line) is displayed. + +.ES +env = Environment(JARCOMSTR = "JARchiving $SOURCES into $TARGET") +.EE + .IP JARFLAGS General options passed to the Java archive tool. By default this is set to @@ -5517,6 +5526,16 @@ corresponding Java class files. Any options specified in the $JAVACFLAGS construction variable are included on this command line. +.IP JAVACCOMSTR +The string displayed when compiling +a directory tree of Java source files to +corresponding Java class files. +If this is not set, then $JAVACCOM (the command line) is displayed. + +.ES +env = Environment(JAVACCOMSTR = "Compiling class files $TARGETS from $SOURCES") +.EE + .IP JAVACFLAGS General options that are passed to the Java compiler. @@ -5541,6 +5560,15 @@ from Java classes. Any options specified in the $JAVAHFLAGS construction variable are included on this command line. +.IP JAVAHCOMSTR +The string displayed when C header and stub files +are generated from Java classes. +If this is not set, then $JAVAHCOM (the command line) is displayed. + +.ES +env = Environment(JAVAHCOMSTR = "Generating header/stub file(s) $TARGETS from $SOURCES") +.EE + .IP JAVAHFLAGS General options passed to the C header and stub file generator for Java classes. @@ -6258,6 +6286,16 @@ from Java classes that contain RMI implementations. Any options specified in the $RMICFLAGS construction variable are included on this command line. +.IP RMICCOMSTR +The string displayed when compiling +stub and skeleton class files +from Java classes that contain RMI implementations. +If this is not set, then $RMICCOM (the command line) is displayed. + +.ES +env = Environment(RMICCOMSTR = "Generating stub/skeleton class files $TARGETS from $SOURCES") +.EE + .IP RMICFLAGS General options passed to the Java RMI stub compiler. diff --git a/src/CHANGES.txt b/src/CHANGES.txt index 326f9cf2..62d691a0 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -133,10 +133,12 @@ RELEASE 0.97 - XXX - Support easier customization of what's displayed by various default actions by adding new construction variables: $ARCOMSTR, $ASCOMSTR, $ASPPCOMSTR, $BITKEEPERCOMSTR, $CCCOMSTR, $CVSCOMSTR, $CXXCOMSTR, - $F77COMSTR, $F90COMSTR, $F95COMSTR, $FORTRANCOMSTR, $LEXCOMSTR, - $LINKCOMSTR, $RCSCOMSTR, $SCCSCOMSTR, $SHCCCOMSTR, $SHCXXCOMSTR, - $SHF77COMSTR, $SHF90COMSTR, $SHF95COMSTR, $SHFORTRANCOMSTR, - $SHLINKCOMSTR and $YACCCOMSTR. + $F77COMSTR, $F90COMSTR, $F95COMSTR, $FORTRANCOMSTR, $JARCOMSTR, + $JAVACCOMSTR, $JAVAHCOMSTR, $LEXCOMSTR, $LINKCOMSTR, $RCSCOMSTR, + $RMICCOMSTR, $SCCSCOMSTR, $SHCCCOMSTR, $SHCXXCOMSTR, $SHF77COMSTR, + $SHF90COMSTR, $SHF95COMSTR, $SHFORTRANCOMSTR, $SHLINKCOMSTR and + $YACCCOMSTR. + From Wayne Lee: diff --git a/src/engine/SCons/Tool/jar.py b/src/engine/SCons/Tool/jar.py index 3c5e5f54..a721d96d 100644 --- a/src/engine/SCons/Tool/jar.py +++ b/src/engine/SCons/Tool/jar.py @@ -33,6 +33,7 @@ selection method. __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" +import SCons.Action import SCons.Builder import SCons.Util @@ -77,8 +78,10 @@ def jarChdir(target, source, env, for_signature): if env.has_key('JARCHDIR'): return [ '-C', '$JARCHDIR' ] return [] - -JarBuilder = SCons.Builder.Builder(action = '$JARCOM', + +JarAction = SCons.Action.Action('$JARCOM', '$JARCOMSTR') + +JarBuilder = SCons.Builder.Builder(action = JarAction, source_factory = SCons.Node.FS.default_fs.Entry, suffix = '$JARSUFFIX') diff --git a/src/engine/SCons/Tool/javac.py b/src/engine/SCons/Tool/javac.py index e16f6d0c..e6a0fc37 100644 --- a/src/engine/SCons/Tool/javac.py +++ b/src/engine/SCons/Tool/javac.py @@ -37,6 +37,7 @@ import os import os.path import string +import SCons.Action import SCons.Builder from SCons.Node.FS import _my_normcase from SCons.Tool.JavaCommon import parse_java_file @@ -91,7 +92,9 @@ def emit_java_classes(target, source, env): return tlist, slist -JavaBuilder = SCons.Builder.Builder(action = '$JAVACCOM', +JavaAction = SCons.Action.Action('$JAVACCOM', '$JAVACCOMSTR') + +JavaBuilder = SCons.Builder.Builder(action = JavaAction, emitter = emit_java_classes, target_factory = SCons.Node.FS.default_fs.Dir, source_factory = SCons.Node.FS.default_fs.Dir) diff --git a/src/engine/SCons/Tool/javah.py b/src/engine/SCons/Tool/javah.py index 8f69a461..4d5749a1 100644 --- a/src/engine/SCons/Tool/javah.py +++ b/src/engine/SCons/Tool/javah.py @@ -36,6 +36,7 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import os.path import string +import SCons.Action import SCons.Builder import SCons.Node.FS import SCons.Tool.javac @@ -105,7 +106,9 @@ def JavaHOutFlagGenerator(target, source, env, for_signature): except AttributeError: return '-o ' + str(t) -JavaHBuilder = SCons.Builder.Builder(action = '$JAVAHCOM', +JavaHAction = SCons.Action.Action('$JAVAHCOM', '$JAVAHCOMSTR') + +JavaHBuilder = SCons.Builder.Builder(action = JavaHAction, emitter = emit_java_headers, src_suffix = '$JAVACLASSSUFFIX', target_factory = SCons.Node.FS.default_fs.Entry, diff --git a/src/engine/SCons/Tool/rmic.py b/src/engine/SCons/Tool/rmic.py index 465bd68f..c5c4854a 100644 --- a/src/engine/SCons/Tool/rmic.py +++ b/src/engine/SCons/Tool/rmic.py @@ -36,6 +36,7 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import os.path import string +import SCons.Action import SCons.Builder import SCons.Node.FS import SCons.Util @@ -89,7 +90,9 @@ def emit_rmic_classes(target, source, env): return tlist, source -RMICBuilder = SCons.Builder.Builder(action = '$RMICCOM', +RMICAction = SCons.Action.Action('$RMICCOM', '$RMICCOMSTR') + +RMICBuilder = SCons.Builder.Builder(action = RMICAction, emitter = emit_rmic_classes, src_suffix = '$JAVACLASSSUFFIX', target_factory = SCons.Node.FS.default_fs.Dir, diff --git a/test/JAR.py b/test/Java/JAR.py similarity index 100% rename from test/JAR.py rename to test/Java/JAR.py diff --git a/test/Java/JARCOM.py b/test/Java/JARCOM.py new file mode 100644 index 00000000..0d7ebba0 --- /dev/null +++ b/test/Java/JARCOM.py @@ -0,0 +1,65 @@ +#!/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__" + +""" +Test the ability to configure the $JARCOM construction variable. +""" + +import TestSCons + +python = TestSCons.python + +test = TestSCons.TestSCons() + + + +test.write('myjar.py', r""" +import sys +outfile = open(sys.argv[1], 'wb') +for f in sys.argv[2:]: + infile = open(f, 'rb') + for l in filter(lambda l: l != '/*jar*/\n', infile.readlines()): + outfile.write(l) +sys.exit(0) +""") + +test.write('SConstruct', """ +env = Environment(TOOLS = ['default', 'jar'], + JARCOM = r'%(python)s myjar.py $TARGET $SOURCES') +env.Jar(target = 'test1', source = ['file1.in', 'file2.in', 'file3.in']) +""" % locals()) + +test.write('file1.in', "file1.in\n/*jar*/\n") +test.write('file2.in', "file2.in\n/*jar*/\n") +test.write('file3.in', "file3.in\n/*jar*/\n") + +test.run() + +test.must_match('test1.jar', "file1.in\nfile2.in\nfile3.in\n") + + + +test.pass_test() diff --git a/test/Java/JARCOMSTR.py b/test/Java/JARCOMSTR.py new file mode 100644 index 00000000..aa8a6ad5 --- /dev/null +++ b/test/Java/JARCOMSTR.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__" + +""" +Test that the $JARCOMSTR construction variable allows you to configure +the jar output. +""" + +import TestSCons + +python = TestSCons.python + +test = TestSCons.TestSCons() + + + +test.write('myjar.py', r""" +import sys +outfile = open(sys.argv[1], 'wb') +for f in sys.argv[2:]: + infile = open(f, 'rb') + for l in filter(lambda l: l != '/*jar*/\n', infile.readlines()): + outfile.write(l) +sys.exit(0) +""") + +test.write('SConstruct', """ +env = Environment(TOOLS = ['default', 'jar'], + JARCOM = r'%(python)s myjar.py $TARGET $SOURCES', + JARCOMSTR = "Jar'ing up $TARGET from $SOURCES") +env.Jar(target = 'test1', source = ['file1.in', 'file2.in', 'file3.in']) +""" % locals()) + +test.write('file1.in', "file1.in\n/*jar*/\n") +test.write('file2.in', "file2.in\n/*jar*/\n") +test.write('file3.in', "file3.in\n/*jar*/\n") + +test.run(stdout = test.wrap_stdout("""\ +Jar'ing up test1.jar from file1.in file2.in file3.in +""")) + +test.must_match('test1.jar', "file1.in\nfile2.in\nfile3.in\n") + + + +test.pass_test() diff --git a/test/JARFLAGS.py b/test/Java/JARFLAGS.py similarity index 100% rename from test/JARFLAGS.py rename to test/Java/JARFLAGS.py diff --git a/test/JAVAC.py b/test/Java/JAVAC.py similarity index 100% rename from test/JAVAC.py rename to test/Java/JAVAC.py diff --git a/test/Java/JAVACCOM.py b/test/Java/JAVACCOM.py new file mode 100644 index 00000000..171649c1 --- /dev/null +++ b/test/Java/JAVACCOM.py @@ -0,0 +1,68 @@ +#!/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__" + +""" +Test the ability to configure the $JAVACCOM construction variable. +""" + +import TestSCons + +python = TestSCons.python + +test = TestSCons.TestSCons() + +test.subdir('src') + + + +test.write('myjavac.py', r""" +import sys +outfile = open(sys.argv[1], 'wb') +for f in sys.argv[2:]: + infile = open(f, 'rb') + for l in filter(lambda l: l != '/*javac*/\n', infile.readlines()): + outfile.write(l) +sys.exit(0) +""") + +test.write('SConstruct', """ +env = Environment(TOOLS = ['default', 'javac'], + JAVACCOM = r'%(python)s myjavac.py $TARGET $SOURCES') +env.Java(target = 'classes', source = 'src') +""" % locals()) + +test.write(['src', 'file1.java'], "file1.java\n/*javac*/\n") +test.write(['src', 'file2.java'], "file2.java\n/*javac*/\n") +test.write(['src', 'file3.java'], "file3.java\n/*javac*/\n") + +test.run() + +test.must_match(['classes', 'src', 'file1.class'], + "file1.java\nfile2.java\nfile3.java\n") + + + +test.pass_test() diff --git a/test/Java/JAVACCOMSTR.py b/test/Java/JAVACCOMSTR.py new file mode 100644 index 00000000..306ae57a --- /dev/null +++ b/test/Java/JAVACCOMSTR.py @@ -0,0 +1,72 @@ +#!/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__" + +""" +Test that the $JAVACCOMSTR construction variable allows you to configure +the javac output. +""" + +import TestSCons + +python = TestSCons.python + +test = TestSCons.TestSCons() + +test.subdir('src') + + + +test.write('myjavac.py', r""" +import sys +outfile = open(sys.argv[1], 'wb') +for f in sys.argv[2:]: + infile = open(f, 'rb') + for l in filter(lambda l: l != '/*javac*/\n', infile.readlines()): + outfile.write(l) +sys.exit(0) +""") + +test.write('SConstruct', """ +env = Environment(TOOLS = ['default', 'javac'], + JAVACCOM = r'%(python)s myjavac.py $TARGET $SOURCES', + JAVACCOMSTR = "Compiling class(es) $TARGET from $SOURCES") +env.Java(target = 'classes', source = 'src') +""" % locals()) + +test.write(['src', 'file1.java'], "file1.java\n/*javac*/\n") +test.write(['src', 'file2.java'], "file2.java\n/*javac*/\n") +test.write(['src', 'file3.java'], "file3.java\n/*javac*/\n") + +test.run(stdout = test.wrap_stdout("""\ +Compiling class(es) classes/src/file1.class from src/file1.java src/file2.java src/file3.java +""")) + +test.must_match(['classes', 'src', 'file1.class'], + "file1.java\nfile2.java\nfile3.java\n") + + + +test.pass_test() diff --git a/test/JAVACFLAGS.py b/test/Java/JAVACFLAGS.py similarity index 100% rename from test/JAVACFLAGS.py rename to test/Java/JAVACFLAGS.py diff --git a/test/JAVAH.py b/test/Java/JAVAH.py similarity index 100% rename from test/JAVAH.py rename to test/Java/JAVAH.py diff --git a/test/Java/JAVAHCOM.py b/test/Java/JAVAHCOM.py new file mode 100644 index 00000000..1cc4208f --- /dev/null +++ b/test/Java/JAVAHCOM.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__" + +""" +Test the ability to configure the $JAVAHCOM construction variable. +""" + +import TestSCons + +python = TestSCons.python + +test = TestSCons.TestSCons() + + + +test.write('myjavah.py', r""" +import sys +outfile = open(sys.argv[1], 'wb') +for f in sys.argv[2:]: + infile = open(f, 'rb') + for l in filter(lambda l: l != '/*javah*/\n', infile.readlines()): + outfile.write(l) +sys.exit(0) +""") + +test.write('SConstruct', """ +env = Environment(TOOLS = ['default', 'javah'], + JAVAHCOM = r'%(python)s myjavah.py $TARGET $SOURCES') +env.JavaH(target = 'out', source = 'file1.class') +env.JavaH(target = 'out', source = 'file2.class') +env.JavaH(target = 'out', source = 'file3.class') +""" % locals()) + +test.write('file1.class', "file1.class\n/*javah*/\n") +test.write('file2.class', "file2.class\n/*javah*/\n") +test.write('file3.class', "file3.class\n/*javah*/\n") + +test.run() + +test.must_match(['out', 'file1.h'], "file1.class\n") +test.must_match(['out', 'file2.h'], "file2.class\n") +test.must_match(['out', 'file3.h'], "file3.class\n") + + + +test.pass_test() diff --git a/test/Java/JAVAHCOMSTR.py b/test/Java/JAVAHCOMSTR.py new file mode 100644 index 00000000..2a14e1ce --- /dev/null +++ b/test/Java/JAVAHCOMSTR.py @@ -0,0 +1,85 @@ +#!/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__" + +""" +Test that the $JAVAHCOMSTR construction variable allows you to configure +the javah output. +""" + +import os.path + +import TestSCons + +python = TestSCons.python + +test = TestSCons.TestSCons() + +test.subdir('src') + + + +out_file1_h = os.path.join('out', 'file1.h') +out_file2_h = os.path.join('out', 'file2.h') +out_file3_h = os.path.join('out', 'file3.h') + + + +test.write('myjavah.py', r""" +import sys +outfile = open(sys.argv[1], 'wb') +for f in sys.argv[2:]: + infile = open(f, 'rb') + for l in filter(lambda l: l != '/*javah*/\n', infile.readlines()): + outfile.write(l) +sys.exit(0) +""") + +test.write('SConstruct', """ +env = Environment(TOOLS = ['default', 'javah'], + JAVAHCOM = r'%(python)s myjavah.py $TARGET $SOURCES', + JAVAHCOMSTR = 'Building javah $TARGET from $SOURCES') +env.JavaH(target = 'out', source = 'file1.class') +env.JavaH(target = 'out', source = 'file2.class') +env.JavaH(target = 'out', source = 'file3.class') +""" % locals()) + +test.write('file1.class', "file1.class\n/*javah*/\n") +test.write('file2.class', "file2.class\n/*javah*/\n") +test.write('file3.class', "file3.class\n/*javah*/\n") + +test.run(stdout = test.wrap_stdout("""\ +Building javah %(out_file1_h)s from file1.class +Building javah %(out_file2_h)s from file2.class +Building javah %(out_file3_h)s from file3.class +""" % locals())) + +test.must_match(['out', 'file1.h'], "file1.class\n") +test.must_match(['out', 'file2.h'], "file2.class\n") +test.must_match(['out', 'file3.h'], "file3.class\n") + + + +test.pass_test() diff --git a/test/RMIC.py b/test/Java/RMIC.py similarity index 100% rename from test/RMIC.py rename to test/Java/RMIC.py diff --git a/test/Java/RMICCOM.py b/test/Java/RMICCOM.py new file mode 100644 index 00000000..109c22e7 --- /dev/null +++ b/test/Java/RMICCOM.py @@ -0,0 +1,79 @@ +#!/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__" + +""" +Test the ability to configure the $RMICCOM construction variable. +""" + +import os.path + +import TestSCons + +python = TestSCons.python + +test = TestSCons.TestSCons() + +test.subdir('src') + + + +out_file1 = os.path.join('out', 'file1', 'class_Skel.class') +out_file2 = os.path.join('out', 'file2', 'class_Skel.class') +out_file3 = os.path.join('out', 'file3', 'class_Skel.class') + + + +test.write('myrmic.py', r""" +import sys +outfile = open(sys.argv[1], 'wb') +for f in sys.argv[2:]: + infile = open(f, 'rb') + for l in filter(lambda l: l != '/*rmic*/\n', infile.readlines()): + outfile.write(l) +sys.exit(0) +""") + +test.write('SConstruct', """ +env = Environment(TOOLS = ['default', 'rmic'], + RMICCOM = r'%(python)s myrmic.py $TARGET $SOURCES') +env.RMIC(target = 'out', source = 'file1.class') +env.RMIC(target = 'out', source = 'file2.class') +env.RMIC(target = 'out', source = 'file3.class') +""" % locals()) + +test.write('file1.class', "file1.class\n/*rmic*/\n") +test.write('file2.class', "file2.class\n/*rmic*/\n") +test.write('file3.class', "file3.class\n/*rmic*/\n") + +test.run() + +test.must_match(out_file1, "file1.class\n") +test.must_match(out_file2, "file2.class\n") +test.must_match(out_file3, "file3.class\n") + + + +test.pass_test() diff --git a/test/Java/RMICCOMSTR.py b/test/Java/RMICCOMSTR.py new file mode 100644 index 00000000..1bcf300a --- /dev/null +++ b/test/Java/RMICCOMSTR.py @@ -0,0 +1,85 @@ +#!/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__" + +""" +Test that the $RMICCOMSTR construction variable allows you to configure +the rmic output. +""" + +import os.path + +import TestSCons + +python = TestSCons.python + +test = TestSCons.TestSCons() + +test.subdir('src') + + + +out_file1 = os.path.join('out', 'file1', 'class_Skel.class') +out_file2 = os.path.join('out', 'file2', 'class_Skel.class') +out_file3 = os.path.join('out', 'file3', 'class_Skel.class') + + + +test.write('myrmic.py', r""" +import sys +outfile = open(sys.argv[1], 'wb') +for f in sys.argv[2:]: + infile = open(f, 'rb') + for l in filter(lambda l: l != '/*rmic*/\n', infile.readlines()): + outfile.write(l) +sys.exit(0) +""") + +test.write('SConstruct', """ +env = Environment(TOOLS = ['default', 'rmic'], + RMICCOM = r'%(python)s myrmic.py $TARGET $SOURCES', + RMICCOMSTR = 'Building rmic $TARGET from $SOURCES') +env.RMIC(target = 'out', source = 'file1.class') +env.RMIC(target = 'out', source = 'file2.class') +env.RMIC(target = 'out', source = 'file3.class') +""" % locals()) + +test.write('file1.class', "file1.class\n/*rmic*/\n") +test.write('file2.class', "file2.class\n/*rmic*/\n") +test.write('file3.class', "file3.class\n/*rmic*/\n") + +test.run(stdout = test.wrap_stdout("""\ +Building rmic %(out_file1)s from file1.class +Building rmic %(out_file2)s from file2.class +Building rmic %(out_file3)s from file3.class +""" % locals())) + +test.must_match(out_file1, "file1.class\n") +test.must_match(out_file2, "file2.class\n") +test.must_match(out_file3, "file3.class\n") + + + +test.pass_test()