diff options
author | Daniel Moody <dmoody256@gmail.com> | 2017-12-03 21:15:41 (GMT) |
---|---|---|
committer | Daniel Moody <dmoody256@gmail.com> | 2017-12-03 21:19:53 (GMT) |
commit | 121174d379aad244254a1efc03d5adbb6bc41058 (patch) | |
tree | 26c4256120880c8a45aa462ad8d3d386412fbab4 | |
parent | e08b2caf67a8ea982eb287914ecd28461f51ddb3 (diff) | |
download | SCons-121174d379aad244254a1efc03d5adbb6bc41058.zip SCons-121174d379aad244254a1efc03d5adbb6bc41058.tar.gz SCons-121174d379aad244254a1efc03d5adbb6bc41058.tar.bz2 |
Updated some comments and refactored a variable name. No functional changes.
-rw-r--r-- | src/engine/SCons/Tool/jar.py | 38 |
1 files changed, 25 insertions, 13 deletions
diff --git a/src/engine/SCons/Tool/jar.py b/src/engine/SCons/Tool/jar.py index c7ca4d4..3be3aee 100644 --- a/src/engine/SCons/Tool/jar.py +++ b/src/engine/SCons/Tool/jar.py @@ -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,9 +145,20 @@ 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 @@ -173,34 +184,35 @@ def Jar(env, target = None, source = [], *args, **kw): 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(dir_to_class(s)) + # 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): - target_classes.extend(dir_to_class(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 == str(node)): - target_classes.append(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.""" |