summaryrefslogtreecommitdiffstats
path: root/src/engine/SCons/Tool
diff options
context:
space:
mode:
authorSteven Knight <knight@baldmt.com>2007-08-17 03:17:04 (GMT)
committerSteven Knight <knight@baldmt.com>2007-08-17 03:17:04 (GMT)
commit8cb34cccc26935bce5d07ed3f51cc29fbbd1ab03 (patch)
tree7bc281e44fe45cae35656e0e457fef8f308fbb7b /src/engine/SCons/Tool
parent5b4b4c6e5384712ab1835bdcf8beea09611b6e62 (diff)
downloadSCons-8cb34cccc26935bce5d07ed3f51cc29fbbd1ab03.zip
SCons-8cb34cccc26935bce5d07ed3f51cc29fbbd1ab03.tar.gz
SCons-8cb34cccc26935bce5d07ed3f51cc29fbbd1ab03.tar.bz2
Merged revisions 2136-2200,2202-2290,2292-2301 via svnmerge from
http://scons.tigris.org/svn/scons/branches/core ........ r2145 | stevenknight | 2007-07-17 09:15:12 -0500 (Tue, 17 Jul 2007) | 3 lines Don't put null strings (from variable expansion) in a path list. (They get turned into the current directory on later expansion.) ........ r2146 | stevenknight | 2007-07-17 10:47:39 -0500 (Tue, 17 Jul 2007) | 3 lines Add support for optional arguments on command-line long options by specifying nargs='?'. ........ r2149 | stevenknight | 2007-07-17 15:22:24 -0500 (Tue, 17 Jul 2007) | 2 lines Remove left-over Optik mentions. ........ r2150 | stevenknight | 2007-07-17 15:39:34 -0500 (Tue, 17 Jul 2007) | 4 lines Add a $SWIGPATH variable for finding SWIG dependencies, with $SWIGINC{PREFIX,SUFFIX} for adding them to the command line. ........ r2154 | stevenknight | 2007-07-18 20:05:31 -0500 (Wed, 18 Jul 2007) | 2 lines Fix variable misspellings in the doc added for $SWIGOUTPUT. ........ r2155 | stevenknight | 2007-07-18 20:07:28 -0500 (Wed, 18 Jul 2007) | 2 lines Add the Python eggs info file to the RPM packaging build. ........ r2156 | stevenknight | 2007-07-18 20:15:08 -0500 (Wed, 18 Jul 2007) | 2 lines Convert documentation from DocBook SGML to XML. ........ r2158 | stevenknight | 2007-07-19 17:16:19 -0500 (Thu, 19 Jul 2007) | 3 lines Conditionally add the .egg-info the RPM file list only if the distutils in the version of Python that rpmbuild will execute knows about them. ........ r2161 | stevenknight | 2007-07-19 19:12:29 -0500 (Thu, 19 Jul 2007) | 5 lines Capture a test case (contributed by Tilo Prutz) where instantiation of a private class causes javac to generate an additional anonymous inner class file. (No solution yet, but there's no sense throwing away the preparatory work.) ........ r2162 | stevenknight | 2007-07-20 11:29:56 -0500 (Fri, 20 Jul 2007) | 3 lines Support passing a list of .java files as source to the Java() builder. (Leanid Nazdrynau) ........ r2163 | garyo | 2007-07-20 12:00:35 -0500 (Fri, 20 Jul 2007) | 1 line Fixed cut-n-paste error in Touch factory method doc in users guide. ........ r2167 | stevenknight | 2007-07-21 22:59:40 -0500 (Sat, 21 Jul 2007) | 2 lines Don't execute the SWIGOUTDIR test if swig isn't installed. ........ r2168 | stevenknight | 2007-07-21 23:14:17 -0500 (Sat, 21 Jul 2007) | 2 lines Fix the test's ability to run under a path name containing spaces. ........ r2171 | stevenknight | 2007-07-24 15:54:41 -0500 (Tue, 24 Jul 2007) | 2 lines Handle white space in key file names in the packaging build. ........ r2172 | stevenknight | 2007-07-24 21:41:15 -0500 (Tue, 24 Jul 2007) | 2 lines More efficient copying of construction environments. ........ r2173 | stevenknight | 2007-07-25 10:56:02 -0500 (Wed, 25 Jul 2007) | 2 lines Update the SCons build for Subversion and general clean-up. ........ r2174 | stevenknight | 2007-07-25 11:35:16 -0500 (Wed, 25 Jul 2007) | 3 lines Suppress the [brackets] around a node in the --tree=prune output if the node is a source. ........ r2175 | stevenknight | 2007-07-25 12:52:18 -0500 (Wed, 25 Jul 2007) | 3 lines Commonize the skip_test() method and make its behavior configurable via a TESTCOMMON_PASS_SKIPS environment variable. ........ r2178 | stevenknight | 2007-07-25 21:43:47 -0500 (Wed, 25 Jul 2007) | 3 lines Add $JAVACLASSPATH and $JAVASOURCEPATH construction variables. (Leanid Nazdrynau) ........ r2182 | stevenknight | 2007-07-30 12:10:20 -0500 (Mon, 30 Jul 2007) | 3 lines Refactor Builder suffix-adjusting into its own method, so we can (potentially) re-use it for Builders with attached source Builders. ........ r2183 | stevenknight | 2007-07-30 14:51:53 -0500 (Mon, 30 Jul 2007) | 2 lines More efficient source-builder suffix matching. ........ r2184 | stevenknight | 2007-07-30 16:01:42 -0500 (Mon, 30 Jul 2007) | 4 lines Encapsulate initialization of the default FS object by an accessor function in SCons.Node.FS. (This also gets rid of an unnecessary reference to SCons.Node.FS.default_fs in the LaTeX scanner.) ........ r2193 | stevenknight | 2007-07-30 18:24:07 -0500 (Mon, 30 Jul 2007) | 3 lines Fix interpretation of source arguments that have no suffix when the called Builder has both a src_suffix and a src_builder. ........ r2194 | stevenknight | 2007-07-31 10:25:31 -0500 (Tue, 31 Jul 2007) | 2 lines Increase the number of tries for random output from three to ten. ........ r2195 | stevenknight | 2007-07-31 10:52:28 -0500 (Tue, 31 Jul 2007) | 3 lines Skip the test gracefully if the zipfile module can't read the file it just wrote (which is the case for Python 2.1 on 64-bit systems). ........ r2196 | stevenknight | 2007-07-31 13:06:21 -0500 (Tue, 31 Jul 2007) | 2 lines Move the "import zipfile" so it doesn't fail on Python <= 2.0. ........ r2197 | stevenknight | 2007-07-31 14:51:50 -0500 (Tue, 31 Jul 2007) | 3 lines Commonize initialization of the various Java builders so they can be hooked up into a multi-stage Builder chain. (Leanid Nazdrynau) ........ r2198 | stevenknight | 2007-07-31 16:15:18 -0500 (Tue, 31 Jul 2007) | 3 lines Fix use of ${TARGET.dir} and ${SOURCE.dir} expansions in $FORTRANMODDIR $JARCHDIR, $JARFLAGS, $LEXFLAGS, $SWIGFLAGS, $SWIGOUTDIR and $YACCFLAGS. ........ r2199 | stevenknight | 2007-07-31 16:25:48 -0500 (Tue, 31 Jul 2007) | 2 lines Remove left-over Trace() call. ........ r2202 | stevenknight | 2007-08-01 12:31:48 -0500 (Wed, 01 Aug 2007) | 3 lines Bail out via test.skip_test() if wix ("candle") isn't found. Put the main body of code flush left instead of under an if: block. ........ r2203 | stevenknight | 2007-08-01 15:35:55 -0500 (Wed, 01 Aug 2007) | 5 lines Fix Tool.packaging.rpm.package() so it doesn't always overwrite $RPMFLAGS with -ta. Set --buildroot in RPM packaging tests so they don't overwrite each other when run simultaneously. ........ r2204 | stevenknight | 2007-08-01 15:37:36 -0500 (Wed, 01 Aug 2007) | 2 lines Fix a nested scope issue with the internal build_sources() function. ........ r2205 | stevenknight | 2007-08-01 15:46:08 -0500 (Wed, 01 Aug 2007) | 5 lines Normalize (X out) the CreationDate field inside embedded, compressed PostScript streams within the generated PDF files. Also normalize preceding Length field, since compression length is affected by different patterns of input, including the variable CreationDate value. ........ r2211 | stevenknight | 2007-08-02 08:52:06 -0500 (Thu, 02 Aug 2007) | 2 lines Add the new modules from branches/packaging to the SCons packaging build. ........ r2212 | stevenknight | 2007-08-02 19:59:01 -0500 (Thu, 02 Aug 2007) | 2 lines Fix the JAVACLASSPATH test when javah isn't on the default $PATH. ........ r2214 | stevenknight | 2007-08-03 15:05:21 -0500 (Fri, 03 Aug 2007) | 4 lines Hook up the Java builders into a multi-step chain underneath a Java() pseudo-builder (wrapper) that examines its arguments and calls the appropriate underlying file-or-dir builder. ........ r2215 | stevenknight | 2007-08-03 15:49:58 -0500 (Fri, 03 Aug 2007) | 2 lines Fix for old Python versions: use apply() instead of *args, **kw. ........ r2216 | stevenknight | 2007-08-03 16:49:31 -0500 (Fri, 03 Aug 2007) | 2 lines Hook up the SWIG builder as a source builder for .java files. ........ r2217 | stevenknight | 2007-08-03 17:28:19 -0500 (Fri, 03 Aug 2007) | 2 lines Don't use .endswith(), which didn't appear until later Python versions. ........ r2218 | stevenknight | 2007-08-03 17:29:38 -0500 (Fri, 03 Aug 2007) | 2 lines Replace tabs with spaces. ........ r2219 | stevenknight | 2007-08-04 08:06:23 -0500 (Sat, 04 Aug 2007) | 3 lines Initialize a loop-invariant lambda for matching .java suffixes outside the loop. ........ r2220 | stevenknight | 2007-08-07 15:06:13 -0500 (Tue, 07 Aug 2007) | 2 lines Refactor parallel class-generation loops into one. ........ r2221 | stevenknight | 2007-08-07 16:04:06 -0500 (Tue, 07 Aug 2007) | 5 lines Have the Java multi-step builder test actually check for generated files, and fix the generation of .java and .class file names, and interaction with the SWIG builder, so that the files are generated in the correct place. ........ r2222 | stevenknight | 2007-08-07 16:45:05 -0500 (Tue, 07 Aug 2007) | 3 lines Fix dependencies on SWIG-generated .java files so they don't have to be built in multiple passes. ........ r2226 | stevenknight | 2007-08-07 18:00:22 -0500 (Tue, 07 Aug 2007) | 2 lines Fix SWIG when used with BuildDir(). ........ r2227 | stevenknight | 2007-08-07 22:15:55 -0500 (Tue, 07 Aug 2007) | 5 lines User's guide updates: - Make the multiple files example match its text. - Expand a truncated sentence about being able to use Python function actions in the Command() Builder. ........ r2228 | stevenknight | 2007-08-07 23:25:18 -0500 (Tue, 07 Aug 2007) | 3 lines Don't generate an error if a #include file matches a same-named directory in $CPPPATH (or $FORTRANPATH, etc.). ........ r2229 | stevenknight | 2007-08-07 23:40:00 -0500 (Tue, 07 Aug 2007) | 2 lines Fix a code example. (Gary Oberbrunner) ........ r2230 | stevenknight | 2007-08-08 00:05:43 -0500 (Wed, 08 Aug 2007) | 3 lines Capture a test case to make sure AddPostAction() doesn't interfere with normal linking. (Matt Doar, Gary Oberbrunner) ........ r2233 | stevenknight | 2007-08-08 14:15:44 -0500 (Wed, 08 Aug 2007) | 2 lines Fix documentation typo in a construction variable cross-reference. ........ r2234 | stevenknight | 2007-08-08 17:03:25 -0500 (Wed, 08 Aug 2007) | 2 lines Changes to SCons packaging to support checkpoint releases. ........ r2235 | stevenknight | 2007-08-09 10:10:01 -0500 (Thu, 09 Aug 2007) | 2 lines Sidestep false negatives on heavily loaded systems. ........ r2236 | garyo | 2007-08-09 11:16:26 -0500 (Thu, 09 Aug 2007) | 1 line Allow unpackaged files (e.g. *.pyo) to exist in the build dir without being packaged in the RPM. Without this, on some systems the rpmbuild may error out. ........ r2237 | stevenknight | 2007-08-09 11:27:56 -0500 (Thu, 09 Aug 2007) | 5 lines Fix test/SWIG/build-dir.py so it works on old Python versions without distutils.sysconfig. Instead of just cutting-and-pasting initialization code from other SWIG tests, centralize it in some new TestSCons methods. ........ r2238 | garyo | 2007-08-09 11:30:58 -0500 (Thu, 09 Aug 2007) | 1 line Use docbook 4.3 instead of 4.4 for the XML doctype since some older(?) jade parsers can't handle new 4-byte Unicode chars in the 4.4 version of isogrk4.ent. ........ r2240 | stevenknight | 2007-08-09 16:35:06 -0500 (Thu, 09 Aug 2007) | 2 lines User's Guide updates (post packaging changes). ........ r2243 | stevenknight | 2007-08-10 10:31:51 -0500 (Fri, 10 Aug 2007) | 3 lines Fix the User's Guide build to use openjade, and to accomodate a change in the name of the main generated file (book1.html => index.html). ........ r2245 | stevenknight | 2007-08-10 11:09:16 -0500 (Fri, 10 Aug 2007) | 2 lines Update the {CHANGES,RELEASE}.txt datestamp lines. ........ r2253 | stevenknight | 2007-08-10 16:21:54 -0500 (Fri, 10 Aug 2007) | 2 lines Fix the wix Tool module's ability to handle null entries in $PATH. ........ r2261 | stevenknight | 2007-08-11 23:08:12 -0500 (Sat, 11 Aug 2007) | 3 lines Remove unnecessary files (.svnt/*, .{ae,cvs}ignore, www/*) from the scons-src packages. ........ r2262 | stevenknight | 2007-08-11 23:24:49 -0500 (Sat, 11 Aug 2007) | 2 lines Add missing __revision__ lines. ........ r2263 | stevenknight | 2007-08-11 23:33:42 -0500 (Sat, 11 Aug 2007) | 2 lines Skip the test if the MANIFEST file hasn't been built. ........ r2264 | stevenknight | 2007-08-11 23:36:30 -0500 (Sat, 11 Aug 2007) | 2 lines Add recent compatibility modules to the relevant exceptions lists. ........ r2265 | stevenknight | 2007-08-11 23:39:00 -0500 (Sat, 11 Aug 2007) | 3 lines Update __VERSION__ strings in the QMTest/*.py modules, so that packaging tests (src/test_*.py) will pass after builds of checkpoint releases. ........ r2266 | stevenknight | 2007-08-12 07:36:19 -0500 (Sun, 12 Aug 2007) | 2 lines Add a comment about why we construct the __VERSION__ string at run time. ........ r2267 | stevenknight | 2007-08-12 07:42:30 -0500 (Sun, 12 Aug 2007) | 2 lines Avoid reading the MANIFEST file twice. (Courtesy review by Greg Noel.) ........ r2268 | stevenknight | 2007-08-12 08:14:53 -0500 (Sun, 12 Aug 2007) | 3 lines Shift Install() and InstallAs() from being documented as functions to being documented as Builders. ........ r2269 | garyo | 2007-08-13 08:49:52 -0500 (Mon, 13 Aug 2007) | 1 line Tests: Skip some more Java tests if javac is not installed on the test machine so they don't get marked as failing. ........ r2270 | garyo | 2007-08-13 11:09:39 -0500 (Mon, 13 Aug 2007) | 1 line Fixed typo in test (shows up on non-Linux platforms). ........ r2271 | garyo | 2007-08-13 14:09:05 -0500 (Mon, 13 Aug 2007) | 4 lines Test portability fixes for Darwin/OSX and IRIX. This does not make all the tests pass on those OSes, but it takes care of some of the more obvious errors that I have time for right now. More to come. ........ r2272 | stevenknight | 2007-08-13 15:33:29 -0500 (Mon, 13 Aug 2007) | 2 lines Tab => space fix. ........ r2273 | stevenknight | 2007-08-13 15:33:52 -0500 (Mon, 13 Aug 2007) | 2 lines Test for swig, too, which is used to build from the .i file. ........ r2277 | garyo | 2007-08-14 10:40:00 -0500 (Tue, 14 Aug 2007) | 8 lines Test portability on IRIX: test/Actions/pre-post creates target file before building target, then IRIX CC does not chmod +x afterwards. I think this change is safe on all OSes. test/AS/ml.py: I think this is only supposed to be run on win32 (not skipped only on win32); the sense of the skip test was backwards. ........ r2278 | stevenknight | 2007-08-14 11:04:40 -0500 (Tue, 14 Aug 2007) | 2 lines Add -tt when running tests, to catch inconsistent tab usage. ........ r2279 | stevenknight | 2007-08-14 14:00:43 -0500 (Tue, 14 Aug 2007) | 2 lines Minor refactor of logic in File.retrieve_from_cache(). ........ r2280 | stevenknight | 2007-08-15 01:11:40 -0500 (Wed, 15 Aug 2007) | 2 lines Refactor CacheDir support into its own module. ........ r2281 | stevenknight | 2007-08-15 07:24:51 -0500 (Wed, 15 Aug 2007) | 2 lines Move the cachepath() method from FS.File to the CacheDir class. ........ r2282 | stevenknight | 2007-08-15 08:31:34 -0500 (Wed, 15 Aug 2007) | 2 lines Python 1.5.2 fix in the new Null class. ........ r2283 | stevenknight | 2007-08-15 10:45:53 -0500 (Wed, 15 Aug 2007) | 5 lines Refactor CacheDir unit tests to: - restore functionality that was dropped in the transition; - commonize creation of test Nodes and other (mock) objects - separate CacheDir tests from tests of CacheDir through Node.FS.File. ........ r2284 | stevenknight | 2007-08-15 11:46:38 -0500 (Wed, 15 Aug 2007) | 3 lines Replace the Executor.Null.NullEnvironment object with a real Null object, so it will absorb the CacheDir method calls as well. ........ r2285 | stevenknight | 2007-08-15 11:52:57 -0500 (Wed, 15 Aug 2007) | 5 lines Add a get_CacheDir() method to a construction environment, which will be used to fetch per-environment CacheDir specifications. (Right now all calls to it still just return the one attached to underlying default FS object.) ........ r2286 | stevenknight | 2007-08-15 15:15:46 -0500 (Wed, 15 Aug 2007) | 2 lines Support per-construction-environment configuration of CacheDir(). ........ r2287 | stevenknight | 2007-08-15 15:33:04 -0500 (Wed, 15 Aug 2007) | 2 lines Move the tests of CacheDir()-related command-line options into test/CacheDir. ........ r2293 | stevenknight | 2007-08-16 11:14:49 -0500 (Thu, 16 Aug 2007) | 3 lines Add the Package() builder description to the documentation build, fixing the XML so that it will build. ........ r2294 | stevenknight | 2007-08-16 12:51:19 -0500 (Thu, 16 Aug 2007) | 3 lines Reorganize packaging documentation: alphabetize the variable definitions (and function names), document Tag() as a function, not a builder. ........ r2296 | stevenknight | 2007-08-16 12:55:01 -0500 (Thu, 16 Aug 2007) | 2 lines Add a build command. ........ r2300 | stevenknight | 2007-08-16 16:49:13 -0500 (Thu, 16 Aug 2007) | 2 lines First cut at documenting packaging variables. ........ r2301 | stevenknight | 2007-08-16 16:51:21 -0500 (Thu, 16 Aug 2007) | 3 lines Construct the .src.rpm and .arch.rpm file names independnetly, not by trying to massage one into the other. ........
Diffstat (limited to 'src/engine/SCons/Tool')
-rw-r--r--src/engine/SCons/Tool/JavaCommonTests.py33
-rw-r--r--src/engine/SCons/Tool/__init__.py77
-rw-r--r--src/engine/SCons/Tool/aixlink.py2
-rw-r--r--src/engine/SCons/Tool/filesystem.py3
-rw-r--r--src/engine/SCons/Tool/fortran.py4
-rw-r--r--src/engine/SCons/Tool/install.py8
-rw-r--r--src/engine/SCons/Tool/install.xml52
-rw-r--r--src/engine/SCons/Tool/jar.py20
-rw-r--r--src/engine/SCons/Tool/jar.xml11
-rw-r--r--src/engine/SCons/Tool/javac.py167
-rw-r--r--src/engine/SCons/Tool/javac.xml58
-rw-r--r--src/engine/SCons/Tool/javah.py24
-rw-r--r--src/engine/SCons/Tool/javah.xml6
-rw-r--r--src/engine/SCons/Tool/lex.py3
-rw-r--r--src/engine/SCons/Tool/packaging/__init__.py20
-rw-r--r--src/engine/SCons/Tool/packaging/__init__.xml490
-rw-r--r--src/engine/SCons/Tool/packaging/rpm.py7
-rw-r--r--src/engine/SCons/Tool/swig.py70
-rw-r--r--src/engine/SCons/Tool/swig.xml86
-rw-r--r--src/engine/SCons/Tool/wix.py3
-rw-r--r--src/engine/SCons/Tool/yacc.py3
21 files changed, 843 insertions, 304 deletions
diff --git a/src/engine/SCons/Tool/JavaCommonTests.py b/src/engine/SCons/Tool/JavaCommonTests.py
index 40f0a47..358f675 100644
--- a/src/engine/SCons/Tool/JavaCommonTests.py
+++ b/src/engine/SCons/Tool/JavaCommonTests.py
@@ -418,6 +418,39 @@ public class NestedExample
expect = [ 'NestedExample$1', 'NestedExample$1$1', 'NestedExample' ]
assert expect == classes, (expect, classes)
+ def test_private_inner_class_instantiation(self):
+ """Test anonymous inner class generated by private instantiation"""
+
+ input = """\
+class test
+{
+ test()
+ {
+ super();
+ new inner();
+ }
+
+ static class inner
+ {
+ private inner() {}
+ }
+}
+"""
+
+ # This is what we *should* generate, apparently due to the
+ # private instantiation of the inner class, but don't today.
+ #expect = [ 'test$1', 'test$inner', 'test' ]
+
+ # What our parser currently generates, which doesn't match
+ # what the Java compiler actually generates.
+ expect = [ 'test$inner', 'test' ]
+
+ pkg_dir, classes = SCons.Tool.JavaCommon.parse_java(input, '1.4')
+ assert expect == classes, (expect, classes)
+
+ pkg_dir, classes = SCons.Tool.JavaCommon.parse_java(input, '1.5')
+ assert expect == classes, (expect, classes)
+
if __name__ == "__main__":
diff --git a/src/engine/SCons/Tool/__init__.py b/src/engine/SCons/Tool/__init__.py
index bf3df56..97a4e70 100644
--- a/src/engine/SCons/Tool/__init__.py
+++ b/src/engine/SCons/Tool/__init__.py
@@ -43,6 +43,7 @@ import sys
import SCons.Builder
import SCons.Errors
+import SCons.Node.FS
import SCons.Scanner
import SCons.Scanner.C
import SCons.Scanner.D
@@ -176,6 +177,9 @@ class Tool:
def __str__(self):
return self.name
+##########################################################################
+# Create common executable program / library / object builders
+
def createProgBuilder(env):
"""This is a utility function that creates the Program
Builder in an Environment if it is not there already.
@@ -347,6 +351,79 @@ def createCFileBuilders(env):
return (c_file, cxx_file)
+##########################################################################
+# Create common Java builders
+
+def CreateJarBuilder(env):
+ try:
+ java_jar = env['BUILDERS']['Jar']
+ except KeyError:
+ fs = SCons.Node.FS.get_default_fs()
+ jar_com = SCons.Action.Action('$JARCOM', '$JARCOMSTR')
+ java_jar = SCons.Builder.Builder(action = jar_com,
+ suffix = '$JARSUFFIX',
+ src_suffix = '$JAVACLASSSUFIX',
+ src_builder = 'JavaClassFile',
+ source_factory = fs.Entry)
+ env['BUILDERS']['Jar'] = java_jar
+ return java_jar
+
+def CreateJavaHBuilder(env):
+ try:
+ java_javah = env['BUILDERS']['JavaH']
+ except KeyError:
+ fs = SCons.Node.FS.get_default_fs()
+ java_javah_com = SCons.Action.Action('$JAVAHCOM', '$JAVAHCOMSTR')
+ java_javah = SCons.Builder.Builder(action = java_javah_com,
+ src_suffix = '$JAVACLASSSUFFIX',
+ target_factory = fs.Entry,
+ source_factory = fs.File,
+ src_builder = 'JavaClassFile')
+ env['BUILDERS']['JavaH'] = java_javah
+ return java_javah
+
+def CreateJavaClassFileBuilder(env):
+ try:
+ java_class_file = env['BUILDERS']['JavaClassFile']
+ except KeyError:
+ fs = SCons.Node.FS.get_default_fs()
+ javac_com = SCons.Action.Action('$JAVACCOM', '$JAVACCOMSTR')
+ java_class_file = SCons.Builder.Builder(action = javac_com,
+ emitter = {},
+ #suffix = '$JAVACLASSSUFFIX',
+ src_suffix = '$JAVASUFFIX',
+ src_builder = ['JavaFile'],
+ target_factory = fs.Entry,
+ source_factory = fs.File)
+ env['BUILDERS']['JavaClassFile'] = java_class_file
+ return java_class_file
+
+def CreateJavaClassDirBuilder(env):
+ try:
+ java_class_dir = env['BUILDERS']['JavaClassDir']
+ except KeyError:
+ fs = SCons.Node.FS.get_default_fs()
+ javac_com = SCons.Action.Action('$JAVACCOM', '$JAVACCOMSTR')
+ java_class_dir = SCons.Builder.Builder(action = javac_com,
+ emitter = {},
+ target_factory = fs.Dir,
+ source_factory = fs.Dir)
+ env['BUILDERS']['JavaClassDir'] = java_class_dir
+ return java_class_dir
+
+def CreateJavaFileBuilder(env):
+ try:
+ java_file = env['BUILDERS']['JavaFile']
+ except KeyError:
+ java_file = SCons.Builder.Builder(action = {},
+ emitter = {},
+ suffix = {None:'$JAVASUFFIX'})
+ env['BUILDERS']['JavaFile'] = java_file
+ env['JAVASUFFIX'] = '.java'
+ return java_file
+
+
+
def FindTool(tools, env):
for tool in tools:
t = Tool(tool)
diff --git a/src/engine/SCons/Tool/aixlink.py b/src/engine/SCons/Tool/aixlink.py
index 2deb1f1..5c3b383 100644
--- a/src/engine/SCons/Tool/aixlink.py
+++ b/src/engine/SCons/Tool/aixlink.py
@@ -44,7 +44,7 @@ cplusplus = __import__('c++', globals(), locals(), [])
def smart_linkflags(source, target, env, for_signature):
if cplusplus.iscplusplus(source):
- build_dir = env.subst('$BUILDDIR')
+ build_dir = env.subst('$BUILDDIR', target=target, source=source)
if build_dir:
return '-qtempinc=' + os.path.join(build_dir, 'tempinc')
return ''
diff --git a/src/engine/SCons/Tool/filesystem.py b/src/engine/SCons/Tool/filesystem.py
index 5e631fd..46aefbb 100644
--- a/src/engine/SCons/Tool/filesystem.py
+++ b/src/engine/SCons/Tool/filesystem.py
@@ -29,6 +29,9 @@ selection method.
# 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__"
+
import SCons
from SCons.Tool.install import copyFunc
diff --git a/src/engine/SCons/Tool/fortran.py b/src/engine/SCons/Tool/fortran.py
index 8494fd6..b748303 100644
--- a/src/engine/SCons/Tool/fortran.py
+++ b/src/engine/SCons/Tool/fortran.py
@@ -78,8 +78,8 @@ def _fortranEmitter(target, source, env):
# Remove unique items from the list
modules = SCons.Util.unique(modules)
# Convert module name to a .mod filename
- suffix = env.subst('$FORTRANMODSUFFIX')
- moddir = env.subst('$FORTRANMODDIR')
+ suffix = env.subst('$FORTRANMODSUFFIX', target=target, source=source)
+ moddir = env.subst('$FORTRANMODDIR', target=target, source=source)
modules = map(lambda x, s=suffix: string.lower(x) + s, modules)
for m in modules:
target.append(env.fs.File(m, moddir))
diff --git a/src/engine/SCons/Tool/install.py b/src/engine/SCons/Tool/install.py
index 5083c9f..828bb9e 100644
--- a/src/engine/SCons/Tool/install.py
+++ b/src/engine/SCons/Tool/install.py
@@ -29,8 +29,14 @@ selection method.
# 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__"
+
+import os
+import shutil
+import stat
+
import SCons.Action
-import shutil, os, stat
from SCons.Util import make_path_relative
#
diff --git a/src/engine/SCons/Tool/install.xml b/src/engine/SCons/Tool/install.xml
new file mode 100644
index 0000000..4b57a68
--- /dev/null
+++ b/src/engine/SCons/Tool/install.xml
@@ -0,0 +1,52 @@
+<!--
+__COPYRIGHT__
+
+This file is processed by the bin/SConsDoc.py module.
+See its __doc__ string for a discussion of the format.
+-->
+
+<tool name="install">
+<summary>
+Sets construction variables for file
+and directory installation.
+</summary>
+<sets>
+INSTALL
+INSTALLSTR
+</sets>
+</tool>
+
+<builder name="Install">
+<summary>
+Installs one or more source files or directories
+in the specified target,
+which must be a directory.
+The names of the specified source files or directories
+remain the same within the destination directory.
+
+<example>
+env.Install('/usr/local/bin', source = ['foo', 'bar'])
+</example>
+</summary>
+</builder>
+
+<builder name="InstallAs">
+<summary>
+Installs one or more source files or directories
+to specific names,
+allowing changing a file or directory name
+as part of the installation.
+It is an error if the
+target
+and
+source
+arguments list different numbers of files or directories.
+
+<example>
+env.InstallAs(target = '/usr/local/bin/foo',
+ source = 'foo_debug')
+env.InstallAs(target = ['../lib/libfoo.a', '../lib/libbar.a'],
+ source = ['libFOO.a', 'libBAR.a'])
+</example>
+</summary>
+</builder>
diff --git a/src/engine/SCons/Tool/jar.py b/src/engine/SCons/Tool/jar.py
index cb0a8eb..4f221c0 100644
--- a/src/engine/SCons/Tool/jar.py
+++ b/src/engine/SCons/Tool/jar.py
@@ -33,14 +33,12 @@ selection method.
__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
-import SCons.Action
-import SCons.Builder
import SCons.Subst
import SCons.Util
def jarSources(target, source, env, for_signature):
"""Only include sources that are not a manifest file."""
- jarchdir = env.subst('$JARCHDIR')
+ jarchdir = env.subst('$JARCHDIR', target=target, source=source)
if jarchdir:
jarchdir = env.fs.Dir(jarchdir)
result = []
@@ -67,7 +65,7 @@ def jarManifest(target, source, env, for_signature):
def jarFlags(target, source, env, for_signature):
"""If we have a manifest, make sure that the 'm'
flag is specified."""
- jarflags = env.subst('$JARFLAGS')
+ jarflags = env.subst('$JARFLAGS', target=target, source=source)
for src in source:
contents = src.get_contents()
if contents[:16] == "Manifest-Version":
@@ -76,25 +74,17 @@ def jarFlags(target, source, env, for_signature):
break
return jarflags
-JarAction = SCons.Action.Action('$JARCOM', '$JARCOMSTR')
-
-JarBuilder = SCons.Builder.Builder(action = JarAction,
- source_factory = SCons.Node.FS.Entry,
- suffix = '$JARSUFFIX')
-
def generate(env):
"""Add Builders and construction variables for jar to an Environment."""
- try:
- env['BUILDERS']['Jar']
- except KeyError:
- env['BUILDERS']['Jar'] = JarBuilder
+ SCons.Tool.CreateJarBuilder(env)
env['JAR'] = 'jar'
env['JARFLAGS'] = SCons.Util.CLVar('cf')
env['_JARFLAGS'] = jarFlags
env['_JARMANIFEST'] = jarManifest
env['_JARSOURCES'] = jarSources
- env['JARCOM'] = '$JAR $_JARFLAGS $TARGET $_JARMANIFEST $_JARSOURCES'
+ env['_JARCOM'] = '$JAR $_JARFLAGS $TARGET $_JARMANIFEST $_JARSOURCES'
+ env['JARCOM'] = "${TEMPFILE('$_JARCOM')}"
env['JARSUFFIX'] = '.jar'
def exists(env):
diff --git a/src/engine/SCons/Tool/jar.xml b/src/engine/SCons/Tool/jar.xml
index 0deaaae..a0d730e 100644
--- a/src/engine/SCons/Tool/jar.xml
+++ b/src/engine/SCons/Tool/jar.xml
@@ -22,7 +22,13 @@ JARCOMSTR
<builder name="Jar">
<summary>
Builds a Java archive (<filename>.jar</filename>) file
-from a source tree of <filename>.class</filename> files.
+from the specified list of sources.
+Any directories in the source list
+will be searched for <filename>.class</filename> files).
+Any <filename>.java</filename> files in the source list
+will be compiled to <filename>.class</filename> files
+by calling the &b-link-Java; Builder.
+
If the &cv-link-JARCHDIR; value is set, the
&jar;
command will change to the specified directory using the
@@ -39,6 +45,9 @@ option set.
<example>
env.Jar(target = 'foo.jar', source = 'classes')
+
+env.Jar(target = 'bar.jar',
+ source = ['bar1.java', 'bar2.java'])
</example>
</summary>
</builder>
diff --git a/src/engine/SCons/Tool/javac.py b/src/engine/SCons/Tool/javac.py
index 85dfc3f..5703b2d 100644
--- a/src/engine/SCons/Tool/javac.py
+++ b/src/engine/SCons/Tool/javac.py
@@ -54,43 +54,73 @@ def emit_java_classes(target, source, env):
java_suffix = env.get('JAVASUFFIX', '.java')
class_suffix = env.get('JAVACLASSSUFFIX', '.class')
+ target[0].must_be_same(SCons.Node.FS.Dir)
+ classdir = target[0]
+
+ s = source[0].rentry().disambiguate()
+ if isinstance(s, SCons.Node.FS.File):
+ sourcedir = s.dir.rdir()
+ elif isinstance(s, SCons.Node.FS.Dir):
+ sourcedir = s.rdir()
+ else:
+ raise SCons.Errors.UserError("Java source must be File or Dir, not '%s'" % s.__class__)
+
slist = []
js = _my_normcase(java_suffix)
- 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)
- # The on-disk entries come back in arbitrary order. Sort them
- # so our target and source lists are determinate.
- java_files.sort()
- 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)
+ find_java = lambda n, js=js, ljs=len(js): _my_normcase(n[-ljs:]) == js
+ for entry in source:
+ entry = entry.rentry().disambiguate()
+ if isinstance(entry, SCons.Node.FS.File):
+ slist.append(entry)
+ elif isinstance(entry, SCons.Node.FS.Dir):
+ result = SCons.Util.OrderedDict()
+ def visit(arg, dirname, names, fj=find_java, dirnode=entry.rdir()):
+ java_files = filter(fj, names)
+ # The on-disk entries come back in arbitrary order. Sort
+ # them so our target and source lists are determinate.
+ java_files.sort()
+ mydir = dirnode.Dir(dirname)
+ java_paths = map(lambda f, d=mydir: d.File(f), java_files)
+ for jp in java_paths:
+ arg[jp] = True
+
+ os.path.walk(entry.rdir().get_abspath(), visit, result)
+ entry.walk(visit, result)
+
+ slist.extend(result.keys())
+ else:
+ raise SCons.Errors.UserError("Java source must be File or Dir, not '%s'" % entry.__class__)
+ version = env.get('JAVAVERSION', '1.4')
tlist = []
for f in slist:
- version = env.get('JAVAVERSION', '1.4')
- pkg_dir, classes = parse_java_file(f.get_abspath(), version)
- if pkg_dir:
- for c in classes:
- t = target[0].Dir(pkg_dir).File(c+class_suffix)
- t.attributes.java_classdir = target[0]
- t.attributes.java_classname = classname(pkg_dir + os.sep + c)
- tlist.append(t)
- elif classes:
- for c in classes:
- t = target[0].File(c+class_suffix)
- t.attributes.java_classdir = target[0]
- t.attributes.java_classname = classname(c)
- tlist.append(t)
- else:
- # This is an odd end case: no package and no classes.
- # Just do our best based on the source file name.
- base = str(f)[:-len(java_suffix)]
- t = target[0].File(base + class_suffix)
- t.attributes.java_classdir = target[0]
+ source_file_based = True
+ pkg_dir = None
+ if not f.is_derived():
+ pkg_dir, classes = parse_java_file(f.rfile().get_abspath(), version)
+ if classes:
+ source_file_based = False
+ if pkg_dir:
+ d = target[0].Dir(pkg_dir)
+ p = pkg_dir + os.sep
+ else:
+ d = target[0]
+ p = ''
+ for c in classes:
+ t = d.File(c + class_suffix)
+ t.attributes.java_classdir = classdir
+ t.attributes.java_sourcedir = sourcedir
+ t.attributes.java_classname = classname(p + c)
+ tlist.append(t)
+
+ if source_file_based:
+ base = f.name[:-len(java_suffix)]
+ if pkg_dir:
+ t = target[0].Dir(pkg_dir).File(base + class_suffix)
+ else:
+ t = target[0].File(base + class_suffix)
+ t.attributes.java_classdir = classdir
+ t.attributes.java_sourcedir = f.dir
t.attributes.java_classname = classname(base)
tlist.append(t)
@@ -100,18 +130,81 @@ JavaAction = SCons.Action.Action('$JAVACCOM', '$JAVACCOMSTR')
JavaBuilder = SCons.Builder.Builder(action = JavaAction,
emitter = emit_java_classes,
- target_factory = SCons.Node.FS.Dir,
- source_factory = SCons.Node.FS.Dir)
+ target_factory = SCons.Node.FS.Entry,
+ source_factory = SCons.Node.FS.Entry)
+
+def getClassPath(env,target, source, for_signature):
+ path = ""
+ if env.has_key('JAVACLASSPATH') and env['JAVACLASSPATH']:
+ path = SCons.Util.AppendPath(path, env['JAVACLASSPATH'])
+ return "-classpath %s" % (path)
+ else:
+ return ""
+
+def getSourcePath(env,target, source, for_signature):
+ path = ""
+ if env.has_key('JAVASOURCEPATH') and env['JAVASOURCEPATH']:
+ path = SCons.Util.AppendPath(path, env['JAVASOURCEPATH'])
+ path = SCons.Util.AppendPath(path,['${TARGET.attributes.java_sourcedir}'])
+ return "-sourcepath %s" % (path)
+
+def Java(env, target, source, *args, **kw):
+ """
+ A pseudo-Builder wrapper around the separate JavaClass{File,Dir}
+ Builders.
+ """
+ if not SCons.Util.is_List(target):
+ target = [target]
+ if not SCons.Util.is_List(source):
+ source = [source]
+
+ # Pad the target list with repetitions of the last element in the
+ # list so we have a target for every source element.
+ target = target + ([target[-1]] * (len(source) - len(target)))
+
+ java_suffix = env.subst('$JAVASUFFIX')
+ result = []
+
+ for t, s in zip(target, source):
+ if isinstance(s, SCons.Node.FS.Base):
+ if isinstance(s, SCons.Node.FS.File):
+ b = env.JavaClassFile
+ else:
+ b = env.JavaClassDir
+ else:
+ if os.path.isfile(s):
+ b = env.JavaClassFile
+ elif os.path.isdir(s):
+ b = env.JavaClassDir
+ elif s[-len(java_suffix):] == java_suffix:
+ b = env.JavaClassFile
+ else:
+ b = env.JavaClassDir
+ result.extend(apply(b, (t, s) + args, kw))
+
+ return result
def generate(env):
"""Add Builders and construction variables for javac to an Environment."""
- env['BUILDERS']['Java'] = JavaBuilder
+ java_file = SCons.Tool.CreateJavaFileBuilder(env)
+ java_class = SCons.Tool.CreateJavaClassFileBuilder(env)
+ java_class_dir = SCons.Tool.CreateJavaClassDirBuilder(env)
+ java_class.add_emitter(None, emit_java_classes)
+ java_class.add_emitter(env.subst('$JAVASUFFIX'), emit_java_classes)
+ java_class_dir.emitter = emit_java_classes
+
+ env.AddMethod(Java)
env['JAVAC'] = 'javac'
env['JAVACFLAGS'] = SCons.Util.CLVar('')
- env['JAVACCOM'] = '$JAVAC $JAVACFLAGS -d ${TARGET.attributes.java_classdir} -sourcepath ${SOURCE.dir.rdir()} $SOURCES'
+ env['JAVACLASSPATH'] = []
+ env['JAVASOURCEPATH'] = []
+ env['_JAVACLASSPATH'] = getClassPath
+ env['_JAVASOURCEPATH'] = getSourcePath
+ env['_JAVACCOM'] = '$JAVAC $JAVACFLAGS $_JAVACLASSPATH -d ${TARGET.attributes.java_classdir} $_JAVASOURCEPATH $SOURCES'
+ env['JAVACCOM'] = "${TEMPFILE('$_JAVACCOM')}"
env['JAVACLASSSUFFIX'] = '.class'
env['JAVASUFFIX'] = '.java'
def exists(env):
- return env.Detect('javac')
+ return 1
diff --git a/src/engine/SCons/Tool/javac.xml b/src/engine/SCons/Tool/javac.xml
index 248eda2..f5af975 100644
--- a/src/engine/SCons/Tool/javac.xml
+++ b/src/engine/SCons/Tool/javac.xml
@@ -14,6 +14,8 @@ JAVACFLAGS
JAVACCOM
JAVACLASSSUFFIX
JAVASUFFIX
+JAVACLASSPATH
+JAVASOURCEPATH
</sets>
<uses>
JAVACCOMSTR
@@ -22,16 +24,21 @@ JAVACCOMSTR
<builder name="Java">
<summary>
-Builds one or more Java class files
-from one or more source trees of <filename>.java</filename> files.
-The class files will be placed underneath
-the specified target directory.
+Builds one or more Java class files.
+The sources may be any combination of explicit
+<filename>.java</filename> files,
+or directory trees which will be scanned
+for <filename>.java</filename> files.
+
SCons will parse each source <filename>.java</filename> file
to find the classes
(including inner classes)
defined within that file,
and from that figure out the
target <filename>.class</filename> files that will be created.
+The class files will be placed underneath
+the specified target directory.
+
SCons will also search each Java file
for the Java package name,
which it assumes can be found on a line
@@ -58,6 +65,7 @@ Example:
<example>
env.Java(target = 'classes', source = 'src')
env.Java(target = 'classes', source = ['src1', 'src2'])
+env.Java(target = 'classes', source = ['File1.java', 'File2.java'])
</example>
</summary>
</builder>
@@ -107,6 +115,27 @@ builder.
</summary>
</cvar>
+<cvar name="JAVACLASSPATH">
+<summary>
+Specifies the list of directories that
+will be searched for Java
+<filename>.class</filename> file.
+The directories in this list will be added to the
+&javac; and &javah; command lines
+via the <option>-classpath</option> option.
+The individual directory names will be
+separated by the operating system's path separate character
+(<filename>:</filename> on UNIX/Linux/POSIX,
+<filename>;</filename> on Windows).
+
+Note that this currently just adds the specified
+directory via the <option>-classpath</option> option.
+&SCons; does not currently search the
+&cv-JAVACLASSPATH; directories for dependency
+<filename>.class</filename> files.
+</summary>
+</cvar>
+
<cvar name="JAVACLASSSUFFIX">
<summary>
The suffix for Java class files;
@@ -115,6 +144,27 @@ by default.
</summary>
</cvar>
+<cvar name="JAVASOURCEPATH">
+<summary>
+Specifies the list of directories that
+will be searched for input
+<filename>.java</filename> file.
+The directories in this list will be added to the
+&javac; command line
+via the <option>-sourcepath</option> option.
+The individual directory names will be
+separated by the operating system's path separate character
+(<filename>:</filename> on UNIX/Linux/POSIX,
+<filename>;</filename> on Windows).
+
+Note that this currently just adds the specified
+directory via the <option>-sourcepath</option> option.
+&SCons; does not currently search the
+&cv-JAVASOURCEPATH; directories for dependency
+<filename>.java</filename> files.
+</summary>
+</cvar>
+
<cvar name="JAVASUFFIX">
<summary>
The suffix for Java files;
diff --git a/src/engine/SCons/Tool/javah.py b/src/engine/SCons/Tool/javah.py
index 26fcc53..7eb4969 100644
--- a/src/engine/SCons/Tool/javah.py
+++ b/src/engine/SCons/Tool/javah.py
@@ -60,6 +60,7 @@ def emit_java_headers(target, source, env):
except AttributeError:
classdir = '.'
classdir = env.Dir(classdir).rdir()
+
if str(classdir) == '.':
c_ = None
else:
@@ -77,10 +78,13 @@ def emit_java_headers(target, source, env):
classname = classname[:-len(class_suffix)]
classname = SCons.Tool.javac.classname(classname)
s = src.rfile()
- s.attributes.java_classdir = classdir
s.attributes.java_classname = classname
slist.append(s)
+ s = source[0].rfile()
+ if not hasattr(s.attributes, 'java_classdir'):
+ s.attributes.java_classdir = classdir
+
if target[0].__class__ is SCons.Node.FS.File:
tlist = target
else:
@@ -106,22 +110,22 @@ def JavaHOutFlagGenerator(target, source, env, for_signature):
except AttributeError:
return '-o ' + str(t)
-JavaHAction = SCons.Action.Action('$JAVAHCOM', '$JAVAHCOMSTR')
-
-JavaHBuilder = SCons.Builder.Builder(action = JavaHAction,
- emitter = emit_java_headers,
- src_suffix = '$JAVACLASSSUFFIX',
- target_factory = SCons.Node.FS.Entry,
- source_factory = SCons.Node.FS.File)
+def getJavaHClassPath(env,target, source, for_signature):
+ path = "${SOURCE.attributes.java_classdir}"
+ if env.has_key('JAVACLASSPATH') and env['JAVACLASSPATH']:
+ path = SCons.Util.AppendPath(path, env['JAVACLASSPATH'])
+ return "-classpath %s" % (path)
def generate(env):
"""Add Builders and construction variables for javah to an Environment."""
- env['BUILDERS']['JavaH'] = JavaHBuilder
+ java_javah = SCons.Tool.CreateJavaHBuilder(env)
+ java_javah.emitter = emit_java_headers
env['_JAVAHOUTFLAG'] = JavaHOutFlagGenerator
env['JAVAH'] = 'javah'
env['JAVAHFLAGS'] = SCons.Util.CLVar('')
- env['JAVAHCOM'] = '$JAVAH $JAVAHFLAGS $_JAVAHOUTFLAG -classpath ${SOURCE.attributes.java_classdir} ${SOURCES.attributes.java_classname}'
+ env['_JAVAHCLASSPATH'] = getJavaHClassPath
+ env['JAVAHCOM'] = '$JAVAH $JAVAHFLAGS $_JAVAHOUTFLAG $_JAVAHCLASSPATH ${SOURCES.attributes.java_classname}'
env['JAVACLASSSUFFIX'] = '.class'
def exists(env):
diff --git a/src/engine/SCons/Tool/javah.xml b/src/engine/SCons/Tool/javah.xml
index c6487e7..20fe3ee 100644
--- a/src/engine/SCons/Tool/javah.xml
+++ b/src/engine/SCons/Tool/javah.xml
@@ -16,6 +16,7 @@ JAVACLASSSUFFIX
</sets>
<uses>
JAVAHCOMSTR
+JAVACLASSPATH
</uses>
</tool>
@@ -27,7 +28,10 @@ The target can be either a directory
in which the header files will be written,
or a header file name which
will contain all of the definitions.
-The source can be either the names of <filename>.class</filename> files,
+The source can be the names of <filename>.class</filename> files,
+the names of <filename>.java</filename> files
+to be compiled into <filename>.class</filename> files
+by calling the &b-link-Java; builder method,
or the objects returned from the
&b-Java;
builder method.
diff --git a/src/engine/SCons/Tool/lex.py b/src/engine/SCons/Tool/lex.py
index 31f21a9..e599f8a 100644
--- a/src/engine/SCons/Tool/lex.py
+++ b/src/engine/SCons/Tool/lex.py
@@ -55,7 +55,8 @@ def lexEmitter(target, source, env):
# Different options that are used to trigger the creation of extra files.
fileGenOptions = ["--header-file=", "--tables-file="]
- for option in SCons.Util.CLVar(env.subst("$LEXFLAGS")):
+ lexflags = env.subst("$LEXFLAGS", target=target, source=source)
+ for option in SCons.Util.CLVar(lexflags):
for fileGenOption in fileGenOptions:
l = len(fileGenOption)
if option[:l] == fileGenOption:
diff --git a/src/engine/SCons/Tool/packaging/__init__.py b/src/engine/SCons/Tool/packaging/__init__.py
index c5f40b7..e8f6a09 100644
--- a/src/engine/SCons/Tool/packaging/__init__.py
+++ b/src/engine/SCons/Tool/packaging/__init__.py
@@ -175,6 +175,15 @@ def Package(env, target=None, source=None, **kw):
targets.extend(env.Alias( 'package', targets ))
return targets
+def build_source(ss, sources):
+ for s in ss:
+ if s.__class__==SCons.Node.FS.Dir:
+ build_source(s.all_children())
+ elif not s.has_builder() and s.__class__==SCons.Node.FS.File:
+ sources.append(s)
+ else:
+ build_source(s.sources)
+
def FindSourceFiles(env, target=None, source=None ):
""" returns a list of all children of the target nodes, which have no
children. This selects all leaves of the DAG that gets build by SCons for
@@ -185,17 +194,8 @@ def FindSourceFiles(env, target=None, source=None ):
nodes = env.arg2nodes(target, env.fs.Entry)
sources = []
- def build_source(ss):
- for s in ss:
- if s.__class__==SCons.Node.FS.Dir:
- build_source(s.all_children())
- elif not s.has_builder() and s.__class__==SCons.Node.FS.File:
- sources.append(s)
- else:
- build_source(s.sources)
-
for node in nodes:
- build_source(node.all_children())
+ build_source(node.all_children(), sources)
# now strip the build_node from the sources by calling the srcnode
# function
diff --git a/src/engine/SCons/Tool/packaging/__init__.xml b/src/engine/SCons/Tool/packaging/__init__.xml
index 8e7f652..bf4e96e 100644
--- a/src/engine/SCons/Tool/packaging/__init__.xml
+++ b/src/engine/SCons/Tool/packaging/__init__.xml
@@ -6,36 +6,46 @@ See its __doc__ string for a discussion of the format.
-->
<tool name="Packaging">
<summary>
-TODO
+Sets construction variables for the &b-Package; Builder.
</summary>
+<sets>
+</sets>
+<uses>
+</uses>
</tool>
<builder name="Package">
-Builds software distribution packages. Packages consist of files to install
-and packaging information. The former may be specified with the source
-parameter and may be left out, in which case the &-bFindInstalledFiles;
-function will collect all files that have an &-bInstall; or
-&-bInstallAs; Builder attached. The target, if not specified will be deduced
-from additional information given to this Builder.
-
-The packaging information is specified with the help of construction Variables
-documented below. This information is called a tag to stress that some of them
-can also be attached to files with the &-bTag; Builder.The mandatory ones will
-complain if they were not specified. They vary depending on chosen target
-packager.
-
-The target packager may be selected with the "PACKAGETYPE" command line option
-or with the &-tPACKAGETYPE; construction variable. Currently there are six
-packagers available:
+<summary>
+Builds software distribution packages. Packages consist of files
+to install and packaging information. The former may be specified
+with the &source; parameter and may be left out, in which case the
+&FindInstalledFiles; function will collect all files that have an
+&b-Install; or &b-InstallAs; Builder attached. If the &target;, is
+not specified it will be deduced from additional information given to
+this Builder.
+
+The packaging information is specified with the help of construction
+variables documented below. This information is called a tag to stress
+that some of them can also be attached to files with the &Tag; function.
+The mandatory ones will complain if they were not specified. They vary
+depending on chosen target packager.
+
+The target packager may be selected with the "PACKAGETYPE" command line
+option or with the &cv-PACKAGETYPE; construction variable. Currently
+the following packagers available:
* msi - Microsoft Installer
* rpm - Redhat Package Manger
* ipkg - Itsy Package Management System
- * tarbz, tarbz and zip
+ * tarbz2 - compressed tar
+ * targz - compressed tar
+ * zip - zip file
+ * src_tarbz2 - compressed tar source
+ * src_targz - compressed tar source
+ * src_zip - zip file source
An updated list is always available under the "package_type" option when
running "scons --help" on a project that has packaging activated.
-
<example>
env = Environment(tools=['default', 'packaging'])
env.Install('/bin/', 'my_program')
@@ -50,148 +60,229 @@ env.Package( NAME = 'foo',
SOURCE_URL = 'http://foo.org/foo-1.2.3.tar.gz'
)
</example>
+</summary>
+</builder>
-<cvar name="DESCRIPTION">
+<cvar name="ARCHITECTURE">
<summary>
-A long description of what the project is about.
+Specifies the system architecture for which
+the package is being built.
+The default is the system architecture
+of the machine on which SCons is running.
+This is used to fill in the
+<literal>Architecture:</literal>
+field in an Ipkg
+<filename>control</filename> file,
+and as part of the name of a generated RPM file.
</summary>
</cvar>
-<cvar name="DESCRIPTION_<lang>">
+<cvar name="CHANGE_SPECFILE">
<summary>
-TODO
+A hook for modifying the file that controls the packaging build
+(the <filename>.spec</filename> for RPM,
+the <filename>control</filename> for Ipkg,
+the <filename>.wxs</filename> for MSI).
+If set, the function will be called
+after the SCons template for the file has been written.
+XXX
</summary>
</cvar>
+<cvar name="CHANGELOG">
+<summary>
+The name of a file containing the change log text
+to be included in the package.
+This is included as the
+<literal>%changelog</literal>
+section of the RPM
+<filename>.spec</filename> file.
+</summary>
+</cvar>
-<cvar name="SUMMARY">
+<cvar name="DESCRIPTION">
<summary>
-A short summary of what the project is about.
+A long description of the project being packaged.
+This is included in the relevant section
+of the file that controls the packaging build.
</summary>
</cvar>
-<cvar name="LICENSE">
+<cvar name="DESCRIPTION_lang">
<summary>
-The shorthand of the license this project is under (gpl, lpgl, bsd etc.).
+A language-specific long description for
+the specified <varname>lang</varname>.
+This is used to populate a
+<literal>%description -l</literal>
+section of an RPM
+<filename>.spec</filename> file.
</summary>
</cvar>
-<cvar name="NAME">
+<cvar name="LICENSE">
<summary>
-Specfies the name of the project to package.
+The abbreviated name of the license under which
+this project is released (gpl, lpgl, bsd etc.).
+See http://www.opensource.org/licenses/alphabetical
+for a list of license names.
</summary>
</cvar>
-<cvar name="VERSION">
+<cvar name="NAME">
<summary>
-The version of the project, given as a string.
+Specfies the name of the project to package.
</summary>
</cvar>
-<cvar name="PACKAGEVERSION">
+<cvar name="PACKAGEROOT">
<summary>
-The version of the package, if only changes in the package were done. Currently
-only used by the rpm packager.
+Specifies the directory where all files in resulting archive will be
+placed if applicable. The default value is "$NAME-$VERSION".
</summary>
</cvar>
<cvar name="PACKAGETYPE">
<summary>
-Selects the package type to build. Currently those are available:
+Selects the package type to build. Currently these are available:
* msi - Microsoft Installer
* rpm - Redhat Package Manger
* ipkg - Itsy Package Management System
- * tarbz2, targz and zip - tarball and zip packager
- * src_tarbz2, src_targz and src_zip - source tarbarll and zip packager
+ * tarbz2 - compressed tar
+ * targz - compressed tar
+ * zip - zip file
+ * src_tarbz2 - compressed tar source
+ * src_targz - compressed tar source
+ * src_zip - zip file source
This may be overridden with the "package_type" command line option.
</summary>
</cvar>
-<cvar name="VENDOR">
+<cvar name="PACKAGEVERSION">
<summary>
-TODO
+The version of the package (not the underlying project).
+This is currently only used by the rpm packager
+and should reflect changes in the packaging,
+not the underlying project code itself.
</summary>
</cvar>
<cvar name="SOURCE_URL">
<summary>
-TODO
+The URL
+(web address)
+of the location from which the project was retrieved.
+This is used to fill in the
+<literal>Source:</literal>
+field in the controlling information for Ipkg and RPM packages.
</summary>
</cvar>
-<cvar name="ARCHITECURE">
+<cvar name="SUMMARY">
<summary>
-TODO
+A short summary of what the project is about.
+This is used to fill in the
+<literal>Summary:</literal>
+field in the controlling information for Ipkg and RPM packages,
+and as the
+<literal>Description:</literal>
+field in MSI packages.
</summary>
</cvar>
-<cvar name="PACKAGEROOT">
+<cvar name="VENDOR">
<summary>
-defines the directory where all files in resulting archive will be placed if
-applicable. The default value is "$NAME-$VERSION".
+The person or organization who supply the packaged software.
+This is used to fill in the
+<literal>Vendor:</literal>
+field in the controlling information for RPM packages,
+and the
+<literal>Manufacturer:</literal>
+field in the controlling information for MSI packages.
</summary>
</cvar>
-<cvar name="LICENSE">
+<cvar name="VERSION">
<summary>
-Short name of the license your package is under. Example: gpl, lgpl, bsd ...
-See http://www.opensource.org/licenses/alphabetical
+The version of the project, specified as a string.
</summary>
</cvar>
-<cvar name="CHANGE_SPECFILE">
+
+<cvar name="X_IPK_DEPENDS">
<summary>
-TODO
+This is used to fill in the
+<literal>Depends:</literal>
+field in the controlling information for Ipkg packages.
</summary>
</cvar>
-<cvar name="CHANGELOG">
+<cvar name="X_IPK_DESCRIPTION">
<summary>
-TODO
+This is used to fill in the
+<literal>Description:</literal>
+field in the controlling information for Ipkg packages.
+The default value is
+<literal>$SUMMARY\n$DESCRIPTION</literal>
</summary>
</cvar>
-<cvar name="X_RPM_PREINSTALL">
+<cvar name="X_IPK_MAINTAINER">
<summary>
-TODO
+This is used to fill in the
+<literal>Maintainer:</literal>
+field in the controlling information for Ipkg packages.
</summary>
</cvar>
-<cvar name="X_RPM_DEFATTR">
+<cvar name="X_IPK_PRIORITY">
<summary>
-TODO
+This is used to fill in the
+<literal>Priority:</literal>
+field in the controlling information for Ipkg packages.
</summary>
</cvar>
-<cvar name="X_RPM_POSTINSTALL">
+<cvar name="X_IPK_SECTION">
<summary>
-TODO
+This is used to fill in the
+<literal>Section:</literal>
+field in the controlling information for Ipkg packages.
</summary>
</cvar>
-<cvar name="X_RPM_PREUNINSTALL">
+
+
+<cvar name="X_MSI_LANGUAGE">
<summary>
-TODO
+This is used to fill in the
+<literal>Language:</literal>
+attribute in the controlling information for MSI packages.
</summary>
</cvar>
-<cvar name="X_RPM_POSTUNINSTALL">
+<cvar name="X_MSI_LICENSE_TEXT">
<summary>
-TODO
+The text of the software license in RTF format.
+Carriage return characters will be
+replaced with the RTF equivalent \\par.
</summary>
</cvar>
-<cvar name="X_RPM_VERIFY">
+<cvar name="X_MSI_UPGRADE_CODE">
<summary>
TODO
</summary>
</cvar>
-<cvar name="X_RPM_PREP">
+
+<cvar name="X_RPM_AUTOREQPROV">
<summary>
-internal, but overridable
+This is used to fill in the
+<literal>AutoReqProv:</literal>
+field in the RPM
+<filename>.spec</filename> file.
</summary>
</cvar>
@@ -201,188 +292,254 @@ internal, but overridable
</summary>
</cvar>
-<cvar name="X_RPM_INSTALL">
+<cvar name="X_RPM_BUILDREQUIRES">
<summary>
-internal, but overridable
+This is used to fill in the
+<literal>BuildRequires:</literal>
+field in the RPM
+<filename>.spec</filename> file.
</summary>
</cvar>
-<cvar name="X_RPM_CLEAN">
+<cvar name="X_RPM_BUILDROOT">
<summary>
internal, but overridable
</summary>
</cvar>
-<cvar name="X_RPM_URL">
+<cvar name="X_RPM_CLEAN">
<summary>
-TODO
+internal, but overridable
</summary>
</cvar>
-<cvar name="X_RPM_GROUP">
+<cvar name="X_RPM_CONFLICTS">
<summary>
-TODO
+This is used to fill in the
+<literal>Conflicts:</literal>
+field in the RPM
+<filename>.spec</filename> file.
</summary>
</cvar>
-<cvar name="X_RPM_GROUP_<lang>">
+<cvar name="X_RPM_DEFATTR">
<summary>
-TODO
+This value is used as the default attributes
+for the files in the RPM package.
+The default value is
+<literal>(-,root,root)</literal>.
</summary>
</cvar>
<cvar name="X_RPM_DISTRIBUTION">
<summary>
-TODO
+This is used to fill in the
+<literal>Distribution:</literal>
+field in the RPM
+<filename>.spec</filename> file.
</summary>
</cvar>
-<cvar name="X_RPM_ICON">
+<cvar name="X_RPM_EPOCH">
<summary>
-TODO
+This is used to fill in the
+<literal>Epoch:</literal>
+field in the controlling information for RPM packages.
</summary>
</cvar>
-<cvar name="X_RPM_PACKAGER">
+<cvar name="X_RPM_EXCLUDEARCH">
<summary>
-TODO
+This is used to fill in the
+<literal>ExcludeArch:</literal>
+field in the RPM
+<filename>.spec</filename> file.
</summary>
</cvar>
-<cvar name="X_RPM_REQUIRES">
+<cvar name="X_RPM_EXLUSIVEARCH">
<summary>
-TODO
+This is used to fill in the
+<literal>ExclusiveArch:</literal>
+field in the RPM
+<filename>.spec</filename> file.
</summary>
</cvar>
-<cvar name="X_RPM_PROVIDES">
+<cvar name="X_RPM_GROUP">
<summary>
-TODO
+This is used to fill in the
+<literal>Group:</literal>
+field in the RPM
+<filename>.spec</filename> file.
</summary>
</cvar>
-<cvar name="X_RPM_CONFLICTS">
+<cvar name="X_RPM_GROUP_lang">
<summary>
-TODO
+This is used to fill in the
+<literal>Group(lang):</literal>
+field in the RPM
+<filename>.spec</filename> file.
+Note that
+<varname>lang</varname>
+is not literal
+and should be replaced by
+the appropriate language code.
</summary>
</cvar>
-<cvar name="X_RPM_BUILDREQUIRES">
+<cvar name="X_RPM_ICON">
<summary>
-TODO
+This is used to fill in the
+<literal>Icon:</literal>
+field in the RPM
+<filename>.spec</filename> file.
</summary>
</cvar>
-<cvar name="X_RPM_SERIAL">
+<cvar name="X_RPM_INSTALL">
<summary>
-TODO
+internal, but overridable
</summary>
</cvar>
-<cvar name="X_RPM_EPOCH">
+<cvar name="X_RPM_PACKAGER">
<summary>
-TODO
+This is used to fill in the
+<literal>Packager:</literal>
+field in the RPM
+<filename>.spec</filename> file.
</summary>
</cvar>
-<cvar name="X_RPM_AUTOREQPROV">
+<cvar name="X_RPM_PROVIDES">
<summary>
-TODO
+This is used to fill in the
+<literal>Provides:</literal>
+field in the RPM
+<filename>.spec</filename> file.
</summary>
</cvar>
-<cvar name="X_RPM_EXCLUDEARCH">
+<cvar name="X_RPM_POSTINSTALL">
<summary>
-TODO
+This is used to fill in the
+<literal>%post:</literal>
+section in the RPM
+<filename>.spec</filename> file.
</summary>
</cvar>
-<cvar name="X_RPM_EXLUSIVEARCH">
+<cvar name="X_RPM_PREINSTALL">
<summary>
-TODO
+This is used to fill in the
+<literal>%pre:</literal>
+section in the RPM
+<filename>.spec</filename> file.
</summary>
</cvar>
<cvar name="X_RPM_PREFIX">
<summary>
-TODO
+This is used to fill in the
+<literal>Prefix:</literal>
+field in the RPM
+<filename>.spec</filename> file.
</summary>
</cvar>
-<cvar name="X_RPM_CONFLICTS">
-<summary>
-TODO
-</summary>
-</cvar>
-
-<cvar name="X_RPM_BUILDROOT">
+<cvar name="X_RPM_PREP">
<summary>
internal, but overridable
</summary>
</cvar>
-<cvar name="X_RPM_GROUP_<lang>">
+<cvar name="X_RPM_POSTUNINSTALL">
<summary>
-TODO
+This is used to fill in the
+<literal>%postun:</literal>
+section in the RPM
+<filename>.spec</filename> file.
</summary>
</cvar>
-<cvar name="X_MSI_LICENSE_TEXT">
+<cvar name="X_RPM_PREUNINSTALL">
<summary>
-The text of the software license in rtf format. Carriage return chars will be
-replaced with the rtf equivalent \\par.
+This is used to fill in the
+<literal>%preun:</literal>
+section in the RPM
+<filename>.spec</filename> file.
</summary>
</cvar>
-<cvar name="X_MSI_LANGUAGE">
+<cvar name="X_RPM_REQUIRES">
<summary>
-TODO
+This is used to fill in the
+<literal>Requires:</literal>
+field in the RPM
+<filename>.spec</filename> file.
</summary>
</cvar>
-<cvar name="X_MSI_UPGRADE_CODE">
+<cvar name="X_RPM_SERIAL">
<summary>
-TODO
+This is used to fill in the
+<literal>Serial:</literal>
+field in the RPM
+<filename>.spec</filename> file.
</summary>
</cvar>
-<cvar name="X_IPK_PRIORITY">
+<cvar name="X_RPM_URL">
<summary>
-TODO
+This is used to fill in the
+<literal>Url:</literal>
+field in the RPM
+<filename>.spec</filename> file.
</summary>
</cvar>
-<cvar name="X_IPK_SECTION">
+
+
+<!--
+
+THE FOLLOWING AREN'T CONSTRUCTION VARIABLES,
+THEY'RE "TAGS" THAT CAN BE ATTACHED
+TO DIFFERENT FILES OR DIRECTORIES.
+NOT SURE YET WHAT TO DO ABOUT THESE.
+
+<cvar name="CONFIG">
<summary>
TODO
</summary>
</cvar>
-<cvar name="X_IPK_MAINTAINER">
+<cvar name="CONFIG_NOREPLACE">
<summary>
TODO
</summary>
</cvar>
-<cvar name="X_IPK_DEPENDS">
+<cvar name="DOC">
<summary>
TODO
</summary>
</cvar>
-<cvar name="X_IPK_DESCRIPTION">
+<cvar name="INSTALL_LOCATION">
<summary>
-default is "$SUMMARY\n$DESCRIPTION"
+internal, but overridable, TODO
</summary>
</cvar>
-<cvar name="X_IPK_POSTRM">
+<cvar name="LANG_lang">
<summary>
TODO
</summary>
</cvar>
-<cvar name="X_IPK_PRERM">
+<cvar name="UNIX_ATTR">
<summary>
TODO
</summary>
@@ -394,61 +551,49 @@ TODO
</summary>
</cvar>
-<cvar name="X_IPK_PREINST">
+<cvar name="X_IPK_POSTRM">
<summary>
TODO
</summary>
</cvar>
-</builder>
-
-<builder name="Tag">
-Leaves hints for the Package() Builder on how specific should be packaged.
-All those tags are optional.
-<example>
-Tag( Library( 'lib.c' ), unix-attr="0644" ) # makes sure the built library will
- # be installed with 0644 file
- # access mode
-Tag( 'file2.txt', doc ) # marks file2.txt to be a documentation file
-</example>
-
-<cvar name="INSTALL_LOCATION">
+<cvar name="X_IPK_PREINST">
<summary>
-internal, but overridable, TODO
+TODO
</summary>
</cvar>
-<cvar name="CONFIG">
+<cvar name="X_IPK_PRERM">
<summary>
TODO
</summary>
</cvar>
-<cvar name="CONFIG_NOREPLACE">
+<cvar name="X_MSI_FEATURE">
<summary>
TODO
</summary>
</cvar>
-<cvar name="DOC">
+<cvar name="X_MSI_FILEID">
<summary>
TODO
</summary>
</cvar>
-<cvar name="UNIX_ATTR=">
+<cvar name="X_MSI_LONGNAME">
<summary>
TODO
</summary>
</cvar>
-<cvar name="LANG_<lang>">
+<cvar name="X_MSI_SHORTNAME">
<summary>
TODO
</summary>
</cvar>
-<cvar name="X_RPM_VERIFY">
+<cvar name="X_MSI_VITAL">
<summary>
TODO
</summary>
@@ -472,51 +617,42 @@ TODO
</summary>
</cvar>
-<cvar name="X_MSI_FEATURE=">
+<cvar name="X_RPM_VERIFY">
<summary>
TODO
</summary>
</cvar>
-<cvar name="X_MSI_VITAL">
-<summary>
-TODO
-</summary>
-</cvar>
+-->
-<cvar name="X_MSI_FILEID">
-<summary>
-TODO
-</summary>
-</cvar>
-<cvar name="X_MSI_LONGNAME">
+<!--
+<builder name="Tag">
<summary>
-TODO
-</summary>
-</cvar>
+Leaves hints for the Package() Builder on how specific
+files or directories should be packaged.
+All tags are optional.
-<cvar name="X_MSI_SHORTNAME">
-<summary>
-TODO
-</summary>
-</cvar>
+<example>
+# makes sure the built library will be installed with 0644 file
+# access mode
+Tag( Library( 'lib.c' ), unix-attr="0644" )
-<cvar name="X_MSI_SHORTNAME">
-<summary>
-TODO
+# marks file2.txt to be a documentation file
+Tag( 'file2.txt', doc )
+</example>
</summary>
-</cvar>
-
</builder>
-<builder name="FindSourceFiles">
-A convenience function which returns all leafs of the build tree.
-</builder>
+<function name="FindSourceFiles">
+<summary>
+A convenience function which returns all leaves of the build tree.
+</summary>
+</function>
<builder name="FindInstalledFiles">
-Returns all files "build" by the install builder.
-</builder>
-
-</tool>
-
+<summary>
+Returns all files "built" by the &b-Install; or &b-InstallAs; builders.
+</summary>
+</function>
+-->
diff --git a/src/engine/SCons/Tool/packaging/rpm.py b/src/engine/SCons/Tool/packaging/rpm.py
index 49b8ff8..94b7b7a 100644
--- a/src/engine/SCons/Tool/packaging/rpm.py
+++ b/src/engine/SCons/Tool/packaging/rpm.py
@@ -41,9 +41,7 @@ def package(env, target, source, PACKAGEROOT, NAME, VERSION,
# initialize the rpm tool
SCons.Tool.Tool('rpm').generate(env)
- # create the neccesary builder
bld = env['BUILDERS']['Rpm']
- env['RPMFLAGS'] = SCons.Util.CLVar('-ta')
bld.push_emitter(targz_emitter)
bld.push_emitter(specfile_emitter)
@@ -67,8 +65,9 @@ def package(env, target, source, PACKAGEROOT, NAME, VERSION,
if kw.has_key('ARCHITECTURE'):
buildarchitecture = kw['ARCHITECTURE']
- srcrpm = '%s-%s-%s.src.rpm' % (NAME, VERSION, PACKAGEVERSION)
- binrpm = string.replace(srcrpm, 'src', buildarchitecture)
+ fmt = '%s-%s-%s.%s.rpm'
+ srcrpm = fmt % (NAME, VERSION, PACKAGEVERSION, 'src')
+ binrpm = fmt % (NAME, VERSION, PACKAGEVERSION, buildarchitecture)
target = [ srcrpm, binrpm ]
diff --git a/src/engine/SCons/Tool/swig.py b/src/engine/SCons/Tool/swig.py
index 5326e8d..8ca1b89 100644
--- a/src/engine/SCons/Tool/swig.py
+++ b/src/engine/SCons/Tool/swig.py
@@ -33,57 +33,30 @@ selection method.
__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+import os.path
+import re
+
import SCons.Action
import SCons.Defaults
+import SCons.Scanner
import SCons.Tool
import SCons.Util
-from SCons.Scanner import Scanner
-import os
-import re
SwigAction = SCons.Action.Action('$SWIGCOM', '$SWIGCOMSTR')
def swigSuffixEmitter(env, source):
- if '-c++' in SCons.Util.CLVar(env.subst("$SWIGFLAGS")):
+ if '-c++' in SCons.Util.CLVar(env.subst("$SWIGFLAGS", source=source)):
return '$SWIGCXXFILESUFFIX'
else:
return '$SWIGCFILESUFFIX'
-_reInclude = re.compile(r'%include\s+(\S+)')
_reModule = re.compile(r'%module\s+(.+)')
-def recurse(path, searchPath):
- global _reInclude
- f = open(path)
- try: contents = f.read()
- finally: f.close()
-
- found = []
- # Better code for when we drop Python 1.5.2.
- #for m in _reInclude.finditer(contents):
- # fname = m.group(1)
- for fname in _reInclude.findall(contents):
- for dpath in searchPath:
- absPath = os.path.join(dpath, fname)
- if os.path.isfile(absPath):
- found.append(absPath)
- break
-
- # Equivalent code for when we drop Python 1.5.2.
- #for f in [f for f in found if os.path.splitext(f)[1] == ".i"]:
- # found += recurse(f, searchPath)
- for f in filter(lambda f: os.path.splitext(f)[1] == ".i", found):
- found = found + recurse(f, searchPath)
- return found
-
-def _scanSwig(node, env, path):
- r = recurse(str(node), [os.path.abspath(os.path.dirname(str(node))), os.path.abspath(os.path.join("include", "swig"))])
- return r
-
def _swigEmitter(target, source, env):
+ swigflags = env.subst("$SWIGFLAGS", target=target, source=source)
+ flags = SCons.Util.CLVar(swigflags)
for src in source:
- src = str(src)
- flags = SCons.Util.CLVar(env.subst("$SWIGFLAGS"))
+ src = str(src.rfile())
mnames = None
if "-python" in flags and "-noproxy" not in flags:
if mnames is None:
@@ -94,9 +67,13 @@ def _swigEmitter(target, source, env):
mnames = _reModule.findall(open(src).read())
java_files = map(lambda m: [m + ".java", m + "JNI.java"], mnames)
java_files = SCons.Util.flatten(java_files)
- outdir = env.subst('$SWIGOUTDIR')
+ outdir = env.subst('$SWIGOUTDIR', target=target, source=source)
if outdir:
java_files = map(lambda j, o=outdir: os.path.join(o, j), java_files)
+ java_files = map(env.fs.File, java_files)
+ for jf in java_files:
+ t_from_s = lambda t, p, s, x: t.dir
+ SCons.Util.AddMethod(jf, t_from_s, 'target_from_source')
target.extend(java_files)
return (target, source)
@@ -112,13 +89,28 @@ def generate(env):
cxx_file.add_action('.i', SwigAction)
cxx_file.add_emitter('.i', _swigEmitter)
+ java_file = SCons.Tool.CreateJavaFileBuilder(env)
+
+ java_file.suffix['.i'] = swigSuffixEmitter
+
+ java_file.add_action('.i', SwigAction)
+ java_file.add_emitter('.i', _swigEmitter)
+
env['SWIG'] = 'swig'
env['SWIGFLAGS'] = SCons.Util.CLVar('')
env['SWIGCFILESUFFIX'] = '_wrap$CFILESUFFIX'
env['SWIGCXXFILESUFFIX'] = '_wrap$CXXFILESUFFIX'
- env['_SWIGOUTDIR'] = '${"-outdir " + SWIGOUTDIR}'
- env['SWIGCOM'] = '$SWIG -o $TARGET ${_SWIGOUTDIR} $SWIGFLAGS $SOURCES'
- env.Append(SCANNERS=Scanner(function=_scanSwig, skeys=[".i"]))
+ env['_SWIGOUTDIR'] = '${"-outdir " + str(SWIGOUTDIR)}'
+ env['SWIGPATH'] = []
+ env['SWIGINCPREFIX'] = '-I'
+ env['SWIGINCSUFFIX'] = ''
+ env['_SWIGINCFLAGS'] = '$( ${_concat(SWIGINCPREFIX, SWIGPATH, SWIGINCSUFFIX, __env__, RDirs, TARGET, SOURCE)} $)'
+ env['SWIGCOM'] = '$SWIG -o $TARGET ${_SWIGOUTDIR} ${_SWIGINCFLAGS} $SWIGFLAGS $SOURCES'
+
+ expr = '^[ \t]*%[ \t]*(?:include|import|extern)[ \t]*(<|"?)([^>\s"]+)(?:>|"?)'
+ scanner = SCons.Scanner.ClassicCPP("SWIGScan", ".i", "SWIGPATH", expr)
+
+ env.Append(SCANNERS = scanner)
def exists(env):
return env.Detect(['swig'])
diff --git a/src/engine/SCons/Tool/swig.xml b/src/engine/SCons/Tool/swig.xml
index 679d683..580ef97 100644
--- a/src/engine/SCons/Tool/swig.xml
+++ b/src/engine/SCons/Tool/swig.xml
@@ -13,7 +13,11 @@ SWIG
SWIGFLAGS
SWIGCFILESUFFIX
SWIGCXXFILESUFFIX
+_SWIGINCFLAGS
+SWIGINCPREFIX
+SWIGINCSUFFIX
SWIGCOM
+SWIGPATH
</sets>
<uses>
SWIGCOMSTR
@@ -94,6 +98,36 @@ variable.
</summary>
</cvar>
+<cvar name="_SWIGINCFLAGS">
+<summary>
+An automatically-generated construction variable
+containing the SWIG command-line options
+for specifying directories to be searched for included files.
+The value of &cv-_SWIGINCFLAGS; is created
+by appending &cv-SWIGINCPREFIX; and &cv-SWIGINCSUFFIX;
+to the beginning and end
+of each directory in &cv-SWIGPATH;.
+</summary>
+</cvar>
+
+<cvar name="SWIGINCPREFIX">
+<summary>
+The prefix used to specify an include directory on the SWIG command line.
+This will be appended to the beginning of each directory
+in the &cv-SWIGPATH; construction variable
+when the &cv-_SWIGINCFLAGS; variable is automatically generated.
+</summary>
+</cvar>
+
+<cvar name="SWIGINCSUFFIX">
+<summary>
+The suffix used to specify an include directory on the SWIG command line.
+This will be appended to the end of each directory
+in the &cv-SWIGPATH; construction variable
+when the &cv-_SWIGINCFLAGS; variable is automatically generated.
+</summary>
+</cvar>
+
<cvar name="SWIGOUTDIR">
<summary>
Specifies the output directory in which
@@ -105,3 +139,55 @@ and translated into the
<literal>swig -outdir</literal> option on the command line.
</summary>
</cvar>
+
+<cvar name="SWIGPATH">
+<summary>
+The list of directories that the scripting language wrapper
+and interface generate will search for included files.
+The SWIG implicit dependency scanner will search these
+directories for include files.
+The default is to use the same path
+specified as &cv-CPPPATH;.
+
+Don't explicitly put include directory
+arguments in SWIGFLAGS;
+the result will be non-portable
+and the directories will not be searched by the dependency scanner.
+Note: directory names in SWIGPATH will be looked-up relative to the SConscript
+directory when they are used in a command.
+To force
+&scons;
+to look-up a directory relative to the root of the source tree use #:
+
+<example>
+env = Environment(SWIGPATH='#/include')
+</example>
+
+The directory look-up can also be forced using the
+&Dir;()
+function:
+
+<example>
+include = Dir('include')
+env = Environment(SWIGPATH=include)
+</example>
+
+The directory list will be added to command lines
+through the automatically-generated
+&cv-_SWIGINCFLAGS;
+construction variable,
+which is constructed by
+appending the values of the
+&cv-SWIGINCPREFIX; and &cv-SWIGINCSUFFIX;
+construction variables
+to the beginning and end
+of each directory in &cv-SWIGPATH;.
+Any command lines you define that need
+the SWIGPATH directory list should
+include &cv-_SWIGINCFLAGS;:
+
+<example>
+env = Environment(SWIGCOM="my_swig -o $TARGET $_SWIGINCFLAGS $SORUCES")
+</example>
+</summary>
+</cvar>
diff --git a/src/engine/SCons/Tool/wix.py b/src/engine/SCons/Tool/wix.py
index b133947..3aa3375 100644
--- a/src/engine/SCons/Tool/wix.py
+++ b/src/engine/SCons/Tool/wix.py
@@ -69,6 +69,9 @@ def exists(env):
# add the install directory to light libpath.
#for path in os.environ['PATH'].split(os.pathsep):
for path in string.split(os.environ['PATH'], os.pathsep):
+ if not path:
+ continue
+
# workaround for some weird python win32 bug.
if path[0] == '"' and path[-1:]=='"':
path = path[1:-1]
diff --git a/src/engine/SCons/Tool/yacc.py b/src/engine/SCons/Tool/yacc.py
index cbccb29..34f60cb 100644
--- a/src/engine/SCons/Tool/yacc.py
+++ b/src/engine/SCons/Tool/yacc.py
@@ -43,7 +43,8 @@ import SCons.Util
YaccAction = SCons.Action.Action("$YACCCOM", "$YACCCOMSTR")
def _yaccEmitter(target, source, env, ysuf, hsuf):
- flags = SCons.Util.CLVar(env.subst("$YACCFLAGS"))
+ yaccflags = env.subst("$YACCFLAGS", target=target, source=source)
+ flags = SCons.Util.CLVar(yaccflags)
targetBase, targetExt = os.path.splitext(SCons.Util.to_String(target[0]))
if '.ym' in ysuf: # If using Objective-C