diff options
author | Steven Knight <knight@baldmt.com> | 2003-09-17 12:01:39 (GMT) |
---|---|---|
committer | Steven Knight <knight@baldmt.com> | 2003-09-17 12:01:39 (GMT) |
commit | aff3d21397df3db4ee99f0d6ef964dde23791b50 (patch) | |
tree | 104507e594a84e99a83abbbffac1b51cd834113c /src/engine/SCons/Tool/jar.py | |
parent | 0b3f13af1549fc4f6b6ed57f151b1d2004e82f2c (diff) | |
download | SCons-aff3d21397df3db4ee99f0d6ef964dde23791b50.zip SCons-aff3d21397df3db4ee99f0d6ef964dde23791b50.tar.gz SCons-aff3d21397df3db4ee99f0d6ef964dde23791b50.tar.bz2 |
Support Jar manifest files and the -C option. Tool/ms*.py fixes for pre-Python 2.2. (Charles Crain)
Diffstat (limited to 'src/engine/SCons/Tool/jar.py')
-rw-r--r-- | src/engine/SCons/Tool/jar.py | 47 |
1 files changed, 46 insertions, 1 deletions
diff --git a/src/engine/SCons/Tool/jar.py b/src/engine/SCons/Tool/jar.py index fa21f3c..5fcb205 100644 --- a/src/engine/SCons/Tool/jar.py +++ b/src/engine/SCons/Tool/jar.py @@ -38,6 +38,47 @@ import os.path import SCons.Builder +def jarSources(target, source, env, for_signature): + """Only include sources that are not a manifest file.""" + ret = [] + for src in source: + contents = src.get_contents() + if contents[:16] != "Manifest-Version": + if env.has_key('JARCHDIR'): + # If we are changing the dir with -C, then sources should + # be relative to that directory. + ret.append(src.get_path(src.fs.Dir(env['JARCHDIR']))) + else: + ret.append(src) + return ret + +def jarManifest(target, source, env, for_signature): + """Look in sources for a manifest file, if any.""" + for src in source: + contents = src.get_contents() + if contents[:16] == "Manifest-Version": + return src + return '' + +def jarFlags(target, source, env, for_signature): + """If we have a manifest, make sure that the 'm' + flag is specified.""" + for src in source: + contents = src.get_contents() + if contents[:16] == "Manifest-Version": + if not 'm' in env['JARFLAGS']: + return env['JARFLAGS'] + 'm' + break + return env['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 '' + JarBuilder = SCons.Builder.Builder(action = '$JARCOM', source_factory = SCons.Node.FS.default_fs.Entry, suffix = '$JARSUFFIX') @@ -51,7 +92,11 @@ def generate(env): env['JAR'] = 'jar' env['JARFLAGS'] = 'cf' - env['JARCOM'] = '$JAR $JARFLAGS $TARGET $SOURCE' + env['_JARFLAGS'] = jarFlags + env['_JARMANIFEST'] = jarManifest + env['_JARSOURCES'] = jarSources + env['_JARCHDIR'] = jarChdir + env['JARCOM'] = '$JAR $_JARFLAGS $TARGET $_JARMANIFEST $_JARCHDIR $_JARSOURCES' env['JARSUFFIX'] = '.jar' def exists(env): |