diff options
author | Steven Knight <knight@baldmt.com> | 2004-04-02 04:48:40 (GMT) |
---|---|---|
committer | Steven Knight <knight@baldmt.com> | 2004-04-02 04:48:40 (GMT) |
commit | e7b9c76212c0330af15c6ae04b1583d8c9b3cb5e (patch) | |
tree | 43558efa6711652dc12561cbeb55b46b51319cc5 | |
parent | 363ca02b088d5a54fa5b1b125ae4f2b83d1b536e (diff) | |
download | SCons-e7b9c76212c0330af15c6ae04b1583d8c9b3cb5e.zip SCons-e7b9c76212c0330af15c6ae04b1583d8c9b3cb5e.tar.gz SCons-e7b9c76212c0330af15c6ae04b1583d8c9b3cb5e.tar.bz2 |
Support multiple source paths in Java. (Tom Epperly)
-rw-r--r-- | doc/man/scons.1 | 3 | ||||
-rw-r--r-- | src/CHANGES.txt | 4 | ||||
-rw-r--r-- | src/engine/SCons/Tool/javac.py | 17 | ||||
-rw-r--r-- | test/JAVAC.py | 59 |
4 files changed, 52 insertions, 31 deletions
diff --git a/doc/man/scons.1 b/doc/man/scons.1 index 3f8b282..82878cb 100644 --- a/doc/man/scons.1 +++ b/doc/man/scons.1 @@ -1281,7 +1281,7 @@ env.Jar(target = 'foo.jar', source = 'classes') .IP Java() .IP env.Java() Builds one or more Java class files -from a source tree of .java files. +from one or more source trees of .java files. The class files will be placed underneath the specified target directory. SCons will parse each source .java file @@ -1315,6 +1315,7 @@ Example: .ES env.Java(target = 'classes', source = 'src') +env.Java(target = 'classes', source = ['src1', 'src2']) .EE '\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" diff --git a/src/CHANGES.txt b/src/CHANGES.txt index 16f76ba..b323e08 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -14,6 +14,10 @@ RELEASE 0.96 - XXX - Make the CacheDir() directory if it doesn't already exist. + From Tom Epperly: + + - Allow the Java() Builder to take more than one source directory. + From Bob Halley: - Make the new *FLAGS variable type work with copied Environments. diff --git a/src/engine/SCons/Tool/javac.py b/src/engine/SCons/Tool/javac.py index b56a118..b4a5ce9 100644 --- a/src/engine/SCons/Tool/javac.py +++ b/src/engine/SCons/Tool/javac.py @@ -56,14 +56,15 @@ def emit_java_classes(target, source, env): slist = [] js = _my_normcase(java_suffix) - def visit(arg, dirname, names, js=js, dirnode=source[0].rdir()): - java_files = filter(lambda n, js=js: - _my_normcase(n[-len(js):]) == js, - names) - mydir = dirnode.Dir(dirname) - java_paths = map(lambda f, d=mydir: d.File(f), java_files) - arg.extend(java_paths) - os.path.walk(source[0].rdir().get_abspath(), visit, slist) + for sdir in source: + def visit(arg, dirname, names, js=js, dirnode=sdir.rdir()): + java_files = filter(lambda n, js=js: + _my_normcase(n[-len(js):]) == js, + names) + mydir = dirnode.Dir(dirname) + java_paths = map(lambda f, d=mydir: d.File(f), java_files) + arg.extend(java_paths) + os.path.walk(sdir.rdir().get_abspath(), visit, slist) tlist = [] for file in slist: diff --git a/test/JAVAC.py b/test/JAVAC.py index 13d4670..fafe3a9 100644 --- a/test/JAVAC.py +++ b/test/JAVAC.py @@ -111,14 +111,15 @@ javac = foo.Dictionary('JAVAC') bar = foo.Copy(JAVAC = r'%s wrapper.py ' + javac) foo.Java(target = 'class1', source = 'com/sub/foo') bar.Java(target = 'class2', source = 'com/sub/bar') -foo.Java(target = 'class3', source = 'src') +foo.Java(target = 'class3', source = ['src1', 'src2']) """ % python) test.subdir('com', ['com', 'sub'], ['com', 'sub', 'foo'], ['com', 'sub', 'bar'], - 'src') + 'src1', + 'src2') test.write(['com', 'sub', 'foo', 'Example1.java'], """\ package com.sub.foo; @@ -204,8 +205,20 @@ public class Example6 } """) +test.write(['src1', 'Example7.java'], """\ +public class Example7 +{ + + public static void main(String[] args) + { + + } + +} +""") + # Acid-test file for parsing inner Java classes, courtesy Chad Austin. -test.write(['src', 'Test.java'], """\ +test.write(['src2', 'Test.java'], """\ class Empty { } @@ -265,25 +278,27 @@ class Private { test.run(arguments = '.') -test.fail_test(test.read('wrapper.out') != "wrapper.py /usr/local/j2sdk1.3.1/bin/javac -d class2 -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('class1', 'com', 'sub', 'foo', 'Example1.class'))) -test.fail_test(not os.path.exists(test.workpath('class1', 'com', 'other', 'Example2.class'))) -test.fail_test(not os.path.exists(test.workpath('class1', 'com', 'sub', 'foo', 'Example3.class'))) - -test.fail_test(not os.path.exists(test.workpath('class2', 'com', 'sub', 'bar', 'Example4.class'))) -test.fail_test(not os.path.exists(test.workpath('class2', 'com', 'other', 'Example5.class'))) -test.fail_test(not os.path.exists(test.workpath('class2', 'com', 'sub', 'bar', 'Example6.class'))) - -test.fail_test(not os.path.exists(test.workpath('class3', 'Empty.class'))) -test.fail_test(not os.path.exists(test.workpath('class3', 'Listener.class'))) -test.fail_test(not os.path.exists(test.workpath('class3', 'Private.class'))) -test.fail_test(not os.path.exists(test.workpath('class3', 'Private$1.class'))) -test.fail_test(not os.path.exists(test.workpath('class3', 'Test.class'))) -test.fail_test(not os.path.exists(test.workpath('class3', 'Test$1.class'))) -test.fail_test(not os.path.exists(test.workpath('class3', 'Test$2.class'))) -test.fail_test(not os.path.exists(test.workpath('class3', 'Test$3.class'))) -test.fail_test(not os.path.exists(test.workpath('class3', 'Test$Inner.class'))) +test.must_match('wrapper.out', "wrapper.py /usr/local/j2sdk1.3.1/bin/javac -d class2 -sourcepath com/sub/bar com/sub/bar/Example4.java com/sub/bar/Example5.java com/sub/bar/Example6.java\n") + +test.must_exist(test.workpath('class1', 'com', 'sub', 'foo', 'Example1.class')) +test.must_exist(test.workpath('class1', 'com', 'other', 'Example2.class')) +test.must_exist(test.workpath('class1', 'com', 'sub', 'foo', 'Example3.class')) + +test.must_exist(test.workpath('class2', 'com', 'sub', 'bar', 'Example4.class')) +test.must_exist(test.workpath('class2', 'com', 'other', 'Example5.class')) +test.must_exist(test.workpath('class2', 'com', 'sub', 'bar', 'Example6.class')) + +test.must_exist(test.workpath('class3', 'Example7.class')) + +test.must_exist(test.workpath('class3', 'Empty.class')) +test.must_exist(test.workpath('class3', 'Listener.class')) +test.must_exist(test.workpath('class3', 'Private.class')) +test.must_exist(test.workpath('class3', 'Private$1.class')) +test.must_exist(test.workpath('class3', 'Test.class')) +test.must_exist(test.workpath('class3', 'Test$1.class')) +test.must_exist(test.workpath('class3', 'Test$2.class')) +test.must_exist(test.workpath('class3', 'Test$3.class')) +test.must_exist(test.workpath('class3', 'Test$Inner.class')) test.up_to_date(arguments = '.') |