summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--QMTest/TestSCons.py20
-rw-r--r--doc/man/scons.xml20
-rw-r--r--src/CHANGES.txt8
-rw-r--r--src/engine/SCons/CacheDir.py7
-rw-r--r--src/engine/SCons/Tool/jar.py56
-rw-r--r--src/engine/SCons/Warnings.py6
-rw-r--r--test/Java/JAR.py233
7 files changed, 298 insertions, 52 deletions
diff --git a/QMTest/TestSCons.py b/QMTest/TestSCons.py
index eccad9d..f0d25cb 100644
--- a/QMTest/TestSCons.py
+++ b/QMTest/TestSCons.py
@@ -784,6 +784,16 @@ class TestSCons(TestCommon):
print("Could not determine JAVA_HOME: %s is not a directory" % home)
self.fail_test()
+ def java_mac_check(self, where_java_bin, java_bin_name):
+ # on Mac there is a place holder java installed to start the java install process
+ # so we need to check the output in this case, more info here:
+ # http://anas.pk/2015/09/02/solution-no-java-runtime-present-mac-yosemite/
+ sp = subprocess.Popen([where_java_bin, "-version"], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ stdout, stderr = sp.communicate()
+ sp.wait()
+ if("No Java runtime" in str(stderr)):
+ self.skip_test("Could not find Java " + java_bin_name + ", skipping test(s).\n")
+
def java_where_jar(self, version=None):
ENV = self.java_ENV(version)
if self.detect_tool('jar', ENV=ENV):
@@ -792,6 +802,9 @@ class TestSCons(TestCommon):
where_jar = self.where_is('jar', ENV['PATH'])
if not where_jar:
self.skip_test("Could not find Java jar, skipping test(s).\n")
+ elif sys.platform == "darwin":
+ self.java_mac_check(where_jar, 'jar')
+
return where_jar
def java_where_java(self, version=None):
@@ -800,8 +813,12 @@ class TestSCons(TestCommon):
"""
ENV = self.java_ENV(version)
where_java = self.where_is('java', ENV['PATH'])
+
if not where_java:
self.skip_test("Could not find Java java, skipping test(s).\n")
+ elif sys.platform == "darwin":
+ self.java_mac_check(where_java, 'java')
+
return where_java
def java_where_javac(self, version=None):
@@ -815,6 +832,9 @@ class TestSCons(TestCommon):
where_javac = self.where_is('javac', ENV['PATH'])
if not where_javac:
self.skip_test("Could not find Java javac, skipping test(s).\n")
+ elif sys.platform == "darwin":
+ self.java_mac_check(where_javac, 'javac')
+
self.run(program = where_javac,
arguments = '-version',
stderr=None,
diff --git a/doc/man/scons.xml b/doc/man/scons.xml
index bc3793f..c198957 100644
--- a/doc/man/scons.xml
+++ b/doc/man/scons.xml
@@ -1871,26 +1871,6 @@ These warnings are enabled by default.</para>
</listitem>
</varlistentry>
<varlistentry>
- <term>--warn=no-md5-module, --warn=no-no-md5-module</term>
- <listitem>
-<para>Enables or disables warnings about the version of Python
-not having an MD5 checksum module available.
-These warnings are enabled by default.</para>
-
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>--warn=no-metaclass-support, --warn=no-no-metaclass-support</term>
- <listitem>
-<para>Enables or disables warnings about the version of Python
-not supporting metaclasses when the
-<option>--debug=memoizer</option>
-option is used.
-These warnings are enabled by default.</para>
-
- </listitem>
- </varlistentry>
- <varlistentry>
<term>--warn=no-object-count, --warn=no-no-object-count</term>
<listitem>
<para>Enables or disables warnings about the
diff --git a/src/CHANGES.txt b/src/CHANGES.txt
index da4e6ae..003c2d9 100644
--- a/src/CHANGES.txt
+++ b/src/CHANGES.txt
@@ -8,6 +8,11 @@
RELEASE 3.1.0.alpha.yyyymmdd - NEW DATE WILL BE INSERTED HERE
From Daniel Moody:
+ - Updated Jar builder to handle nodes and directories better
+ - Updated Jar builder to flatten source list which could contain embedded lists
+ - Removed some magic numbers from jar.py on behalf of Mats Wichmann (mats@linux.com)
+
+ From Daniel Moody:
- Jar can take multiple targets, and will make a duplicate jar from the sources for each target
- Added some warnings in case the Jar builder makes an implicit target
- Added Jar method and changed jar build to be more specific. Jar method will take in
@@ -47,6 +52,9 @@ RELEASE 3.1.0.alpha.yyyymmdd - NEW DATE WILL BE INSERTED HERE
From Zachary Tessler:
- Fix incorrect warning for repeated identical builder calls that use overrides
+ From Andrew Featherstone
+ - Removed unused --warn options from the man page and source code.
+
RELEASE 3.0.0 - Mon, 18 Sep 2017 08:32:04 -0700
NOTE: This is a major release. You should expect that some targets may rebuild when upgrading.
diff --git a/src/engine/SCons/CacheDir.py b/src/engine/SCons/CacheDir.py
index 1690674..ac91c85 100644
--- a/src/engine/SCons/CacheDir.py
+++ b/src/engine/SCons/CacheDir.py
@@ -27,6 +27,7 @@ __doc__ = """
CacheDir support
"""
+import hashlib
import json
import os
import stat
@@ -134,12 +135,6 @@ warned = dict()
class CacheDir(object):
def __init__(self, path):
- try:
- import hashlib
- except ImportError:
- msg = "No hashlib or MD5 module available, CacheDir() not supported"
- SCons.Warnings.warn(SCons.Warnings.NoMD5ModuleWarning, msg)
- path = None
self.path = path
self.current_cache_debug = None
self.debugFP = None
diff --git a/src/engine/SCons/Tool/jar.py b/src/engine/SCons/Tool/jar.py
index 49600e0..b31ccb9 100644
--- a/src/engine/SCons/Tool/jar.py
+++ b/src/engine/SCons/Tool/jar.py
@@ -52,7 +52,7 @@ def jarSources(target, source, env, for_signature):
result = []
for src in source:
contents = src.get_text_contents()
- if contents[:16] != "Manifest-Version":
+ if not contents.startswith("Manifest-Version"):
if jarchdir_set:
_chdir = jarchdir
else:
@@ -73,7 +73,7 @@ def jarManifest(target, source, env, for_signature):
"""Look in sources for a manifest file, if any."""
for src in source:
contents = src.get_text_contents()
- if contents[:16] == "Manifest-Version":
+ if contents.startswith("Manifest-Version"):
return src
return ''
@@ -83,7 +83,7 @@ def jarFlags(target, source, env, for_signature):
jarflags = env.subst('$JARFLAGS', target=target, source=source)
for src in source:
contents = src.get_text_contents()
- if contents[:16] == "Manifest-Version":
+ if contents.startswith("Manifest-Version"):
if not 'm' in jarflags:
return jarflags + 'm'
break
@@ -133,7 +133,7 @@ def Jar(env, target = None, source = [], *args, **kw):
# setup for checking through all the sources and handle accordingly
java_class_suffix = env.subst('$JAVACLASSSUFFIX')
java_suffix = env.subst('$JAVASUFFIX')
- target_classes = []
+ target_nodes = []
# function for determining what to do with a file and not a directory
# if its already a class file then it can be used as a
@@ -145,6 +145,24 @@ def Jar(env, target = None, source = [], *args, **kw):
else:
return [env.fs.File(s)]
+ # function for calling the JavaClassDir builder if a directory is
+ # passed as a source to Jar builder. The JavaClassDir builder will
+ # return an empty list if there were not target classes built from
+ # the directory, in this case assume the user wanted the directory
+ # copied into the jar as is (it contains other files such as
+ # resources or class files compiled from proir commands)
+ # TODO: investigate the expexcted behavior for directories that
+ # have mixed content, such as Java files along side other files
+ # files.
+ def dir_to_class(s):
+ dir_targets = env.JavaClassDir(source = s, *args, **kw)
+ if(dir_targets == []):
+ # no classes files could be built from the source dir
+ # so pass the dir as is.
+ return [env.fs.Dir(s)]
+ else:
+ return dir_targets
+
# In the case that we are passed just string to a node which is directory
# but does not exist, we need to check all the current targets to see if
# that directory is going to exist so we can add it as a source to Jar builder
@@ -161,40 +179,40 @@ def Jar(env, target = None, source = [], *args, **kw):
# loop through the sources and handle each accordingly
# the goal here is to get all the source files into a class
# file or a directory that contains class files
- for s in source:
+ for s in SCons.Util.flatten(source):
s = env.subst(s)
if isinstance(s, SCons.Node.FS.Base):
if isinstance(s, SCons.Node.FS.File):
# found a file so make sure its a class file
- target_classes.extend(file_to_class(s))
+ target_nodes.extend(file_to_class(s))
else:
- # found a dir so make sure its a dir of class files
- target_classes.extend(env.JavaClassDir(source = env.fs.Dir(s), *args, **kw))
+ # found a dir so get the class files out of it
+ target_nodes.extend(dir_to_class(s))
else:
if os.path.isfile(s):
# found a file that exists on the FS, make sure its a class file
- target_classes.extend(file_to_class(s))
+ target_nodes.extend(file_to_class(s))
elif os.path.isdir(s):
- # found a dir on the FS, add it as a dir of class files
- target_classes.append(env.fs.Dir(s))
+ # found a dir so get the class files out of it
+ target_nodes.extend(dir_to_class(s))
elif s[-len(java_suffix):] == java_suffix or s[-len(java_class_suffix):] == java_class_suffix:
# found a file that may not exists and is only a string
# so add it after converting it to a class file
- target_classes.extend(file_to_class(s))
+ target_nodes.extend(file_to_class(s))
else:
# found a swig file so add it after converting it to class files
if(os.path.splitext(str(s))[1] == ".i"):
- target_classes.extend(env.JavaClassFile(source = s, *args, **kw))
+ target_nodes.extend(env.JavaClassFile(source = s, *args, **kw))
else:
- # found a directory that does not yet exist, but can exist as a node
- # check the target nodes to make sure it will be built, then add
- # it as a source
+ # The final else case handles anything not caught above and makes
+ # sure other nodes that are sources for this jar get add as
+ # a source to the JarFile builder
for node in get_all_targets(env):
- if(s in str(node) and os.path.splitext(str(node))[1] == ""):
- target_classes.append(node)
+ if(s == str(node)):
+ target_nodes.append(node)
# at this point all our sources have been converted to classes or directories of class
# so pass it to the Jar builder
- return env.JarFile(target = target, source = target_classes, *args, **kw)
+ return env.JarFile(target = target, source = target_nodes, *args, **kw)
def generate(env):
"""Add Builders and construction variables for jar to an Environment."""
diff --git a/src/engine/SCons/Warnings.py b/src/engine/SCons/Warnings.py
index 2495b89..e8158a4 100644
--- a/src/engine/SCons/Warnings.py
+++ b/src/engine/SCons/Warnings.py
@@ -74,12 +74,6 @@ class MisleadingKeywordsWarning(WarningOnByDefault):
class MissingSConscriptWarning(WarningOnByDefault):
pass
-class NoMD5ModuleWarning(WarningOnByDefault):
- pass
-
-class NoMetaclassSupportWarning(WarningOnByDefault):
- pass
-
class NoObjectCountWarning(WarningOnByDefault):
pass
diff --git a/test/Java/JAR.py b/test/Java/JAR.py
index b9a5191..da2e72e 100644
--- a/test/Java/JAR.py
+++ b/test/Java/JAR.py
@@ -134,7 +134,7 @@ bar = foo.Clone(JAR = r'%(_python_)s wrapper_with_args.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')
+bar.Jar(target = 'bar', source = Dir('classes/com/sub/bar'))
""" % locals())
test.subdir('com',
@@ -330,6 +330,237 @@ test.must_exist(['testdir2','bar.jar'])
test.must_exist(['testdir2', 'barTest', 'com', 'javasource', 'JavaFile1.class'])
test.must_exist(['testdir2', 'barTest', 'com', 'javasource', 'JavaFile2.class'])
test.must_exist(['testdir2', 'barTest', 'com', 'javasource', 'JavaFile3.class'])
+
+
+#######
+# test list of lists
+
+# make some directories to test in
+test.subdir('listOfLists',
+ ['listOfLists', 'src'],
+ ['listOfLists', 'src', 'com'],
+ ['listOfLists', 'src', 'com', 'javasource'],
+ ['listOfLists', 'src', 'com', 'resource'])
+
+# test varient dir and lists of lists
+test.write(['listOfLists', 'SConstruct'], """
+foo = Environment()
+foo.VariantDir('build', 'src', duplicate=0)
+sourceFiles = ["src/com/javasource/JavaFile1.java", "src/com/javasource/JavaFile2.java", "src/com/javasource/JavaFile3.java",]
+list_of_class_files = foo.Java('build', source=sourceFiles)
+resources = ['build/com/resource/resource1.txt', 'build/com/resource/resource2.txt']
+for resource in resources:
+ foo.Command(resource, list_of_class_files, Copy(resource, resource.replace('build','src')))
+foo.Command('build/MANIFEST.mf', list_of_class_files, Copy('build/MANIFEST.mf', 'MANIFEST.mf'))
+contents = [list_of_class_files, resources]
+foo.Jar(target = 'lists', source = contents + ['build/MANIFEST.mf'], JARCHDIR='build')
+foo.Command("listsTest", [], Mkdir("listsTest") )
+foo.Command('listsTest/src/com/javasource/JavaFile3.java', 'lists.jar', foo['JAR'] + ' xvf ../lists.jar', chdir='listsTest')
+""")
+
+test.write(['listOfLists', 'src', 'com', 'javasource', 'JavaFile1.java'], """\
+package com.javasource;
+
+public class JavaFile1
+{
+ public static void main(String[] args)
+ {
+
+ }
+}
+""")
+
+test.write(['listOfLists', 'src', 'com', 'javasource', 'JavaFile2.java'], """\
+package com.javasource;
+
+public class JavaFile2
+{
+ public static void main(String[] args)
+ {
+
+ }
+}
+""")
+
+test.write(['listOfLists', 'src', 'com', 'javasource', 'JavaFile3.java'], """\
+package com.javasource;
+
+public class JavaFile3
+{
+ public static void main(String[] args)
+ {
+
+ }
+}
+""")
+
+test.write(['listOfLists', 'MANIFEST.mf'],
+"""Manifest-Version: 1.0
+MyManifestTest: Test
+""")
+
+test.write(['listOfLists', 'src', 'com', 'resource', 'resource1.txt'], """\
+this is a resource file
+""")
+
+test.write(['listOfLists', 'src', 'com', 'resource', 'resource2.txt'], """\
+this is another resource file
+""")
+
+
+test.run(chdir='listOfLists')
+
+#test single target jar
+test.must_exist(['listOfLists','lists.jar'])
+
+# make sure there are class in the jar
+test.must_exist(['listOfLists', 'listsTest', 'com', 'javasource', 'JavaFile1.class'])
+test.must_exist(['listOfLists', 'listsTest', 'com', 'javasource', 'JavaFile2.class'])
+test.must_exist(['listOfLists', 'listsTest', 'com', 'javasource', 'JavaFile3.class'])
+test.must_exist(['listOfLists', 'listsTest', 'com', 'resource', 'resource1.txt'])
+test.must_exist(['listOfLists', 'listsTest', 'com', 'resource', 'resource2.txt'])
+test.must_exist(['listOfLists', 'listsTest', 'META-INF', 'MANIFEST.MF'])
+test.must_contain(['listOfLists', 'listsTest', 'META-INF', 'MANIFEST.MF'], b"MyManifestTest: Test" )
+
+#######
+# test different style of passing in dirs
+
+# make some directories to test in
+test.subdir('testdir3',
+ ['testdir3', 'com'],
+ ['testdir3', 'com', 'sub'],
+ ['testdir3', 'com', 'sub', 'foo'],
+ ['testdir3', 'com', 'sub', 'bar'])
+
+# Create the jars then extract them back to check contents
+test.write(['testdir3', 'SConstruct'], """
+foo = Environment()
+bar = foo.Clone()
+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', JARCHDIR='classes')
+bar.Jar(target = 'bar', source = Dir('classes/com/sub/bar'), JARCHDIR='classes')
+foo.Command("fooTest", 'foo.jar', Mkdir("fooTest") )
+foo.Command('doesnt_exist1', "fooTest", foo['JAR'] + ' xvf ../foo.jar', chdir='fooTest')
+bar.Command("barTest", 'bar.jar', Mkdir("barTest") )
+bar.Command('doesnt_exist2', 'barTest', bar['JAR'] + ' xvf ../bar.jar', chdir='barTest')
+""")
+
+test.write(['testdir3', 'com', 'sub', 'foo', 'Example1.java'], """\
+package com.sub.foo;
+
+public class Example1
+{
+
+ public static void main(String[] args)
+ {
+
+ }
+
+}
+""")
+
+test.write(['testdir3', 'com', 'sub', 'foo', 'Example2.java'], """\
+package com.sub.foo;
+
+public class Example2
+{
+
+ public static void main(String[] args)
+ {
+
+ }
+
+}
+""")
+
+test.write(['testdir3', 'com', 'sub', 'foo', 'Example3.java'], """\
+package com.sub.foo;
+
+public class Example3
+{
+
+ public static void main(String[] args)
+ {
+
+ }
+
+}
+""")
+
+test.write(['testdir3', 'com', 'sub', 'foo', 'NonJava.txt'], """\
+testfile
+""")
+
+test.write(['testdir3', 'com', 'sub', 'bar', 'Example4.java'], """\
+package com.sub.bar;
+
+public class Example4
+{
+
+ public static void main(String[] args)
+ {
+
+ }
+
+}
+""")
+
+test.write(['testdir3', 'com', 'sub', 'bar', 'Example5.java'], """\
+package com.sub.bar;
+
+public class Example5
+{
+
+ public static void main(String[] args)
+ {
+
+ }
+
+}
+""")
+
+test.write(['testdir3', 'com', 'sub', 'bar', 'Example6.java'], """\
+package com.sub.bar;
+
+public class Example6
+{
+
+ public static void main(String[] args)
+ {
+
+ }
+
+}
+""")
+
+test.write(['testdir3', 'com', 'sub', 'bar', 'NonJava.txt'], """\
+testfile
+""")
+
+test.run(chdir='testdir3')
+
+# check the output and make sure the java files got converted to classes
+
+
+# make sure there are class in the jar
+test.must_exist(['testdir3','foo.jar'])
+test.must_exist(['testdir3', 'fooTest', 'com', 'sub', 'foo', 'Example1.class'])
+test.must_exist(['testdir3', 'fooTest', 'com', 'sub', 'foo', 'Example2.class'])
+test.must_exist(['testdir3', 'fooTest', 'com', 'sub', 'foo', 'Example3.class'])
+# TODO: determine expected behavior with resource files, should they be
+# automatically copied in or specified in seperate commands
+#test.must_exist(['testdir3', 'fooTest', 'com', 'sub', 'foo', 'NonJava.txt'])
+
+# make sure both jars got createds
+test.must_exist(['testdir3','bar.jar'])
+test.must_exist(['testdir3', 'barTest', 'com', 'sub', 'bar', 'Example4.class'])
+test.must_exist(['testdir3', 'barTest', 'com', 'sub', 'bar', 'Example5.class'])
+test.must_exist(['testdir3', 'barTest', 'com', 'sub', 'bar', 'Example6.class'])
+# TODO: determine expected behavior with resource files, should they be
+# automatically copied in or specified in seperate commands
+#test.must_exist(['testdir3', 'fooTest', 'com', 'sub', 'bar', 'NonJava.txt'])
+
test.pass_test()