Commits

Anonymous committed 8da15bd

When building a .jar file and $JARCHDIR is set, prefix each .class file with the -C flag. (Kian Win Ong)

Comments (0)

Files changed (4)

 
   - Document the new $FRAMEWORK* variables for Mac OS X.
 
+  From Kian Win Ong:
+
+  - When building a .jar file and there is a $JARCHDIR, put the -C
+    in front of each .class file on the command line.
+
   From Chris Pawling:
 
   - Have the linkloc tool use $MSVS_VERSION to select the Microsoft

src/engine/SCons/Tool/jar.py

                 # If we are changing the dir with -C, then sources should
                 # be relative to that directory.
                 src = src.get_path(src.fs.Dir(jarchdir))
+                result.append('-C')
+                result.append(jarchdir)
             result.append(src)
     return result
 
             break
     return jarflags
 
-def jarChdir(target, source, env, for_signature):
-    """If we have an Environment variable by the name
-    of JARCHDIR, then supply the command line option
-    '-C <dir>' to Jar."""
-    if env.has_key('JARCHDIR'):
-        return [ '-C', '$JARCHDIR' ]
-    return []
-
 JarAction = SCons.Action.Action('$JARCOM', '$JARCOMSTR')
 
 JarBuilder = SCons.Builder.Builder(action = JarAction,
     env['_JARFLAGS']  = jarFlags
     env['_JARMANIFEST'] = jarManifest
     env['_JARSOURCES'] = jarSources
-    env['_JARCHDIR']  = jarChdir
-    env['JARCOM']     = '$JAR $_JARFLAGS $TARGET $_JARMANIFEST $_JARCHDIR $_JARSOURCES'
+    env['JARCOM']     = '$JAR $_JARFLAGS $TARGET $_JARMANIFEST $_JARSOURCES'
     env['JARSUFFIX']  = '.jar'
 
 def exists(env):

test/Java/JARCHDIR.py

+#!/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 when JARCHDIR that our command to create .jar files
+correctly finds all the .class files (by putting -C in front
+of each class file argument).
+"""
+
+import TestSCons
+
+test = TestSCons.TestSCons()
+
+ENV = test.java_ENV()
+
+if test.detect_tool('javac', ENV=ENV):
+    where_javac = test.detect('JAVAC', 'javac', ENV=ENV)
+else:
+    where_javac = test.where_is('javac')
+if not where_javac:
+    test.skip_test("Could not find Java javac, skipping test(s).\n")
+
+test.write('SConstruct', """
+dir = 'dist'
+env = Environment(tools    = ['javac', 'jar'],
+                  JAVAC = '%(where_javac)s',
+                  JARCHDIR = dir)
+bin = env.Java(dir, Dir('./'))
+jar = env.Jar(File('c.jar', dir), bin)
+Default(bin, jar)
+""" % locals())
+
+test.write('a.java', """\
+package foo.bar;
+public class a {}
+""")
+
+test.write('b.java', """\
+package foo.bar;
+public class b {}
+""")
+
+test.run(arguments = '.')
+
+test.pass_test()

test/Java/JAVAH.py

     test.must_match('test2.h', "test2.JAVA\nline 3\n")
 
 
-if test.detect_tool('javac'):
-    where_javac = test.detect('JAVAC', 'javac')
+
+ENV = test.java_ENV()
+
+if test.detect_tool('javac', ENV=ENV):
+    where_javac = test.detect('JAVAC', 'javac', ENV=ENV)
 else:
-    import SCons.Environment
-    env = SCons.Environment.Environment()
-    where_javac = env.WhereIs('javac', os.environ['PATH'])
-    if not where_javac:
-        where_javac = env.WhereIs('javac', '/usr/local/j2sdk1.3.1/bin')
-        if not where_javac:
-            test.skip_test("Could not find Java javac, skipping test(s).\n")
+    where_javac = test.where_is('javac')
+if not where_javac:
+    test.skip_test("Could not find Java javac, skipping test(s).\n")
 
-if test.detect_tool('javah'):
-    where_javah = test.detect('JAVAH', 'javah')
+if test.detect_tool('javah', ENV=ENV):
+    where_javah = test.detect('JAVAH', 'javah', ENV=ENV)
 else:
-    import SCons.Environment
-    env = SCons.Environment.Environment()
-    where_javah = env.WhereIs('javah', os.environ['PATH'])
-    if not where_javah:
-        where_javah = env.WhereIs('javah', '/usr/local/j2sdk1.3.1/bin')
-        if not where_javah:
-            test.skip_test("Could not find Java javah, skipping test(s).\n")
+    where_javah = test.where_is('javah')
+if not where_javah:
+    test.skip_test("Could not find Java javah, skipping test(s).\n")
 
 
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.