From 93c9b57b0b04df896730fda0b0666e8d59b7d494 Mon Sep 17 00:00:00 2001 From: stevenknight Date: Fri, 17 Aug 2007 03:17:04 +0000 Subject: [PATCH] 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. ........ git-svn-id: http://scons.tigris.org/svn/scons/trunk@2302 fdb21ef1-2011-0410-befe-b5e4ea1792b1 --- .svnt/conf | 4 + HOWTO/release.txt | 6 - HOWTO/subrelease.txt | 6 - QMTest/SConscript | 8 +- QMTest/TestCommon.py | 32 + QMTest/TestRuntest.py | 30 - QMTest/TestSCons.py | 161 +++-- QMTest/TestSCons_time.py | 30 - QMTest/scons_tdb.py | 2 +- README | 2 +- SConstruct | 353 +++++++---- bin/docdiff | 8 +- bin/docrun | 4 +- bin/docupdate | 8 +- bin/linecount | 4 +- bin/scons-proc.py | 18 +- bin/sconsoutput.py | 6 + doc/.aeignore | 2 +- doc/SConscript | 64 +- doc/design/MANIFEST | 22 +- doc/design/{acks.sgml => acks.xml} | 0 doc/design/{bground.sgml => bground.xml} | 0 doc/design/{copyright.sgml => copyright.xml} | 0 doc/design/{engine.sgml => engine.xml} | 44 +- doc/design/{goals.sgml => goals.xml} | 16 +- doc/design/{install.sgml => install.xml} | 4 +- doc/design/{intro.sgml => intro.xml} | 4 +- doc/design/{issues.sgml => issues.xml} | 0 doc/design/{main.sgml => main.xml} | 31 +- doc/design/{native.sgml => native.xml} | 8 +- doc/design/{overview.sgml => overview.xml} | 4 +- doc/developer/MANIFEST | 18 +- .../{architecture.sgml => architecture.xml} | 0 doc/developer/{branches.sgml => branches.xml} | 0 .../{copyright.sgml => copyright.xml} | 0 doc/developer/{cycle.sgml => cycle.xml} | 0 doc/developer/{main.sgml => main.xml} | 23 +- .../{packaging.sgml => packaging.xml} | 0 doc/developer/{preface.sgml => preface.xml} | 0 .../{sourcetree.sgml => sourcetree.xml} | 0 doc/developer/{testing.sgml => testing.xml} | 0 doc/man/scons.1 | 108 ++-- doc/python10/MANIFEST | 18 +- doc/python10/{abstract.sgml => abstract.xml} | 0 doc/python10/{acks.sgml => acks.xml} | 0 .../{copyright.sgml => copyright.xml} | 0 doc/python10/{design.sgml => design.xml} | 0 doc/python10/{future.sgml => future.xml} | 0 doc/python10/{install.sgml => install.xml} | 0 doc/python10/{intro.sgml => intro.xml} | 0 doc/python10/{main.sgml => main.xml} | 21 +- doc/python10/{process.sgml => process.xml} | 0 doc/reference/{Alias.sgml => Alias.xml} | 0 doc/reference/{CFile.sgml => CFile.xml} | 0 doc/reference/{CXXFile.sgml => CXXFile.xml} | 0 doc/reference/{Command.sgml => Command.xml} | 0 doc/reference/{Install.sgml => Install.xml} | 0 .../{InstallAs.sgml => InstallAs.xml} | 0 doc/reference/{Library.sgml => Library.xml} | 0 doc/reference/MANIFEST | 42 +- doc/reference/{Object.sgml => Object.xml} | 0 doc/reference/{PCH.sgml => PCH.xml} | 0 doc/reference/{PDF.sgml => PDF.xml} | 0 .../{PostScript.sgml => PostScript.xml} | 0 doc/reference/{Program.sgml => Program.xml} | 0 doc/reference/{RES.sgml => RES.xml} | 0 .../{SharedLibrary.sgml => SharedLibrary.xml} | 0 .../{SharedObject.sgml => SharedObject.xml} | 0 .../{StaticLibrary.sgml => StaticLibrary.xml} | 0 .../{StaticObject.sgml => StaticObject.xml} | 0 .../{copyright.sgml => copyright.xml} | 0 doc/reference/{errors.sgml => errors.xml} | 0 doc/reference/{main.sgml => main.xml} | 47 +- doc/reference/{preface.sgml => preface.xml} | 0 doc/scons.mod | 3 + doc/user/{ENV.sgml => ENV.xml} | 0 doc/user/MANIFEST | 84 +-- doc/user/{actions.sgml => actions.xml} | 0 doc/user/{alias.sgml => alias.xml} | 0 doc/user/{ant.sgml => ant.xml} | 0 .../{build-install.sgml => build-install.xml} | 0 ...rs-built-in.sgml => builders-built-in.xml} | 0 doc/user/builders-commands.in | 19 +- ...rs-commands.sgml => builders-commands.xml} | 19 +- doc/user/builders-writing.in | 25 +- ...ders-writing.sgml => builders-writing.xml} | 21 +- doc/user/builders.in | 3 +- doc/user/{builders.sgml => builders.xml} | 3 +- doc/user/caching.in | 2 +- doc/user/{caching.sgml => caching.xml} | 20 + .../{command-line.sgml => command-line.xml} | 14 +- doc/user/{copyright.sgml => copyright.xml} | 0 doc/user/{depends.sgml => depends.xml} | 0 .../{environments.sgml => environments.xml} | 2 +- doc/user/{errors.sgml => errors.xml} | 0 doc/user/{example.sgml => example.xml} | 0 doc/user/factories.in | 8 +- doc/user/{factories.sgml => factories.xml} | 10 +- .../{file-removal.sgml => file-removal.xml} | 0 doc/user/{help.sgml => help.xml} | 0 doc/user/hierarchy.in | 4 +- doc/user/{hierarchy.sgml => hierarchy.xml} | 4 +- doc/user/{install.sgml => install.xml} | 0 doc/user/{java.sgml => java.xml} | 0 doc/user/less-simple.in | 12 +- .../{less-simple.sgml => less-simple.xml} | 18 +- doc/user/libraries.in | 4 +- doc/user/{libraries.sgml => libraries.xml} | 4 +- doc/user/main.in | 88 +-- doc/user/{main.sgml => main.xml} | 91 +-- doc/user/{make.sgml => make.xml} | 0 doc/user/{nodes.sgml => nodes.xml} | 0 .../{parseconfig.sgml => parseconfig.xml} | 0 doc/user/{preface.sgml => preface.xml} | 0 doc/user/{python.sgml => python.xml} | 0 .../{repositories.sgml => repositories.xml} | 0 doc/user/{run.sgml => run.xml} | 0 doc/user/{scanners.sgml => scanners.xml} | 0 doc/user/{sconf.sgml => sconf.xml} | 0 doc/user/{separate.sgml => separate.xml} | 0 doc/user/simple.in | 4 +- doc/user/{simple.sgml => simple.xml} | 4 +- doc/user/{sourcecode.sgml => sourcecode.xml} | 0 doc/user/{tasks.sgml => tasks.xml} | 0 doc/user/{tools.sgml => tools.xml} | 0 .../{troubleshoot.sgml => troubleshoot.xml} | 96 ++- doc/user/{variables.sgml => variables.xml} | 0 doc/user/{variants.sgml => variants.xml} | 0 rpm/scons.spec.in | 3 +- src/CHANGES.txt | 68 ++- src/RELEASE.txt | 64 +- src/engine/MANIFEST-xml.in | 3 + src/engine/MANIFEST.in | 30 +- src/engine/SCons/ActionTests.py | 2 +- src/engine/SCons/Builder.py | 71 ++- src/engine/SCons/BuilderTests.py | 33 +- src/engine/SCons/CacheDir.py | 207 +++++++ src/engine/SCons/CacheDirTests.py | 295 +++++++++ src/engine/SCons/Defaults.py | 2 + src/engine/SCons/Environment.py | 64 +- src/engine/SCons/EnvironmentTests.py | 9 +- src/engine/SCons/Executor.py | 6 +- src/engine/SCons/Node/FS.py | 232 +++---- src/engine/SCons/Node/FSTests.py | 264 +++----- src/engine/SCons/Node/NodeTests.py | 3 +- src/engine/SCons/PathList.py | 3 +- src/engine/SCons/PathListTests.py | 6 +- src/engine/SCons/Scanner/LaTeX.py | 6 +- src/engine/SCons/Script/Main.py | 25 +- src/engine/SCons/Script/SConsOptions.py | 69 ++- src/engine/SCons/Script/__init__.py | 6 +- src/engine/SCons/Tool/JavaCommonTests.py | 33 + src/engine/SCons/Tool/__init__.py | 77 +++ src/engine/SCons/Tool/aixlink.py | 2 +- src/engine/SCons/Tool/filesystem.py | 3 + src/engine/SCons/Tool/fortran.py | 4 +- src/engine/SCons/Tool/install.py | 8 +- src/engine/SCons/Tool/install.xml | 52 ++ src/engine/SCons/Tool/jar.py | 20 +- src/engine/SCons/Tool/jar.xml | 11 +- src/engine/SCons/Tool/javac.py | 167 ++++-- src/engine/SCons/Tool/javac.xml | 58 +- src/engine/SCons/Tool/javah.py | 24 +- src/engine/SCons/Tool/javah.xml | 6 +- src/engine/SCons/Tool/lex.py | 3 +- src/engine/SCons/Tool/packaging/__init__.py | 20 +- src/engine/SCons/Tool/packaging/__init__.xml | 490 +++++++++------ src/engine/SCons/Tool/packaging/rpm.py | 7 +- src/engine/SCons/Tool/swig.py | 70 +-- src/engine/SCons/Tool/swig.xml | 86 +++ src/engine/SCons/Tool/wix.py | 3 + src/engine/SCons/Tool/yacc.py | 3 +- src/engine/SCons/Util.py | 97 ++- src/engine/SCons/UtilTests.py | 8 +- src/engine/setup.py | 1 - src/setup.py | 6 +- src/test_interrupts.py | 9 +- src/test_pychecker.py | 4 - src/test_strings.py | 16 +- test/AS/ml.py | 2 +- test/AS/nasm.py | 2 +- test/Actions/addpost-link.py | 76 +++ test/Actions/pre-post.py | 4 +- test/AddOption/optional-arg.py | 102 ++++ test/BuildDir/CPPPATH-subdir.py | 1 + test/CPPPATH/match-dir.py | 61 ++ test/CacheDir/BuildDir.py | 7 +- test/CacheDir/environment.py | 163 +++++ test/{ => CacheDir}/option--cd.py | 0 test/{ => CacheDir}/option--cf.py | 0 test/{ => CacheDir}/option--cs.py | 0 test/Case.py | 3 + test/Fortran/FORTRANMODDIR.py | 5 + test/Java/JARCHDIR.py | 46 ++ test/Java/JAVACCOM.py | 2 +- test/Java/JAVACCOMSTR.py | 6 +- test/Java/JAVACLASSPATH.py | 104 ++++ test/Java/JAVASOURCEPATH.py | 81 +++ test/Java/Java-1.4.py | 93 ++- test/Java/Java-1.5.py | 93 ++- test/Java/Java-1.6.py | 93 ++- test/Java/multi-step.py | 567 ++++++++++++++++++ test/Java/source-files.py | 127 ++++ test/Java/swig-dependencies.py | 135 +++++ test/LEX/LEXFLAGS.py | 20 +- test/SWIG/SWIG.py | 15 +- test/SWIG/SWIGFLAGS.py | 69 +++ test/SWIG/SWIGOUTDIR.py | 11 + test/SWIG/SWIGPATH.py | 91 +++ test/SWIG/build-dir.py | 167 ++++++ test/SWIG/implicit-dependencies.py | 14 +- test/SWIG/live.py | 32 +- test/SWIG/noproxy.py | 30 +- test/SWIG/remove-modules.py | 22 +- test/Scanner/generated.py | 9 +- test/TEX/auxiliaries.py | 16 +- test/TEX/bibtex-latex-rerun.py | 17 +- test/YACC/YACCFLAGS.py | 18 +- test/import.py | 10 + test/long-lines.py | 7 + test/option--random.py | 4 +- test/option/debug-time.py | 13 +- test/option/tree-all.py | 8 +- test/option/tree-derived.py | 4 +- test/packaging/msi/file-placement.py | 126 ++-- test/packaging/msi/package.py | 83 +-- test/packaging/option--package-type.py | 3 + test/packaging/rpm/cleanup.py | 5 + test/packaging/rpm/internationalization.py | 3 + test/packaging/rpm/package.py | 3 + test/packaging/rpm/tagging.py | 5 + test/scons-time/run/archive/zip.py | 24 + test/scons-time/run/option/quiet.py | 5 +- test/scons-time/run/option/verbose.py | 5 +- 234 files changed, 5294 insertions(+), 1797 deletions(-) rename doc/design/{acks.sgml => acks.xml} (100%) rename doc/design/{bground.sgml => bground.xml} (100%) rename doc/design/{copyright.sgml => copyright.xml} (100%) rename doc/design/{engine.sgml => engine.xml} (99%) rename doc/design/{goals.sgml => goals.xml} (99%) rename doc/design/{install.sgml => install.xml} (98%) rename doc/design/{intro.sgml => intro.xml} (99%) rename doc/design/{issues.sgml => issues.xml} (100%) rename doc/design/{main.sgml => main.xml} (85%) rename doc/design/{native.sgml => native.xml} (99%) rename doc/design/{overview.sgml => overview.xml} (99%) rename doc/developer/{architecture.sgml => architecture.xml} (100%) rename doc/developer/{branches.sgml => branches.xml} (100%) rename doc/developer/{copyright.sgml => copyright.xml} (100%) rename doc/developer/{cycle.sgml => cycle.xml} (100%) rename doc/developer/{main.sgml => main.xml} (80%) rename doc/developer/{packaging.sgml => packaging.xml} (100%) rename doc/developer/{preface.sgml => preface.xml} (100%) rename doc/developer/{sourcetree.sgml => sourcetree.xml} (100%) rename doc/developer/{testing.sgml => testing.xml} (100%) rename doc/python10/{abstract.sgml => abstract.xml} (100%) rename doc/python10/{acks.sgml => acks.xml} (100%) rename doc/python10/{copyright.sgml => copyright.xml} (100%) rename doc/python10/{design.sgml => design.xml} (100%) rename doc/python10/{future.sgml => future.xml} (100%) rename doc/python10/{install.sgml => install.xml} (100%) rename doc/python10/{intro.sgml => intro.xml} (100%) rename doc/python10/{main.sgml => main.xml} (92%) rename doc/python10/{process.sgml => process.xml} (100%) rename doc/reference/{Alias.sgml => Alias.xml} (100%) rename doc/reference/{CFile.sgml => CFile.xml} (100%) rename doc/reference/{CXXFile.sgml => CXXFile.xml} (100%) rename doc/reference/{Command.sgml => Command.xml} (100%) rename doc/reference/{Install.sgml => Install.xml} (100%) rename doc/reference/{InstallAs.sgml => InstallAs.xml} (100%) rename doc/reference/{Library.sgml => Library.xml} (100%) rename doc/reference/{Object.sgml => Object.xml} (100%) rename doc/reference/{PCH.sgml => PCH.xml} (100%) rename doc/reference/{PDF.sgml => PDF.xml} (100%) rename doc/reference/{PostScript.sgml => PostScript.xml} (100%) rename doc/reference/{Program.sgml => Program.xml} (100%) rename doc/reference/{RES.sgml => RES.xml} (100%) rename doc/reference/{SharedLibrary.sgml => SharedLibrary.xml} (100%) rename doc/reference/{SharedObject.sgml => SharedObject.xml} (100%) rename doc/reference/{StaticLibrary.sgml => StaticLibrary.xml} (100%) rename doc/reference/{StaticObject.sgml => StaticObject.xml} (100%) rename doc/reference/{copyright.sgml => copyright.xml} (100%) rename doc/reference/{errors.sgml => errors.xml} (100%) rename doc/reference/{main.sgml => main.xml} (78%) rename doc/reference/{preface.sgml => preface.xml} (100%) rename doc/user/{ENV.sgml => ENV.xml} (100%) rename doc/user/{actions.sgml => actions.xml} (100%) rename doc/user/{alias.sgml => alias.xml} (100%) rename doc/user/{ant.sgml => ant.xml} (100%) rename doc/user/{build-install.sgml => build-install.xml} (100%) rename doc/user/{builders-built-in.sgml => builders-built-in.xml} (100%) rename doc/user/{builders-commands.sgml => builders-commands.xml} (90%) rename doc/user/{builders-writing.sgml => builders-writing.xml} (94%) rename doc/user/{builders.sgml => builders.xml} (92%) rename doc/user/{caching.sgml => caching.xml} (95%) rename doc/user/{command-line.sgml => command-line.xml} (98%) rename doc/user/{copyright.sgml => copyright.xml} (100%) rename doc/user/{depends.sgml => depends.xml} (100%) rename doc/user/{environments.sgml => environments.xml} (99%) rename doc/user/{errors.sgml => errors.xml} (100%) rename doc/user/{example.sgml => example.xml} (100%) rename doc/user/{factories.sgml => factories.xml} (97%) rename doc/user/{file-removal.sgml => file-removal.xml} (100%) rename doc/user/{help.sgml => help.xml} (100%) rename doc/user/{hierarchy.sgml => hierarchy.xml} (99%) rename doc/user/{install.sgml => install.xml} (100%) rename doc/user/{java.sgml => java.xml} (100%) rename doc/user/{less-simple.sgml => less-simple.xml} (97%) rename doc/user/{libraries.sgml => libraries.xml} (99%) rename doc/user/{main.sgml => main.xml} (77%) rename doc/user/{make.sgml => make.xml} (100%) rename doc/user/{nodes.sgml => nodes.xml} (100%) rename doc/user/{parseconfig.sgml => parseconfig.xml} (100%) rename doc/user/{preface.sgml => preface.xml} (100%) rename doc/user/{python.sgml => python.xml} (100%) rename doc/user/{repositories.sgml => repositories.xml} (100%) rename doc/user/{run.sgml => run.xml} (100%) rename doc/user/{scanners.sgml => scanners.xml} (100%) rename doc/user/{sconf.sgml => sconf.xml} (100%) rename doc/user/{separate.sgml => separate.xml} (100%) rename doc/user/{simple.sgml => simple.xml} (99%) rename doc/user/{sourcecode.sgml => sourcecode.xml} (100%) rename doc/user/{tasks.sgml => tasks.xml} (100%) rename doc/user/{tools.sgml => tools.xml} (100%) rename doc/user/{troubleshoot.sgml => troubleshoot.xml} (92%) rename doc/user/{variables.sgml => variables.xml} (100%) rename doc/user/{variants.sgml => variants.xml} (100%) create mode 100644 src/engine/SCons/CacheDir.py create mode 100644 src/engine/SCons/CacheDirTests.py create mode 100644 src/engine/SCons/Tool/install.xml create mode 100644 test/Actions/addpost-link.py create mode 100644 test/AddOption/optional-arg.py create mode 100644 test/CPPPATH/match-dir.py create mode 100644 test/CacheDir/environment.py rename test/{ => CacheDir}/option--cd.py (100%) rename test/{ => CacheDir}/option--cf.py (100%) rename test/{ => CacheDir}/option--cs.py (100%) create mode 100644 test/Java/JAVACLASSPATH.py create mode 100644 test/Java/JAVASOURCEPATH.py create mode 100644 test/Java/multi-step.py create mode 100644 test/Java/source-files.py create mode 100644 test/Java/swig-dependencies.py create mode 100644 test/SWIG/SWIGFLAGS.py create mode 100644 test/SWIG/SWIGPATH.py create mode 100644 test/SWIG/build-dir.py diff --git a/.svnt/conf b/.svnt/conf index 255a4ac4..dece3240 100644 --- a/.svnt/conf +++ b/.svnt/conf @@ -3,6 +3,10 @@ import sys python = os.environ.get('PYTHON', sys.executable) +build = [ + '"%(python)s" bootstrap.py %%s' % locals() +] + cmd = '"%(python)s" runtest.py -q --noqmtest %%s' % locals() test_inputs = [ diff --git a/HOWTO/release.txt b/HOWTO/release.txt index ca462639..5fbbfc7b 100644 --- a/HOWTO/release.txt +++ b/HOWTO/release.txt @@ -96,15 +96,9 @@ Things to do to release a new X.Y version of SCons: aecp SConstruct vi SConstruct - aecp rpm/scons.spec.in - vi rpm/scons.spec.in - aecp QMTest/TestSCons.py vi QMTest/TestSCons.py - aecp src/setup.py - vi src/setup.py - # Read through and update the README files if necessary [optional] aecp README [optional] vi README diff --git a/HOWTO/subrelease.txt b/HOWTO/subrelease.txt index 7b9254b1..ecfaa1f6 100644 --- a/HOWTO/subrelease.txt +++ b/HOWTO/subrelease.txt @@ -41,12 +41,6 @@ Things to do to release a new X.Y.Z version of SCons: aecp SConstruct vi SConstruct - aecp rpm/scons.spec.in - vi rpm/scons.spec.in - - aecp src/setup.py - vi src/setup.py - aecp QMTest/TestSCons.py vi QMTest/TestSCons.py diff --git a/QMTest/SConscript b/QMTest/SConscript index 3aa7d9cb..e141a514 100644 --- a/QMTest/SConscript +++ b/QMTest/SConscript @@ -26,6 +26,7 @@ # import os.path +import string Import('build_dir', 'env') @@ -45,7 +46,12 @@ files = [ def copy(target, source, env): t = str(target[0]) s = str(source[0]) - open(t, 'wb').write(open(s, 'rb').read()) + c = open(s, 'rb').read() + # Note: We construct the __ VERSION __ substitution string at + # run-time so it doesn't get replaced when this file gets copied + # into the tree for packaging. + c = string.replace(c, '__' + 'VERSION' + '__', env['VERSION']) + open(t, 'wb').write(c) for file in files: # Guarantee that real copies of these files always exist in diff --git a/QMTest/TestCommon.py b/QMTest/TestCommon.py index b215a265..b8fb5cdd 100644 --- a/QMTest/TestCommon.py +++ b/QMTest/TestCommon.py @@ -427,3 +427,35 @@ class TestCommon(TestCmd): print self.stdout() self.diff(stderr, self.stderr(), 'STDERR ') raise TestFailed + + def skip_test(self, message="Skipping test.\n"): + """Skips a test. + + Proper test-skipping behavior is dependent on the external + TESTCOMMON_PASS_SKIPS environment variable. If set, we treat + the skip as a PASS (exit 0), and otherwise treat it as NO RESULT. + In either case, we print the specified message as an indication + that the substance of the test was skipped. + + (This was originally added to support development under Aegis. + Technically, skipping a test is a NO RESULT, but Aegis would + treat that as a test failure and prevent the change from going to + the next step. Since we ddn't want to force anyone using Aegis + to have to install absolutely every tool used by the tests, we + would actually report to Aegis that a skipped test has PASSED + so that the workflow isn't held up.) + """ + if message: + sys.stdout.write(message) + sys.stdout.flush() + pass_skips = os.environ.get('TESTCOMMON_PASS_SKIPS') + if pass_skips in [None, 0, '0']: + # skip=1 means skip this function when showing where this + # result came from. They only care about the line where the + # script called test.skip_test(), not the line number where + # we call test.no_result(). + self.no_result(skip=1) + else: + # We're under the development directory for this change, + # so this is an Aegis invocation; pass the test (exit 0). + self.pass_test() diff --git a/QMTest/TestRuntest.py b/QMTest/TestRuntest.py index 94527469..ee33b250 100644 --- a/QMTest/TestRuntest.py +++ b/QMTest/TestRuntest.py @@ -158,36 +158,6 @@ class TestRuntest(TestCommon): os.environ['PYTHONPATH'] = '' os.environ['SCONS_SOURCE_PATH_EXECUTABLE'] = '' - def skip_test(self, message="Skipping test.\n"): - """Skips a test. - - Proper test-skipping behavior is dependent on whether we're being - executed as part of development of a change under Aegis. - - Technically, skipping a test is a NO RESULT, but Aegis will - treat that as a test failure and prevent the change from going - to the next step. We don't want to force anyone using Aegis - to have to install absolutely every tool used by the tests, - so we actually report to Aegis that a skipped test has PASSED - so that the workflow isn't held up. - """ - if message: - sys.stdout.write(message) - sys.stdout.flush() - devdir = os.popen("aesub '$dd' 2>/dev/null", "r").read()[:-1] - intdir = os.popen("aesub '$intd' 2>/dev/null", "r").read()[:-1] - if devdir and self._cwd[:len(devdir)] == devdir or \ - intdir and self._cwd[:len(intdir)] == intdir: - # We're under the development directory for this change, - # so this is an Aegis invocation; pass the test (exit 0). - self.pass_test() - else: - # skip=1 means skip this function when showing where this - # result came from. They only care about the line where the - # script called test.skip_test(), not the line number where - # we call test.no_result(). - self.no_result(skip=1) - def write_fake_scons_source_tree(self): os.mkdir('src') os.mkdir('src/script') diff --git a/QMTest/TestSCons.py b/QMTest/TestSCons.py index 100d8ba6..9c270fa2 100644 --- a/QMTest/TestSCons.py +++ b/QMTest/TestSCons.py @@ -38,11 +38,14 @@ from TestCommon import __all__ # Some tests which verify that SCons has been packaged properly need to # look for specific version file names. Replicating the version number -# here provides independent verification that what we packaged conforms -# to what we expect. (If we derived the version number from the same -# data driving the build we might miss errors if the logic breaks.) +# here provides some independent verification that what we packaged +# conforms to what we expect. -SConsVersion = '0.97' +default_version = '0.97.0' + +SConsVersion = '__VERSION__' +if SConsVersion == '__' + 'VERSION' + '__': + SConsVersion = default_version __all__.extend([ 'TestSCons', 'machine', @@ -186,6 +189,10 @@ class TestSCons(TestCommon): kw['workdir'] = '' apply(TestCommon.__init__, [self], kw) + import SCons.Node.FS + if SCons.Node.FS.default_fs is None: + SCons.Node.FS.default_fs = SCons.Node.FS.FS() + def Environment(self, ENV=None, *args, **kw): """ Return a construction Environment that optionally overrides @@ -292,36 +299,6 @@ class TestSCons(TestCommon): kw['match'] = self.match_re_dotall apply(self.run, [], kw) - def skip_test(self, message="Skipping test.\n"): - """Skips a test. - - Proper test-skipping behavior is dependent on whether we're being - executed as part of development of a change under Aegis. - - Technically, skipping a test is a NO RESULT, but Aegis will - treat that as a test failure and prevent the change from going - to the next step. We don't want to force anyone using Aegis - to have to install absolutely every tool used by the tests, - so we actually report to Aegis that a skipped test has PASSED - so that the workflow isn't held up. - """ - if message: - sys.stdout.write(message) - sys.stdout.flush() - devdir = os.popen("aesub '$dd' 2>/dev/null", "r").read()[:-1] - intdir = os.popen("aesub '$intd' 2>/dev/null", "r").read()[:-1] - if devdir and self._cwd[:len(devdir)] == devdir or \ - intdir and self._cwd[:len(intdir)] == intdir: - # We're under the development directory for this change, - # so this is an Aegis invocation; pass the test (exit 0). - self.pass_test() - else: - # skip=1 means skip this function when showing where this - # result came from. They only care about the line where the - # script called test.skip_test(), not the line number where - # we call test.no_result(). - self.no_result(skip=1) - def diff_substr(self, expect, actual, prelen=20, postlen=40): i = 0 for x, y in zip(expect, actual): @@ -361,6 +338,44 @@ class TestSCons(TestCommon): r'/CreationDate (D:XXXX)', s) s = re.sub(r'/ID \[<[0-9a-fA-F]*> <[0-9a-fA-F]*>\]', r'/ID [ ]', s) + s = re.sub(r'/(BaseFont|FontName) /[A-Z]{6}', + r'/\1 /XXXXXX', s) + s = re.sub(r'/Length \d+ *\n/Filter /FlateDecode\n', + r'/Length XXXX\n/Filter /FlateDecode\n', s) + + + try: + import zlib + except ImportError: + pass + else: + begin_marker = '/FlateDecode\n>>\nstream\n' + end_marker = 'endstream\nendobj' + + encoded = [] + b = string.find(s, begin_marker, 0) + while b != -1: + b = b + len(begin_marker) + e = string.find(s, end_marker, b) + encoded.append((b, e)) + b = string.find(s, begin_marker, e + len(end_marker)) + + x = 0 + r = [] + for b, e in encoded: + r.append(s[x:b]) + d = zlib.decompress(s[b:e]) + d = re.sub(r'%%CreationDate: [^\n]*\n', + r'%%CreationDate: 1970 Jan 01 00:00:00\n', d) + d = re.sub(r'%DVIPSSource: TeX output \d\d\d\d\.\d\d\.\d\d:\d\d\d\d', + r'%DVIPSSource: TeX output 1970.01.01:0000', d) + d = re.sub(r'/(BaseFont|FontName) /[A-Z]{6}', + r'/\1 /XXXXXX', d) + r.append(d) + x = e + r.append(s[x:]) + s = string.join(r, '') + return s def java_ENV(self): @@ -744,6 +759,84 @@ print "self._msvs_versions =", str(env['MSVS']['VERSIONS']) print "-----------------------------------------------------" self.fail_test() + def get_python_version(self): + """ + Returns the Python version (just so everyone doesn't have to + hand-code slicing the right number of characters). + """ + # see also sys.prefix documentation + return sys.version[:3] + + def get_platform_python(self): + """ + Returns a path to a Python executable suitable for testing on + this platform. + + Mac OS X has no static libpython for SWIG to link against, + so we have to link against Apple's framwork version. However, + testing must use the executable version that corresponds to the + framework we link against, or else we get interpreter errors. + """ + if sys.platform == 'darwin': + return '/System/Library/Frameworks/Python.framework/Versions/Current/bin/python' + else: + global python + return python + + def get_quoted_platform_python(self): + """ + Returns a quoted path to a Python executable suitable for testing on + this platform. + + Mac OS X has no static libpython for SWIG to link against, + so we have to link against Apple's framwork version. However, + testing must use the executable version that corresponds to the + framework we link against, or else we get interpreter errors. + """ + if sys.platform == 'darwin': + return '"' + self.get_platform_python() + '"' + else: + global _python_ + return _python_ + + def get_platform_sys_prefix(self): + """ + Returns a "sys.prefix" value suitable for linking on this platform. + + Mac OS X has a built-in Python but no static libpython, + so we must link to it using Apple's 'framework' scheme. + """ + if sys.platform == 'darwin': + fmt = '/System/Library/Frameworks/Python.framework/Versions/%s/' + return fmt % self.get_python_version() + else: + return sys.prefix + + def get_python_frameworks_flags(self): + """ + Returns a FRAMEWORKSFLAGS value for linking with Python. + + Mac OS X has a built-in Python but no static libpython, + so we must link to it using Apple's 'framework' scheme. + """ + if sys.platform == 'darwin': + return '-framework Python' + else: + return '' + + def get_python_inc(self): + """ + Returns a path to the Python include directory. + """ + try: + import distutils.sysconfig + except ImportError: + return os.path.join(self.get_platform_sys_prefix(), + 'include', + 'python' + self.get_python_version()) + else: + return distutils.sysconfig.get_python_inc() + # In some environments, $AR will generate a warning message to stderr # if the library doesn't previously exist and is being created. One # way to fix this is to tell AR to be quiet (sometimes the 'c' flag), diff --git a/QMTest/TestSCons_time.py b/QMTest/TestSCons_time.py index 1ceb5298..102181e4 100644 --- a/QMTest/TestSCons_time.py +++ b/QMTest/TestSCons_time.py @@ -246,36 +246,6 @@ class TestSCons_time(TestCommon): self.write(python_name, profile_py % d) self.run(program = python_name, interpreter = sys.executable) - def skip_test(self, message="Skipping test.\n"): - """Skips a test. - - Proper test-skipping behavior is dependent on whether we're being - executed as part of development of a change under Aegis. - - Technically, skipping a test is a NO RESULT, but Aegis will - treat that as a test failure and prevent the change from going - to the next step. We don't want to force anyone using Aegis - to have to install absolutely every tool used by the tests, - so we actually report to Aegis that a skipped test has PASSED - so that the workflow isn't held up. - """ - if message: - sys.stdout.write(message) - sys.stdout.flush() - devdir = os.popen("aesub '$dd' 2>/dev/null", "r").read()[:-1] - intdir = os.popen("aesub '$intd' 2>/dev/null", "r").read()[:-1] - if devdir and self._cwd[:len(devdir)] == devdir or \ - intdir and self._cwd[:len(intdir)] == intdir: - # We're under the development directory for this change, - # so this is an Aegis invocation; pass the test (exit 0). - self.pass_test() - else: - # skip=1 means skip this function when showing where this - # result came from. They only care about the line where the - # script called test.skip_test(), not the line number where - # we call test.no_result(). - self.no_result(skip=1) - def write_fake_aegis_py(self, name): name = self.workpath(name) self.write(name, aegis_py) diff --git a/QMTest/scons_tdb.py b/QMTest/scons_tdb.py index e0d76830..954b8df6 100644 --- a/QMTest/scons_tdb.py +++ b/QMTest/scons_tdb.py @@ -429,7 +429,7 @@ class Test(AegisTest): and fails otherwise. The program output is logged, but not validated.""" command = RedirectedExecutable() - args = [context.get('python', sys.executable), self.script] + args = [context.get('python', sys.executable), '-tt', self.script] status = command.Run(args, os.environ) if not check_exit_status(result, 'Test.', self.script, status): # In case of failure record exit code, stdout, and stderr. diff --git a/README b/README index 6eecb8c4..36dbe230 100644 --- a/README +++ b/README @@ -606,7 +606,7 @@ bin/ of lines in each -- a script for synchronizing the Aegis tree to SourceForge -- a prototype script for capturing sample SCons output - in sgml files + in xml files -- a script that can profile and time a packaging build of SCons itself -- a copy of xml_export, which can retrieve project data diff --git a/SConstruct b/SConstruct index a81b37ba..e00e1091 100644 --- a/SConstruct +++ b/SConstruct @@ -35,17 +35,16 @@ month_year = 'January 2007' # import distutils.util +import fnmatch import os import os.path import re -import socket import stat import string import sys -import time project = 'scons' -default_version = '0.97' +default_version = '0.97.0' copyright = "Copyright (c) %s The SCons Foundation" % copyright_years SConsignFile() @@ -67,89 +66,80 @@ def whereis(file): return None # -# We let the presence or absence of various utilities determine -# whether or not we bother to build certain pieces of things. -# This should allow people to still do SCons work even if they -# don't have Aegis or RPM installed, for example. +# We let the presence or absence of various utilities determine whether +# or not we bother to build certain pieces of things. This should allow +# people to still do SCons packaging work even if they don't have all +# of the utilities installed (e.g. RPM). # -aegis = whereis('aegis') -aesub = whereis('aesub') dh_builddeb = whereis('dh_builddeb') fakeroot = whereis('fakeroot') gzip = whereis('gzip') rpmbuild = whereis('rpmbuild') or whereis('rpm') +svn = whereis('svn') unzip = whereis('unzip') zip = whereis('zip') # # Now grab the information that we "build" into the files. # -try: - date = ARGUMENTS['date'] -except: +date = ARGUMENTS.get('DATE') +if not date: + import time date = time.strftime("%Y/%m/%d %H:%M:%S", time.localtime(time.time())) -if ARGUMENTS.has_key('developer'): - developer = ARGUMENTS['developer'] -elif os.environ.has_key('USERNAME'): - developer = os.environ['USERNAME'] -elif os.environ.has_key('LOGNAME'): - developer = os.environ['LOGNAME'] -elif os.environ.has_key('USER'): - developer = os.environ['USER'] - -if ARGUMENTS.has_key('build_system'): - build_system = ARGUMENTS['build_system'] -else: +developer = ARGUMENTS.get('DEVELOPER') +if not developer: + for variable in ['USERNAME', 'LOGNAME', 'USER']: + developer = os.environ.get(variable) + if developer: + break + +build_system = ARGUMENTS.get('BUILD_SYSTEM') +if not build_system: + import socket build_system = string.split(socket.gethostname(), '.')[0] -if ARGUMENTS.has_key('version'): - revision = ARGUMENTS['version'] -elif aesub: - revision = os.popen(aesub + " \\$version", "r").read()[:-1] -else: - revision = default_version - -# This is old code that adds an initial "0" to revision numbers < 10. -#a = string.split(revision, '.') -#arr = [a[0]] -#for s in a[1:]: -# if len(s) == 1: -# s = '0' + s -# arr.append(s) -#revision = string.join(arr, '.') - -# Here's how we'd turn the calculated $revision into our package $version. -# This makes it difficult to coordinate with other files (debian/changelog -# and rpm/scons.spec) that hard-code the version number, so just go with -# the flow for now and hard code it here, too. -#if len(arr) >= 2: -# arr = arr[:-1] -#def xxx(str): -# if str[0] == 'C' or str[0] == 'D': -# str = str[1:] -# while len(str) > 2 and str[0] == '0': -# str = str[1:] -# return str -#arr = map(lambda x, xxx=xxx: xxx(x), arr) -#version = string.join(arr, '.') -version = default_version - -build_id = string.replace(revision, version + '.', '') - -if ARGUMENTS.has_key('change'): - change = ARGUMENTS['change'] -elif aesub: - change = os.popen(aesub + " \\$change", "r").read()[:-1] +version = ARGUMENTS.get('VERSION', '') +if not version: + version = default_version + +revision = ARGUMENTS.get('REVISION', '') +if not revision and svn: + svn_info = os.popen("%s info 2> /dev/null" % svn, "r").read() + m = re.search('Revision: (\d+)', svn_info) + if m: + revision = m.group(1) + +checkpoint = ARGUMENTS.get('CHECKPOINT', '') +if checkpoint: + if checkpoint == 'd': + import time + checkpoint = time.strftime('d%Y%m%d', time.localtime(time.time())) + elif checkpoint == 'r': + checkpoint = 'r' + revision + version = version + checkpoint + +if svn: + svn_status = os.popen("%s status --verbose 2> /dev/null" % svn, "r").read() + svn_status_lines = svn_status[:-1].split('\n') else: - change = default_version + svn_status_lines = [] + +build_id = ARGUMENTS.get('BUILD_ID') +if build_id is None: + if revision: + build_id = 'r' + revision + if filter(lambda l: l[0] in 'ACDMR', svn_status_lines): + build_id = build_id + '[MODIFIED]' + else: + build_id = '' python_ver = sys.version[0:3] platform = distutils.util.get_platform() ENV = { 'PATH' : os.environ['PATH'] } -for key in ['AEGIS_PROJECT', 'LOGNAME', 'PYTHONPATH']: +for key in ['LOGNAME', 'PYTHONPATH']: if os.environ.has_key(key): ENV[key] = os.environ[key] @@ -157,17 +147,68 @@ build_dir = ARGUMENTS.get('BUILDDIR', 'build') if not os.path.isabs(build_dir): build_dir = os.path.normpath(os.path.join(os.getcwd(), build_dir)) +command_line_variables = [ + ("BUILDDIR=", "The directory in which to build the packages. " + + "The default is the './build' subdirectory."), + + ("BUILD_ID=", "An identifier for the specific build." + + "The default is the Subversion revision number."), + + ("BUILD_SYSTEM=", "The system on which the packages were built. " + + "The default is whatever hostname is returned " + + "by socket.gethostname()."), + + ("CHECKPOINT=", "The specific checkpoint release being packaged. " + + "This will be appended to the VERSION string. " + + "A value of CHECKPOINT=d will generate a string " + + "of 'd' plus today's date in the format YYYMMDD." + + "A value of CHECKPOINT=r will generate a " + + "string of 'r' plus the Subversion revision number. " + + "Any other CHECKPOINT= string will be used as is." + + "There is no default value."), + + ("DATE=", "The date string representing when the packaging " + + "build occurred. The default is the day and time " + + "the SConstruct file was invoked, in the format " + + "YYYY/MM/DD HH:MM:SS."), + + ("DEVELOPER=", "The developer who created the packages. " + + "The default is the first set environment " + + "variable from the list $USERNAME, $LOGNAME, $USER."), + + ("REVISION=", "The revision number of the source being built. " + + "The default is the Subversion revision returned " + + "'svn info', with an appended string of " + + "'[MODIFIED]' if there are any changes in the " + + "working copy."), + + ("VERSION=", "The SCons version being packaged. The default " + + "is the hard-coded value '%s' " % default_version + + "from this SConstruct file."), +] + Default('.', build_dir) packaging_flavors = [ - 'deb', - 'rpm', - 'tar-gz', - 'src-tar-gz', - 'local-tar-gz', - 'zip', - 'src-zip', - 'local-zip', + ('deb', "A .deb package. (This is currently not supported.)"), + + ('rpm', "A RedHat Package Manager file."), + + ('tar-gz', "The normal .tar.gz file for end-user installation."), + + ('src-tar-gz', "A .tar.gz file containing all the source " + + "(including tests and documentation)."), + + ('local-tar-gz', "A .tar.gz file for dropping into other software " + + "for local use."), + + ('zip', "The normal .zip file for end-user installation."), + + ('src-zip', "A .zip file containing all the source " + + "(including tests and documentation)."), + + ('local-zip', "A .zip file for dropping into other software " + + "for local use."), ] test_deb_dir = os.path.join(build_dir, "test-deb") @@ -192,6 +233,44 @@ else: project_script_subinst_dir = 'bin' + +import textwrap + +indent_fmt = ' %-26s ' + +Help(""" +The following aliases build packages of various types, and unpack the +contents into build/test-$PACKAGE subdirectories, which can be used by the +runtest.py -p option to run tests against what's been actually packaged: + +""") + +aliases = packaging_flavors + [('doc', 'The SCons documentation.')] +aliases.sort() + +for alias, help_text in aliases: + tw = textwrap.TextWrapper( + width = 78, + initial_indent = indent_fmt % alias, + subsequent_indent = indent_fmt % '' + ' ', + ) + Help(tw.fill(help_text) + '\n') + +Help(""" +The following command-line variables can be set: + +""") + +for variable, help_text in command_line_variables: + tw = textwrap.TextWrapper( + width = 78, + initial_indent = indent_fmt % variable, + subsequent_indent = indent_fmt % '' + ' ', + ) + Help(tw.fill(help_text) + '\n') + + + zcat = 'gzip -d -c' # @@ -312,6 +391,7 @@ env = Environment( COPYRIGHT = copyright, DATE = date, DEVELOPER = developer, + DISTDIR = os.path.join(build_dir, 'dist'), MONTH_YEAR = month_year, REVISION = revision, VERSION = version, @@ -342,7 +422,7 @@ env = Environment( BUILDERS = { 'SCons_revision' : revbuilder, 'SOElim' : soelimbuilder }, - PYTHON = sys.executable, + PYTHON = '"%s"' % sys.executable, PYTHONFLAGS = '-tt', ) @@ -393,11 +473,26 @@ python_scons = { 'buildermap' : {}, + 'extra_rpm_files' : [], + 'explicit_deps' : { 'SCons/__init__.py' : Version_values, }, } +# The RPM spec file we generate will just execute "python", not +# necessarily the one in sys.executable. If that version of python has +# a distutils that knows about Python eggs, then setup.py will generate +# a .egg-info file. Check for whether or not to add it to the expected +# RPM files by executing "python" in a subshell. + +cmd = "python -c 'import distutils.command.install_egg_info' > /dev/null 2>&1" +import_egg_error = os.system(cmd) + +if not import_egg_error: + egg_info_file = 'scons-' + version + '.egg-info' + python_scons['extra_rpm_files'].append(egg_info_file) + # # The original packaging scheme would have have required us to push # the Python version number into the package name (python1.5-scons, @@ -568,7 +663,7 @@ for p in [ scons ]: setup_py = os.path.join(build, 'setup.py') env.Replace(PKG = pkg, PKG_VERSION = pkg_version, - SETUP_PY = setup_py) + SETUP_PY = '"%s"' % setup_py) Local(setup_py) # @@ -670,7 +765,7 @@ for p in [ scons ]: distutils_targets = [ win32_exe ] - install_targets = distutils_targets[:] + Local(env.Install('$DISTDIR', distutils_targets)) if gzip: @@ -679,7 +774,10 @@ for p in [ scons ]: src_deps.append(tar_gz) distutils_targets.extend([ tar_gz, platform_tar_gz ]) - install_targets.extend([ tar_gz, platform_tar_gz ]) + + dist_tar_gz = env.Install('$DISTDIR', tar_gz) + dist_platform_tar_gz = env.Install('$DISTDIR', platform_tar_gz) + Local(dist_tar_gz, dist_platform_tar_gz) # # Unpack the tar.gz archive created by the distutils into @@ -695,7 +793,7 @@ for p in [ scons ]: unpack_tar_gz_files = map(lambda x, u=unpack_tar_gz_dir, pv=pkg_version: os.path.join(u, pv, x), src_files) - env.Command(unpack_tar_gz_files, tar_gz, [ + env.Command(unpack_tar_gz_files, dist_tar_gz, [ Delete(os.path.join(unpack_tar_gz_dir, pkg_version)), "$ZCAT $SOURCES > .temp", "tar xf .temp -C $UNPACK_TAR_GZ_DIR", @@ -760,7 +858,10 @@ for p in [ scons ]: src_deps.append(zip) distutils_targets.extend([ zip, platform_zip ]) - install_targets.extend([ zip, platform_zip ]) + + dist_zip = env.Install('$DISTDIR', zip) + dist_platform_zip = env.Install('$DISTDIR', platform_zip) + Local(dist_zip, dist_platform_zip) # # Unpack the zip archive created by the distutils into @@ -770,7 +871,7 @@ for p in [ scons ]: os.path.join(u, pv, x), src_files) - env.Command(unpack_zip_files, zip, [ + env.Command(unpack_zip_files, dist_zip, [ Delete(os.path.join(unpack_zip_dir, pkg_version)), unzipit, ]) @@ -796,7 +897,10 @@ for p in [ scons ]: os.path.join(unpack_zip_dir, pkg_version, 'setup.py'), ]) - if rpmbuild: + if not rpmbuild: + msg = "@echo \"Warning: Can not build 'rpm': no rpmbuild utility found\"" + AlwaysBuild(Alias('rpm', [], msg)) + else: topdir = os.path.join(build, 'build', 'bdist.' + platform, 'rpm') @@ -822,7 +926,8 @@ for p in [ scons ]: maintain multiple lists. """ c = open(str(source[0]), 'rb').read() - c = string.replace(c, '__RPM_FILES__', env['RPM_FILES']) + c = string.replace(c, '__VERSION' + '__', env['VERSION']) + c = string.replace(c, '__RPM_FILES' + '__', env['RPM_FILES']) open(str(target[0]), 'wb').write(c) rpm_files.sort() @@ -838,20 +943,22 @@ for p in [ scons ]: cmd = "$RPMBUILD --define '_topdir $(%s$)' --buildroot %s -ba $SOURCES" % (topdir, buildroot) if not os.path.isdir(BUILDdir): cmd = ("$( mkdir -p %s; $)" % BUILDdir) + cmd - env.Command(targets, specfile, cmd) - env.Depends(targets, sourcefile) + t = env.Command(targets, specfile, cmd) + env.Depends(t, sourcefile) - install_targets.extend(targets) + dist_noarch_rpm = env.Install('$DISTDIR', noarch_rpm) + dist_src_rpm = env.Install('$DISTDIR', src_rpm) + Local(dist_noarch_rpm, dist_src_rpm) dfiles = map(lambda x, d=test_rpm_dir: os.path.join(d, 'usr', x), dst_files) env.Command(dfiles, - noarch_rpm, + dist_noarch_rpm, "$RPM2CPIO $SOURCES | (cd $TEST_RPM_DIR && cpio -id)") if dh_builddeb and fakeroot: # Our Debian packaging builds directly into build/dist, - # so we don't need to add the .debs to install_targets. + # so we don't need to Install() the .debs. deb = os.path.join(build_dir, 'dist', "%s_%s-1_all.deb" % (pkg, version)) for d in p['debian_deps']: b = env.SCons_revision(os.path.join(build, d), d) @@ -908,8 +1015,8 @@ for p in [ scons ]: build_dir_local = os.path.join(build_dir, local) build_dir_local_slv = os.path.join(build_dir, local, s_l_v) - local_tar_gz = os.path.join(build_dir, 'dist', "%s.tar.gz" % s_l_v) - local_zip = os.path.join(build_dir, 'dist', "%s.zip" % s_l_v) + dist_local_tar_gz = os.path.join("$DISTDIR/%s.tar.gz" % s_l_v) + dist_local_zip = os.path.join("$DISTDIR/%s.zip" % s_l_v) commands = [ Delete(build_dir_local), @@ -941,7 +1048,7 @@ for p in [ scons ]: Local(l) if gzip: - env.Command(local_tar_gz, + env.Command(dist_local_tar_gz, local_targets, "cd %s && tar czf $( ${TARGET.abspath} $) *" % build_dir_local) @@ -952,10 +1059,10 @@ for p in [ scons ]: Mkdir(test_local_tar_gz_dir), "cd %s && tar xzf $( ${SOURCE.abspath} $)" % test_local_tar_gz_dir] - env.Command(unpack_targets, local_tar_gz, commands) + env.Command(unpack_targets, dist_local_tar_gz, commands) if zipit: - env.Command(local_zip, local_targets, zipit, + env.Command(dist_local_zip, local_targets, zipit, CD = build_dir_local, PSV = '.') unpack_targets = map(lambda x, d=test_local_zip_dir: @@ -965,16 +1072,9 @@ for p in [ scons ]: Mkdir(test_local_zip_dir), unzipit] - env.Command(unpack_targets, local_zip, unzipit, + env.Command(unpack_targets, dist_local_zip, unzipit, UNPACK_ZIP_DIR = test_local_zip_dir) - # - # And, lastly, install the appropriate packages in the - # appropriate subdirectory. - # - b_d_files = env.Install(os.path.join(build_dir, 'dist'), install_targets) - Local(b_d_files) - # # # @@ -1014,35 +1114,24 @@ Export('build_dir', 'env', 'whereis') SConscript('doc/SConscript') # -# If we're running in the actual Aegis project, pack up a complete -# source archive from the project files and files in the change, -# so we can share it with helpful developers who don't use Aegis. +# If we're running in a Subversion working directory, pack up a complete +# source archive from the project files and files in the change. # -if change: - df = [] - cmd = "aegis -list -unf -c %s cf 2>/dev/null" % change - for line in map(lambda x: x[:-1], os.popen(cmd, "r").readlines()): - a = string.split(line) - if a[1] == "remove": - df.append(a[-1]) - - cmd = "aegis -list -terse pf 2>/dev/null" - pf = map(lambda x: x[:-1], os.popen(cmd, "r").readlines()) - cmd = "aegis -list -terse -c %s cf 2>/dev/null" % change - cf = map(lambda x: x[:-1], os.popen(cmd, "r").readlines()) - u = {} - for f in pf + cf: - u[f] = 1 - for f in df: - try: - del u[f] - except KeyError: - pass - sfiles = filter(lambda x: x[-9:] != '.aeignore' and - x[-9:] != '.sconsign' and - x[-10:] != '.cvsignore', - u.keys()) +if svn_status: + slines = filter(lambda l: l[0] in ' MA', svn_status_lines) + sentries = map(lambda l: l.split()[-1], slines) + sfiles = filter(os.path.isfile, sentries) + + remove_patterns = [ + '.svnt/*', + '*.aeignore', + '*.cvsignore', + 'www/*', + ] + + for p in remove_patterns: + sfiles = filter(lambda s, p=p: not fnmatch.fnmatch(s, p), sfiles) if sfiles: ps = "%s-src" % project @@ -1123,7 +1212,7 @@ if change: 'scons', 'build')), Delete("$TEST_SRC_TAR_GZ_DIR"), - 'cd "%s" && $PYTHON $PYTHONFLAGS "%s" "%s"' % \ + 'cd "%s" && $PYTHON $PYTHONFLAGS "%s" "%s" VERSION="$VERSION"' % \ (os.path.join(unpack_tar_gz_dir, psv), os.path.join('src', 'script', 'scons.py'), os.path.join('build', 'scons')), @@ -1179,7 +1268,7 @@ if change: 'scons', 'build')), Delete("$TEST_SRC_ZIP_DIR"), - 'cd "%s" && $PYTHON $PYTHONFLAGS "%s" "%s"' % \ + 'cd "%s" && $PYTHON $PYTHONFLAGS "%s" "%s" VERSION="$VERSION"' % \ (os.path.join(unpack_zip_dir, psv), os.path.join('src', 'script', 'scons.py'), os.path.join('build', 'scons')), @@ -1192,5 +1281,9 @@ if change: ], ENV = ENV) -for pf in packaging_flavors: - Alias(pf, ['build/test-'+pf, 'build/QMTest', 'build/runtest.py']) +for pf, help_text in packaging_flavors: + Alias(pf, [ + os.path.join(build_dir, 'test-'+pf), + os.path.join(build_dir, 'QMTest'), + os.path.join(build_dir, 'runtest.py'), + ]) diff --git a/bin/docdiff b/bin/docdiff index 59f9472d..c565a043 100644 --- a/bin/docdiff +++ b/bin/docdiff @@ -2,15 +2,15 @@ if test $# -eq 0; then for f in doc/user/*.in; do - sgml=doc/user/`basename $f .in`.sgml + xml=doc/user/`basename $f .in`.xml echo $f: - python bin/sconsoutput.py $f | diff $DIFFFLAGS $sgml - + python bin/sconsoutput.py $f | diff $DIFFFLAGS $xml - done else for a in $*; do f=doc/user/$a.in - sgml=doc/user/$a.sgml + xml=doc/user/$a.xml echo $f: - python bin/sconsoutput.py $f | diff $DIFFFLAGS $sgml - + python bin/sconsoutput.py $f | diff $DIFFFLAGS $xml - done fi diff --git a/bin/docrun b/bin/docrun index 57ad2021..5ba4215c 100644 --- a/bin/docrun +++ b/bin/docrun @@ -2,14 +2,14 @@ if test $# -eq 0; then for f in doc/user/*.in; do - sgml=doc/user/`basename $f .in`.sgml + xml=doc/user/`basename $f .in`.xml echo $f: python bin/sconsoutput.py $f done else for a in $*; do f=doc/user/$a.in - sgml=doc/user/$a.sgml + xml=doc/user/$a.xml echo $f: python bin/sconsoutput.py $f done diff --git a/bin/docupdate b/bin/docupdate index c4eedb82..0e1631b6 100644 --- a/bin/docupdate +++ b/bin/docupdate @@ -2,15 +2,15 @@ if test $# -eq 0; then for f in doc/user/*.in; do - sgml=doc/user/`basename $f .in`.sgml + xml=doc/user/`basename $f .in`.xml echo $f: - python bin/sconsoutput.py $f > $sgml + python bin/sconsoutput.py $f > $xml done else for a in $*; do f=doc/user/$a.in - sgml=doc/user/$a.sgml + xml=doc/user/$a.xml echo $f: - python bin/sconsoutput.py $f > $sgml + python bin/sconsoutput.py $f > $xml done fi diff --git a/bin/linecount b/bin/linecount index 765309ef..7ab37f58 100644 --- a/bin/linecount +++ b/bin/linecount @@ -15,9 +15,7 @@ # # A source file is anything under the src/engine/ or src/script/ # directories that ends in '.py' but does NOT begin with 'test_' -# or end in 'Tests.py'. (We should probably ignore the stuff in -# src/engine/SCons/Optik, since it doesn't originate with SCons, but -# what the hell.) +# or end in 'Tests.py'. # # We report the number of tests and sources, the total number of lines # in each category, the number of non-blank lines, and the number of diff --git a/bin/scons-proc.py b/bin/scons-proc.py index fc60a9bd..1de0caa9 100644 --- a/bin/scons-proc.py +++ b/bin/scons-proc.py @@ -6,7 +6,7 @@ # construction variables documented in the specified XML files. # # Dependening on the options, the lists are output in either -# DocBook-formatted generated SGML files containing the summary text +# DocBook-formatted generated XML files containing the summary text # and/or .mod files contining the ENTITY definitions for each item, # or in man-page-formatted output. # @@ -23,7 +23,7 @@ import SConsDoc base_sys_path = [os.getcwd() + '/build/test-tar-gz/lib/scons'] + sys.path helpstr = """\ -Usage: scons-proc.py [--man|--sgml] +Usage: scons-proc.py [--man|--xml] [-b file(s)] [-t file(s)] [-v file(s)] [infile ...] Options: -b file(s) dump builder information to the specified file(s) @@ -31,17 +31,17 @@ Options: -v file(s) dump variable information to the specified file(s) --man print info in man page format, each -[btv] argument is a single file name - --sgml (default) print info in SGML format, each -[btv] argument + --xml (default) print info in SML format, each -[btv] argument is a pair of comma-separated .gen,.mod file names """ opts, args = getopt.getopt(sys.argv[1:], "b:ht:v:", ['builders=', 'help', - 'man', 'sgml', 'tools=', 'variables=']) + 'man', 'xml', 'tools=', 'variables=']) buildersfiles = None -output_type = '--sgml' +output_type = '--xml' toolsfiles = None variablesfiles = None @@ -51,7 +51,7 @@ for o, a in opts: elif o in ['-h', '--help']: sys.stdout.write(helpstr) sys.exit(0) - elif o in ['--man', '--sgml']: + elif o in ['--man', '--xml']: output_type = o elif o in ['-t', '--tools']: toolsfiles = a @@ -132,7 +132,7 @@ class SCons_XML: return sys.stdout return open(name, 'w') -class SCons_XML_to_SGML(SCons_XML): +class SCons_XML_to_XML(SCons_XML): def write(self, files): gen, mod = string.split(files, ',') g.write_gen(gen) @@ -232,8 +232,8 @@ class SCons_XML_to_man(SCons_XML): if output_type == '--man': processor_class = SCons_XML_to_man -elif output_type == '--sgml': - processor_class = SCons_XML_to_SGML +elif output_type == '--xml': + processor_class = SCons_XML_to_XML else: sys.stderr.write("Unknown output type '%s'\n" % output_type) sys.exit(1) diff --git a/bin/sconsoutput.py b/bin/sconsoutput.py index a9c502b4..585d3c1b 100644 --- a/bin/sconsoutput.py +++ b/bin/sconsoutput.py @@ -376,6 +376,8 @@ if filter_tools: toollist = map(lambda t: apply(ToolSurrogate, t), toollist) +toollist.append('install') + def surrogate_spawn(sh, escape, cmd, args, env): pass @@ -788,6 +790,10 @@ data = f.read() if f is not sys.stdin: f.close() +if data.startswith('', re. format_re = re.compile(r'<(?:graphic|imagedata)\s+fileref="([^"]*)"(?:\s+format="([^"]*)")?') # -# Find internal dependencies in .sgml files: +# Find internal dependencies in .xml files: # -# +# # # # @@ -76,7 +74,7 @@ format_re = re.compile(r'<(?:graphic|imagedata)\s+fileref="([^"]*)"(?:\s+format= # defined as a SYSTEM entity is, in fact, a file included # somewhere in the document. # -def scansgml(node, env, target): +def scanxml(node, env, target): includes = [] contents = node.get_contents() @@ -101,7 +99,7 @@ def scansgml(node, env, target): return includes -s = Scanner(name = 'sgml', function = scansgml, skeys = ['.sgml', '.mod']) +s = Scanner(name = 'xml', function = scanxml, skeys = ['.xml', '.mod']) orig_env = env env = orig_env.Clone(SCANNERS = [s], @@ -127,14 +125,14 @@ scons_doc_files = map(lambda x: File('#src/engine/'+x).rstr(), scons_doc_files) if jw: # - # Always create a version.sgml file containing the version information + # Always create a version.xml file containing the version information # for this run. Ignore it for dependency purposes so we don't # rebuild all the docs every time just because the date changes. # date, ver, rev = env.Dictionary('DATE', 'VERSION', 'REVISION') - version_sgml = File(os.path.join(build, "version.sgml")) - #version_sgml = File("version.sgml") - verfile = str(version_sgml) + version_xml = File(os.path.join(build, "version.xml")) + #version_xml = File("version.xml") + verfile = str(version_xml) try: os.unlink(verfile) except OSError: @@ -170,7 +168,7 @@ THIS IS AN AUTOMATICALLY-GENERATED FILE. DO NOT EDIT. variables_gen, variables_mod] b = env.Command(doc_output_files, scons_doc_files, - "$PYTHON $SCONS_PROC_PY --sgml -b ${TARGETS[0]},${TARGETS[1]} -t ${TARGETS[2]},${TARGETS[3]} -v ${TARGETS[4]},${TARGETS[5]} $( $SOURCES $)") + "$PYTHON $SCONS_PROC_PY --xml -b ${TARGETS[0]},${TARGETS[1]} -t ${TARGETS[2]},${TARGETS[3]} -v ${TARGETS[4]},${TARGETS[5]} $( $SOURCES $)") env.Depends(b, "$SCONS_PROC_PY") env.Local(b) @@ -237,8 +235,8 @@ THIS IS AN AUTOMATICALLY-GENERATED FILE. DO NOT EDIT. } # - # We have to tell SCons to scan the top-level SGML files which - # get included by the document SGML files in the subdirectories. + # We have to tell SCons to scan the top-level XML files which + # get included by the document XML files in the subdirectories. # manifest = File('MANIFEST').rstr() src_files = map(lambda x: x[:-1], open(manifest).readlines()) @@ -266,20 +264,20 @@ THIS IS AN AUTOMATICALLY-GENERATED FILE. DO NOT EDIT. if ext in ['.fig', '.jpg']: orig_env.InstallAs(build_s, doc_s) else: - if build_doc and ext == '.sgml': + if build_doc and ext == '.xml': env.Command(doc_s, base + '.in', "$PYTHON $SCONSOUTPUT_PY $SOURCE > $TARGET") orig_env.SCons_revision(build_s, doc_s) Local(build_s) - main = os.path.join(build, doc, 'main.sgml') + main = os.path.join(build, doc, 'main.xml') out = 'main.out' # Hard-coding the scons-src path is a bit of a hack. This can # be reworked when a better solution presents itself. scons_src_main = os.path.join(build_dir, 'scons-src', 'doc', main) - env.Ignore(scons_src_main, version_sgml) + env.Ignore(scons_src_main, version_xml) htmldir = os.path.join(build, 'HTML', 'scons-%s' % doc) htmlindex = os.path.join(htmldir, docs[doc]['htmlindex']) @@ -289,12 +287,27 @@ THIS IS AN AUTOMATICALLY-GENERATED FILE. DO NOT EDIT. text = os.path.join(build, 'TEXT', 'scons-%s.txt' % doc) if docs[doc].get('html') and jade: + def copy_index_html(target, source, env): + # Older versions of DocBook|jw|jade|whatever would + # create a book1.html file, while newer versions create + # an index.html file (logically enough). The scons.org + # web site links expect book1.html, so we're going to + # leave the target as is, and run this post-processing + # action function to check that the target really did + # get created, and if it didn't, copy it from index.html. + t = str(target[0]) + if not os.path.exists(t): + i = os.path.join(os.path.split(t)[0], 'index.html') + open(t, 'w').write(open(i, 'r').read()) + return None + cmds = [ Delete("${TARGET.dir}/*.html"), "jw -b html -o ${TARGET.dir} $SOURCES", ] if tidy: cmds.append("tidy -m -q $TARGET || true") + cmds.append(Action(copy_index_html)) env.Command(htmlindex, File(main), cmds) Local(htmlindex) @@ -308,7 +321,7 @@ THIS IS AN AUTOMATICALLY-GENERATED FILE. DO NOT EDIT. env.Command(html, File(main), cmds) Local(html) - env.Ignore([html, htmlindex], version_sgml) + env.Ignore([html, htmlindex], version_xml) tar_deps.extend([html, htmlindex]) tar_list.extend([html, htmldir]) @@ -339,7 +352,7 @@ THIS IS AN AUTOMATICALLY-GENERATED FILE. DO NOT EDIT. ]) Local(ps) - env.Ignore(ps, version_sgml) + env.Ignore(ps, version_xml) tar_deps.append(ps) tar_list.append(ps) @@ -369,7 +382,7 @@ THIS IS AN AUTOMATICALLY-GENERATED FILE. DO NOT EDIT. ]) Local(pdf) - env.Ignore(pdf, version_sgml) + env.Ignore(pdf, version_xml) tar_deps.append(pdf) tar_list.append(pdf) @@ -378,7 +391,7 @@ THIS IS AN AUTOMATICALLY-GENERATED FILE. DO NOT EDIT. env.Command(text, html, "lynx -dump ${SOURCE.abspath} > $TARGET") Local(text) - env.Ignore(text, version_sgml) + env.Ignore(text, version_xml) tar_deps.append(text) tar_list.append(text) @@ -505,6 +518,9 @@ if epydoc: if tar_deps: tar_list = string.join(map(lambda x, b=build+'/': string.replace(x, b, ''), tar_list)) - env.Command(doc_tar_gz, tar_deps, + t = env.Command(dist_doc_tar_gz, tar_deps, "tar cf${TAR_HFLAG} - -C %s %s | gzip > $TARGET" % (build, tar_list)) - Local(doc_tar_gz) + Local(t) + Alias('doc', t) +else: + Alias('doc', os.path.join(build_dir, 'doc')) diff --git a/doc/design/MANIFEST b/doc/design/MANIFEST index 3fb99f08..33ab8f09 100644 --- a/doc/design/MANIFEST +++ b/doc/design/MANIFEST @@ -1,14 +1,14 @@ -acks.sgml -bground.sgml -copyright.sgml +acks.xml +bground.xml +copyright.xml engine.fig engine.jpg -engine.sgml -goals.sgml -install.sgml -intro.sgml -issues.sgml -main.sgml -native.sgml -overview.sgml +engine.xml +goals.xml +install.xml +intro.xml +issues.xml +main.xml +native.xml +overview.xml scons.mod diff --git a/doc/design/acks.sgml b/doc/design/acks.xml similarity index 100% rename from doc/design/acks.sgml rename to doc/design/acks.xml diff --git a/doc/design/bground.sgml b/doc/design/bground.xml similarity index 100% rename from doc/design/bground.sgml rename to doc/design/bground.xml diff --git a/doc/design/copyright.sgml b/doc/design/copyright.xml similarity index 100% rename from doc/design/copyright.sgml rename to doc/design/copyright.xml diff --git a/doc/design/engine.sgml b/doc/design/engine.xml similarity index 99% rename from doc/design/engine.sgml rename to doc/design/engine.xml index df78e3ba..1a1e3354 100644 --- a/doc/design/engine.sgml +++ b/doc/design/engine.xml @@ -523,7 +523,7 @@ - + @@ -671,9 +671,9 @@ Feedback? &Builder; objects raise the following exceptions on error: - + @@ -735,9 +735,9 @@ Feedback? - + @@ -918,7 +918,7 @@ Feedback?
&Builder; maps - + @@ -1264,13 +1264,13 @@ you set it up with another environment...
&Scanner; maps - + @@ -1543,7 +1543,7 @@ Comments?
Customizing output - + @@ -1732,16 +1732,16 @@ I dunno, maybe this is fine as it is...
Separate source and build trees - + - + @@ -1833,14 +1833,14 @@ and not call it through an environment...
Code repositories - + @@ -1900,10 +1900,10 @@ not to complicate their calling interface?
Derived-file caching - + @@ -1943,12 +1943,12 @@ auxiliary functions like cleaning the cache.
Job management - + diff --git a/doc/design/goals.sgml b/doc/design/goals.xml similarity index 99% rename from doc/design/goals.sgml rename to doc/design/goals.xml index 774e04d4..2a7b69b5 100644 --- a/doc/design/goals.sgml +++ b/doc/design/goals.xml @@ -192,17 +192,25 @@
Fixing &Make;'s problems - + + + + +
Fixing &Cons;'s problems - + + + + +
diff --git a/doc/design/install.sgml b/doc/design/install.xml similarity index 98% rename from doc/design/install.sgml rename to doc/design/install.xml index 918fd643..e670e83d 100644 --- a/doc/design/install.sgml +++ b/doc/design/install.xml @@ -23,6 +23,6 @@ --> - + diff --git a/doc/design/intro.sgml b/doc/design/intro.xml similarity index 99% rename from doc/design/intro.sgml rename to doc/design/intro.xml index 3ab8e3fc..561baa49 100644 --- a/doc/design/intro.sgml +++ b/doc/design/intro.xml @@ -93,7 +93,7 @@
- +
diff --git a/doc/design/issues.sgml b/doc/design/issues.xml similarity index 100% rename from doc/design/issues.sgml rename to doc/design/issues.xml diff --git a/doc/design/main.sgml b/doc/design/main.xml similarity index 85% rename from doc/design/main.sgml rename to doc/design/main.xml index 6246a73d..e991b366 100644 --- a/doc/design/main.sgml +++ b/doc/design/main.xml @@ -1,3 +1,5 @@ + + - + %version; --> @@ -46,16 +49,16 @@ %scons; - - - - - - - - - - + + + + + + + + + + ]> @@ -110,11 +113,15 @@ &native; + + Other Issues &issues; diff --git a/doc/design/native.sgml b/doc/design/native.xml similarity index 99% rename from doc/design/native.sgml rename to doc/design/native.xml index 5a791a7c..8cdd867d 100644 --- a/doc/design/native.sgml +++ b/doc/design/native.xml @@ -186,7 +186,7 @@ SConscript('src/SConscript', Export(env=env, debug=debug, installdir=installdir)) - + @@ -342,10 +342,10 @@ Equivalent to the above example: - + diff --git a/doc/design/overview.sgml b/doc/design/overview.xml similarity index 99% rename from doc/design/overview.sgml rename to doc/design/overview.xml index 8d6f060d..38e42585 100644 --- a/doc/design/overview.sgml +++ b/doc/design/overview.xml @@ -48,13 +48,13 @@
- + - + %version; %scons; - - - - - - - - + + + + + + + + ]> diff --git a/doc/developer/packaging.sgml b/doc/developer/packaging.xml similarity index 100% rename from doc/developer/packaging.sgml rename to doc/developer/packaging.xml diff --git a/doc/developer/preface.sgml b/doc/developer/preface.xml similarity index 100% rename from doc/developer/preface.sgml rename to doc/developer/preface.xml diff --git a/doc/developer/sourcetree.sgml b/doc/developer/sourcetree.xml similarity index 100% rename from doc/developer/sourcetree.sgml rename to doc/developer/sourcetree.xml diff --git a/doc/developer/testing.sgml b/doc/developer/testing.xml similarity index 100% rename from doc/developer/testing.sgml rename to doc/developer/testing.xml diff --git a/doc/man/scons.1 b/doc/man/scons.1 index 769cfc27..a20a0f63 100644 --- a/doc/man/scons.1 +++ b/doc/man/scons.1 @@ -2041,8 +2041,8 @@ This function adds a new command-line option to be recognized. The specified .I arguments are the same as supported by the standard Python -.B optparse.add_option -method; +.BR optparse.add_option () +method (with a few additional capabilities noted below); see the documentation for .B optparse for a thorough discussion of its option-processing capabities. @@ -2054,6 +2054,31 @@ contains a compatible version of the module that is used to provide identical functionality when run by earlier Python versions.) +In addition to the arguments and values supported by the +.B optparse.add_option () +method, +the SCons +.BR AddOption () +function allows you to set the +.B nargs +keyword value to +.B '?' +(a string with just the question mark) +to indicate that the specified long option(s) take(s) an +.I optional +argument. +When +.B "nargs = '?'" +is passed to the +.BR AddOption () +function, the +.B const +keyword argument +may be used to supply the "default" +value that should be used when the +option is specified on the command line +without an explicit argument. + If no .B default= keyword argument is supplied when calling @@ -2459,6 +2484,26 @@ The derived files in the cache will be shared among all the builds using the same .BR CacheDir () call. +Specifying a +.I cache_dir +of +.B None +disables derived file caching. + +Calling +.BR env.CacheDir () +will only affect targets built +through the specified construction environment. +Calling +.BR CacheDir () +sets a global default +that will be used by all targets built +through construction environments +that do +.I not +have an +.BR env.CacheDir () +specified. When a .BR CacheDir () @@ -3278,43 +3323,6 @@ Import(["env", "variable"]) Import("*") .EE -'\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -.TP -.RI Install( dir ", " source ) -.TP -.RI env.Install( dir ", " source ) -Installs one or more source files or directories -in a destination directory -.IR dir . -The names of the specified source files or directories -remain the same within the destination directory. - -.ES -env.Install(dir = '/usr/local/bin', source = ['foo', 'bar']) -.EE - -'\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -.TP -.RI InstallAs( target ", " source ) -.TP -.RI env.InstallAs( target ", " source ) -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 -.I target -and -.I source -arguments list different numbers of files or directories. - -.ES -env.InstallAs(target = '/usr/local/bin/foo', - source = 'foo_debug') -env.InstallAs(target = ['../lib/libfoo.a', '../lib/libbar.a'], - source = ['libFOO.a', 'libBAR.a']) -.EE - '\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" .TP .RI Literal( string ) @@ -4492,6 +4500,26 @@ files = Split(""" """) .EE +'\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +.TP +.RI Tag( node ", " tags ) +Annotates file or directory Nodes with +information about how the +.BR Package () +Builder should package those files or directories. +All tags are optional. + +.ES +# makes sure the built library will be installed with 0644 file +# access mode +Tag( Library( 'lib.c' ), UNIX_ATTR="0644" ) + +# marks file2.txt to be a documentation file +Tag( 'file2.txt', DOC ) +.EE + + + '\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" .TP .RI TargetSignatures( type ) @@ -7026,7 +7054,7 @@ class foo: self.arg = arg def __call__(self, target, source, env, for_signature): - return arg + " bar" + return self.arg + " bar" # Will expand $BAR to "my argument bar baz" env=Environment(FOO=foo, BAR="${FOO('my argument')} baz") diff --git a/doc/python10/MANIFEST b/doc/python10/MANIFEST index e962e6a7..c9484d8f 100644 --- a/doc/python10/MANIFEST +++ b/doc/python10/MANIFEST @@ -1,16 +1,16 @@ -abstract.sgml -acks.sgml +abstract.xml +acks.xml arch.fig builder.fig -copyright.sgml -design.sgml -future.sgml -install.sgml -intro.sgml +copyright.xml +design.xml +future.xml +install.xml +intro.xml job-task.fig -main.sgml +main.xml node.fig -process.sgml +process.xml scanner.fig scons.mod sig.fig diff --git a/doc/python10/abstract.sgml b/doc/python10/abstract.xml similarity index 100% rename from doc/python10/abstract.sgml rename to doc/python10/abstract.xml diff --git a/doc/python10/acks.sgml b/doc/python10/acks.xml similarity index 100% rename from doc/python10/acks.sgml rename to doc/python10/acks.xml diff --git a/doc/python10/copyright.sgml b/doc/python10/copyright.xml similarity index 100% rename from doc/python10/copyright.sgml rename to doc/python10/copyright.xml diff --git a/doc/python10/design.sgml b/doc/python10/design.xml similarity index 100% rename from doc/python10/design.sgml rename to doc/python10/design.xml diff --git a/doc/python10/future.sgml b/doc/python10/future.xml similarity index 100% rename from doc/python10/future.sgml rename to doc/python10/future.xml diff --git a/doc/python10/install.sgml b/doc/python10/install.xml similarity index 100% rename from doc/python10/install.sgml rename to doc/python10/install.xml diff --git a/doc/python10/intro.sgml b/doc/python10/intro.xml similarity index 100% rename from doc/python10/intro.sgml rename to doc/python10/intro.xml diff --git a/doc/python10/main.sgml b/doc/python10/main.xml similarity index 92% rename from doc/python10/main.sgml rename to doc/python10/main.xml index ff1e3178..42bc4af2 100644 --- a/doc/python10/main.sgml +++ b/doc/python10/main.xml @@ -1,3 +1,5 @@ + + - %scons; - - - - - - - - + + + + + + + + ]> diff --git a/doc/python10/process.sgml b/doc/python10/process.xml similarity index 100% rename from doc/python10/process.sgml rename to doc/python10/process.xml diff --git a/doc/reference/Alias.sgml b/doc/reference/Alias.xml similarity index 100% rename from doc/reference/Alias.sgml rename to doc/reference/Alias.xml diff --git a/doc/reference/CFile.sgml b/doc/reference/CFile.xml similarity index 100% rename from doc/reference/CFile.sgml rename to doc/reference/CFile.xml diff --git a/doc/reference/CXXFile.sgml b/doc/reference/CXXFile.xml similarity index 100% rename from doc/reference/CXXFile.sgml rename to doc/reference/CXXFile.xml diff --git a/doc/reference/Command.sgml b/doc/reference/Command.xml similarity index 100% rename from doc/reference/Command.sgml rename to doc/reference/Command.xml diff --git a/doc/reference/Install.sgml b/doc/reference/Install.xml similarity index 100% rename from doc/reference/Install.sgml rename to doc/reference/Install.xml diff --git a/doc/reference/InstallAs.sgml b/doc/reference/InstallAs.xml similarity index 100% rename from doc/reference/InstallAs.sgml rename to doc/reference/InstallAs.xml diff --git a/doc/reference/Library.sgml b/doc/reference/Library.xml similarity index 100% rename from doc/reference/Library.sgml rename to doc/reference/Library.xml diff --git a/doc/reference/MANIFEST b/doc/reference/MANIFEST index 1ea958ee..438aadad 100644 --- a/doc/reference/MANIFEST +++ b/doc/reference/MANIFEST @@ -1,21 +1,21 @@ -Alias.sgml -CFile.sgml -CXXFile.sgml -Command.sgml -Install.sgml -InstallAs.sgml -Library.sgml -Object.sgml -PCH.sgml -PDF.sgml -PostScript.sgml -Program.sgml -RES.sgml -SharedLibrary.sgml -SharedObject.sgml -StaticLibrary.sgml -StaticObject.sgml -copyright.sgml -errors.sgml -main.sgml -preface.sgml +Alias.xml +CFile.xml +CXXFile.xml +Command.xml +Install.xml +InstallAs.xml +Library.xml +Object.xml +PCH.xml +PDF.xml +PostScript.xml +Program.xml +RES.xml +SharedLibrary.xml +SharedObject.xml +StaticLibrary.xml +StaticObject.xml +copyright.xml +errors.xml +main.xml +preface.xml diff --git a/doc/reference/Object.sgml b/doc/reference/Object.xml similarity index 100% rename from doc/reference/Object.sgml rename to doc/reference/Object.xml diff --git a/doc/reference/PCH.sgml b/doc/reference/PCH.xml similarity index 100% rename from doc/reference/PCH.sgml rename to doc/reference/PCH.xml diff --git a/doc/reference/PDF.sgml b/doc/reference/PDF.xml similarity index 100% rename from doc/reference/PDF.sgml rename to doc/reference/PDF.xml diff --git a/doc/reference/PostScript.sgml b/doc/reference/PostScript.xml similarity index 100% rename from doc/reference/PostScript.sgml rename to doc/reference/PostScript.xml diff --git a/doc/reference/Program.sgml b/doc/reference/Program.xml similarity index 100% rename from doc/reference/Program.sgml rename to doc/reference/Program.xml diff --git a/doc/reference/RES.sgml b/doc/reference/RES.xml similarity index 100% rename from doc/reference/RES.sgml rename to doc/reference/RES.xml diff --git a/doc/reference/SharedLibrary.sgml b/doc/reference/SharedLibrary.xml similarity index 100% rename from doc/reference/SharedLibrary.sgml rename to doc/reference/SharedLibrary.xml diff --git a/doc/reference/SharedObject.sgml b/doc/reference/SharedObject.xml similarity index 100% rename from doc/reference/SharedObject.sgml rename to doc/reference/SharedObject.xml diff --git a/doc/reference/StaticLibrary.sgml b/doc/reference/StaticLibrary.xml similarity index 100% rename from doc/reference/StaticLibrary.sgml rename to doc/reference/StaticLibrary.xml diff --git a/doc/reference/StaticObject.sgml b/doc/reference/StaticObject.xml similarity index 100% rename from doc/reference/StaticObject.sgml rename to doc/reference/StaticObject.xml diff --git a/doc/reference/copyright.sgml b/doc/reference/copyright.xml similarity index 100% rename from doc/reference/copyright.sgml rename to doc/reference/copyright.xml diff --git a/doc/reference/errors.sgml b/doc/reference/errors.xml similarity index 100% rename from doc/reference/errors.sgml rename to doc/reference/errors.xml diff --git a/doc/reference/main.sgml b/doc/reference/main.xml similarity index 78% rename from doc/reference/main.sgml rename to doc/reference/main.xml index 87b4a848..ed122f6a 100644 --- a/doc/reference/main.sgml +++ b/doc/reference/main.xml @@ -1,3 +1,5 @@ + + - + %version; %scons; - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + - - - + + + ]> diff --git a/doc/reference/preface.sgml b/doc/reference/preface.xml similarity index 100% rename from doc/reference/preface.sgml rename to doc/reference/preface.xml diff --git a/doc/scons.mod b/doc/scons.mod index 652787a9..f3c1a86e 100644 --- a/doc/scons.mod +++ b/doc/scons.mod @@ -175,6 +175,7 @@ Export"> File"> FindFile"> +FindInstalledFiles"> Finish"> GenerateHelpText"> GetOption"> @@ -212,10 +213,12 @@ Salt"> SetBuildSignatureType"> SetContentSignatureType"> +SetOption"> SideEffect"> SourceSignature"> SourceSignatures"> Split"> +Tag"> TargetSignatures"> Task"> Touch"> diff --git a/doc/user/ENV.sgml b/doc/user/ENV.xml similarity index 100% rename from doc/user/ENV.sgml rename to doc/user/ENV.xml diff --git a/doc/user/MANIFEST b/doc/user/MANIFEST index cc7dc1ee..565298ff 100644 --- a/doc/user/MANIFEST +++ b/doc/user/MANIFEST @@ -1,46 +1,46 @@ -actions.sgml -alias.sgml -ant.sgml -builders.sgml -builders-built-in.sgml -builders-commands.sgml -builders-writing.sgml -build-install.sgml -caching.sgml -command-line.sgml +actions.xml +alias.xml +ant.xml +builders.xml +builders-built-in.xml +builders-commands.xml +builders-writing.xml +build-install.xml +caching.xml +command-line.xml cons.pl -copyright.sgml -depends.sgml -ENV.sgml -environments.sgml -errors.sgml -example.sgml -factories.sgml -file-removal.sgml -help.sgml -hierarchy.sgml -install.sgml -java.sgml -libraries.sgml -less-simple.sgml -main.sgml -make.sgml -nodes.sgml -parseconfig.sgml -preface.sgml -python.sgml -repositories.sgml -run.sgml -scanners.sgml -sconf.sgml -separate.sgml -simple.sgml -sourcecode.sgml -tasks.sgml -tools.sgml -troubleshoot.sgml -variants.sgml -variables.sgml +copyright.xml +depends.xml +ENV.xml +environments.xml +errors.xml +example.xml +factories.xml +file-removal.xml +help.xml +hierarchy.xml +install.xml +java.xml +libraries.xml +less-simple.xml +main.xml +make.xml +nodes.xml +parseconfig.xml +preface.xml +python.xml +repositories.xml +run.xml +scanners.xml +sconf.xml +separate.xml +simple.xml +sourcecode.xml +tasks.xml +tools.xml +troubleshoot.xml +variants.xml +variables.xml SCons-win32-install-1.jpg SCons-win32-install-2.jpg SCons-win32-install-3.jpg diff --git a/doc/user/actions.sgml b/doc/user/actions.xml similarity index 100% rename from doc/user/actions.sgml rename to doc/user/actions.xml diff --git a/doc/user/alias.sgml b/doc/user/alias.xml similarity index 100% rename from doc/user/alias.sgml rename to doc/user/alias.xml diff --git a/doc/user/ant.sgml b/doc/user/ant.xml similarity index 100% rename from doc/user/ant.sgml rename to doc/user/ant.xml diff --git a/doc/user/build-install.sgml b/doc/user/build-install.xml similarity index 100% rename from doc/user/build-install.sgml rename to doc/user/build-install.xml diff --git a/doc/user/builders-built-in.sgml b/doc/user/builders-built-in.xml similarity index 100% rename from doc/user/builders-built-in.sgml rename to doc/user/builders-built-in.xml diff --git a/doc/user/builders-commands.in b/doc/user/builders-commands.in index 13a5c565..7265a233 100644 --- a/doc/user/builders-commands.in +++ b/doc/user/builders-commands.in @@ -79,6 +79,15 @@ + + + When executed, + &SCons; runs the specified command, + substituting &cv-link-SOURCE; and &cv-link-TARGET; + as expected: + + + scons -Q @@ -94,7 +103,9 @@ - Note that the action you + Note that the action you specify to the + &Command; &Builder; can be any legal &SCons; &Action;, + such as a Python function: @@ -111,6 +122,12 @@ + + + Which executes as follows: + + + scons -Q diff --git a/doc/user/builders-commands.sgml b/doc/user/builders-commands.xml similarity index 90% rename from doc/user/builders-commands.sgml rename to doc/user/builders-commands.xml index d2b990a2..15a6015c 100644 --- a/doc/user/builders-commands.sgml +++ b/doc/user/builders-commands.xml @@ -74,6 +74,15 @@ env.Command('foo.out', 'foo.in', "sed 's/x/y/' < $SOURCE > $TARGET") + + + When executed, + &SCons; runs the specified command, + substituting &cv-link-SOURCE; and &cv-link-TARGET; + as expected: + + + % scons -Q sed 's/x/y/' < foo.in > foo.out @@ -90,7 +99,9 @@ - Note that the action you + Note that the action you specify to the + &Command; &Builder; can be any legal &SCons; &Action;, + such as a Python function: @@ -102,6 +113,12 @@ env.Command('foo.out', 'foo.in', build) + + + Which executes as follows: + + + % scons -Q build(["foo.out"], ["foo.in"]) diff --git a/doc/user/builders-writing.in b/doc/user/builders-writing.in index 62717aaf..7497277f 100644 --- a/doc/user/builders-writing.in +++ b/doc/user/builders-writing.in @@ -219,8 +219,31 @@ This functionality could be invoked as in the following example: + - + + import SCons.Defaults; SCons.Defaults.ConstructionEnvironment['TOOLS'] = {}; bld = Builder(action = 'foobuild < $SOURCE > $TARGET') + env = Environment(BUILDERS = {'Foo' : bld}) + env.Foo('file.foo', 'file.input') + env.Program('hello.c') + + bld = Builder(action = 'foobuild < $SOURCE > $TARGET') env = Environment(BUILDERS = {'Foo' : bld}) env.Foo('file.foo', 'file.input') diff --git a/doc/user/builders-writing.sgml b/doc/user/builders-writing.xml similarity index 94% rename from doc/user/builders-writing.sgml rename to doc/user/builders-writing.xml index 412d4310..50f6556e 100644 --- a/doc/user/builders-writing.sgml +++ b/doc/user/builders-writing.xml @@ -206,6 +206,23 @@ This functionality could be invoked as in the following example: + bld = Builder(action = 'foobuild < $SOURCE > $TARGET') env = Environment(BUILDERS = {'Foo' : bld}) @@ -215,8 +232,8 @@ This functionality could be invoked as in the following example: % scons -Q - AttributeError: 'SConsEnvironment' object has no attribute 'Program': - File "SConstruct", line 4: + AttributeError: SConsEnvironment instance has no attribute 'Program': + File "/home/my/project/SConstruct", line 4: env.Program('hello.c') diff --git a/doc/user/builders.in b/doc/user/builders.in index 2bc139d4..f3989ef3 100644 --- a/doc/user/builders.in +++ b/doc/user/builders.in @@ -24,7 +24,8 @@ --> - + %version; @@ -41,47 +43,47 @@ %variables-mod; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/doc/user/main.sgml b/doc/user/main.xml similarity index 77% rename from doc/user/main.sgml rename to doc/user/main.xml index d8643504..c3cf2c2e 100644 --- a/doc/user/main.sgml +++ b/doc/user/main.xml @@ -1,3 +1,4 @@ + - + %version; @@ -41,47 +43,47 @@ %variables-mod; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -117,6 +119,9 @@ XXX SetOption('duplicate') XXX - - duplicate= + XXX GetOption('help') + XXX SetOption('help') + XXX GetOption('num_jobs') XXX SetOption('num_jobs') diff --git a/doc/user/make.sgml b/doc/user/make.xml similarity index 100% rename from doc/user/make.sgml rename to doc/user/make.xml diff --git a/doc/user/nodes.sgml b/doc/user/nodes.xml similarity index 100% rename from doc/user/nodes.sgml rename to doc/user/nodes.xml diff --git a/doc/user/parseconfig.sgml b/doc/user/parseconfig.xml similarity index 100% rename from doc/user/parseconfig.sgml rename to doc/user/parseconfig.xml diff --git a/doc/user/preface.sgml b/doc/user/preface.xml similarity index 100% rename from doc/user/preface.sgml rename to doc/user/preface.xml diff --git a/doc/user/python.sgml b/doc/user/python.xml similarity index 100% rename from doc/user/python.sgml rename to doc/user/python.xml diff --git a/doc/user/repositories.sgml b/doc/user/repositories.xml similarity index 100% rename from doc/user/repositories.sgml rename to doc/user/repositories.xml diff --git a/doc/user/run.sgml b/doc/user/run.xml similarity index 100% rename from doc/user/run.sgml rename to doc/user/run.xml diff --git a/doc/user/scanners.sgml b/doc/user/scanners.xml similarity index 100% rename from doc/user/scanners.sgml rename to doc/user/scanners.xml diff --git a/doc/user/sconf.sgml b/doc/user/sconf.xml similarity index 100% rename from doc/user/sconf.sgml rename to doc/user/sconf.xml diff --git a/doc/user/separate.sgml b/doc/user/separate.xml similarity index 100% rename from doc/user/separate.sgml rename to doc/user/separate.xml diff --git a/doc/user/simple.in b/doc/user/simple.in index 57fdd3ad..b468f9a6 100644 --- a/doc/user/simple.in +++ b/doc/user/simple.in @@ -239,7 +239,7 @@ We'll cover Java builds in more detail, including building Java archive (.jar) and other types of file, - in . + in . @@ -389,7 +389,7 @@ (and any other files) whenever it's necessary. (We'll learn more about how &SCons; decides when building or rebuilding a file - is necessary in , below.) + is necessary in , below.) diff --git a/doc/user/simple.sgml b/doc/user/simple.xml similarity index 99% rename from doc/user/simple.sgml rename to doc/user/simple.xml index 9d3617d4..c5ef430c 100644 --- a/doc/user/simple.sgml +++ b/doc/user/simple.xml @@ -245,7 +245,7 @@ We'll cover Java builds in more detail, including building Java archive (.jar) and other types of file, - in . + in . @@ -412,7 +412,7 @@ (and any other files) whenever it's necessary. (We'll learn more about how &SCons; decides when building or rebuilding a file - is necessary in , below.) + is necessary in , below.) diff --git a/doc/user/sourcecode.sgml b/doc/user/sourcecode.xml similarity index 100% rename from doc/user/sourcecode.sgml rename to doc/user/sourcecode.xml diff --git a/doc/user/tasks.sgml b/doc/user/tasks.xml similarity index 100% rename from doc/user/tasks.sgml rename to doc/user/tasks.xml diff --git a/doc/user/tools.sgml b/doc/user/tools.xml similarity index 100% rename from doc/user/tools.sgml rename to doc/user/tools.xml diff --git a/doc/user/troubleshoot.sgml b/doc/user/troubleshoot.xml similarity index 92% rename from doc/user/troubleshoot.sgml rename to doc/user/troubleshoot.xml index 3df9c679..6ec61857 100644 --- a/doc/user/troubleshoot.sgml +++ b/doc/user/troubleshoot.xml @@ -261,7 +261,7 @@ % scons scons: Reading SConscript files ... - { 'BUILDERS': {}, + { 'BUILDERS': {'InstallAs': <function InstallAsBuilderWrapper at 0xb23a28>, 'Install': <function InstallBuilderWrapper at 0xb1b7d0>}, 'CONFIGUREDIR': '#/.sconf_temp', 'CONFIGURELOG': '#/config.log', 'CPPSUFFIXES': [ '.c', @@ -284,14 +284,13 @@ '.spp', '.SPP'], 'DSUFFIXES': ['.d'], - 'Dir': <SCons.Defaults.Variable_Method_Caller instance at 0xb7c3fdac>, - 'Dirs': <SCons.Defaults.Variable_Method_Caller instance at 0xb7c3fdcc>, + 'Dir': <SCons.Defaults.Variable_Method_Caller instance at 0xa1eb48>, + 'Dirs': <SCons.Defaults.Variable_Method_Caller instance at 0xa1eb90>, 'ENV': {'PATH': '/usr/local/bin:/opt/bin:/bin:/usr/bin'}, - 'ESCAPE': <function escape at 0xb7ba1f0c>, - 'File': <SCons.Defaults.Variable_Method_Caller instance at 0xb7c3fdec>, + 'ESCAPE': <function escape at 0xb1fa28>, + 'File': <SCons.Defaults.Variable_Method_Caller instance at 0xa1ebd8>, 'IDLSUFFIXES': ['.idl', '.IDL'], - 'INSTALL': <function installFunc at 0xb7c4317c>, - 'INSTALLSTR': <function installStr at 0xb7c431b4>, + 'INSTALL': <function copyFunc at 0xb23aa0>, 'LATEXSUFFIXES': ['.tex', '.ltx', '.latex'], 'LIBPREFIX': 'lib', 'LIBPREFIXES': '$LIBPREFIX', @@ -303,27 +302,26 @@ 'PLATFORM': 'posix', 'PROGPREFIX': '', 'PROGSUFFIX': '', - 'PSPAWN': <function piped_env_spawn at 0xb7bb12cc>, - 'RDirs': <SCons.Defaults.Variable_Method_Caller instance at 0xb7c3fe0c>, + 'PSPAWN': <function piped_env_spawn at 0xb23230>, + 'RDirs': <SCons.Defaults.Variable_Method_Caller instance at 0xa1ec20>, 'SCANNERS': [], 'SHELL': 'sh', 'SHLIBPREFIX': '$LIBPREFIX', 'SHLIBSUFFIX': '.so', 'SHOBJPREFIX': '$OBJPREFIX', 'SHOBJSUFFIX': '$OBJSUFFIX', - 'SPAWN': <function spawnvpe_spawn at 0xb7ba1d4c>, - 'TEMPFILE': <class SCons.Platform.TempFileMunge at 0xb7bce89c>, + 'SPAWN': <function spawnvpe_spawn at 0xb1f7d0>, + 'TEMPFILE': <class SCons.Platform.TempFileMunge at 0xa4e170>, 'TEMPFILEPREFIX': '@', - 'TOOLS': [], + 'TOOLS': ['install', 'install'], '_CPPDEFFLAGS': '${_defines(CPPDEFPREFIX, CPPDEFINES, CPPDEFSUFFIX, __env__)}', '_CPPINCFLAGS': '$( ${_concat(INCPREFIX, CPPPATH, INCSUFFIX, __env__, RDirs, TARGET, SOURCE)} $)', '_LIBDIRFLAGS': '$( ${_concat(LIBDIRPREFIX, LIBPATH, LIBDIRSUFFIX, __env__, RDirs, TARGET, SOURCE)} $)', '_LIBFLAGS': '${_concat(LIBLINKPREFIX, LIBS, LIBLINKSUFFIX, __env__)}', '__RPATH': '$_RPATH', - '_concat': <function _concat at 0xb7c43224>, - '_defines': <function _defines at 0xb7c432cc>, - '_installStr': <function installStr at 0xb7c431b4>, - '_stripixes': <function _stripixes at 0xb7c43294>} + '_concat': <function _concat at 0xa3d398>, + '_defines': <function _defines at 0xa3d500>, + '_stripixes': <function _stripixes at 0xa3d488>} scons: done reading SConscript files. scons: Building targets ... scons: `.' is up to date. @@ -340,9 +338,9 @@ C:\>scons scons: Reading SConscript files ... - { 'BUILDERS': {'Object': <SCons.Builder.CompositeBuilder instance at 0xb7b6354c>, 'SharedObject': <SCons.Builder.CompositeBuilder instance at 0xb7b636cc>, 'StaticObject': <SCons.Builder.CompositeBuilder instance at 0xb7b6354c>, 'PCH': <SCons.Builder.BuilderBase instance at 0xb7bd6e8c>, 'RES': <SCons.Builder.BuilderBase instance at 0xb7b5b9ec>}, + { 'BUILDERS': {'RES': <SCons.Builder.BuilderBase instance at 0xb39518>, 'Object': <SCons.Builder.CompositeBuilder instance at 0xb4a710>, 'InstallAs': <function InstallAsBuilderWrapper at 0xb45c08>, 'PCH': <SCons.Builder.BuilderBase instance at 0xb1cef0>, 'Install': <function InstallBuilderWrapper at 0xb1b7d0>, 'SharedObject': <SCons.Builder.CompositeBuilder instance at 0xb4aa28>, 'StaticObject': <SCons.Builder.CompositeBuilder instance at 0xb4a710>}, 'CC': 'cl', - 'CCCOM': <SCons.Action.FunctionAction instance at 0xb7b63b6c>, + 'CCCOM': <SCons.Action.FunctionAction instance at 0xb4c290>, 'CCCOMFLAGS': '$CPPFLAGS $_CPPDEFFLAGS $_CPPINCFLAGS /c $SOURCES /Fo$TARGET $CCPCHFLAGS $CCPDBFLAGS', 'CCFLAGS': ['/nologo'], 'CCPCHFLAGS': ['${(PCH and "/Yu%s /Fp%s"%(PCHSTOP or "",File(PCH))) or ""}'], @@ -377,20 +375,19 @@ 'CXXFILESUFFIX': '.cc', 'CXXFLAGS': ['$CCFLAGS', '$(', '/TP', '$)'], 'DSUFFIXES': ['.d'], - 'Dir': <SCons.Defaults.Variable_Method_Caller instance at 0xb7c5adac>, - 'Dirs': <SCons.Defaults.Variable_Method_Caller instance at 0xb7c5adcc>, + 'Dir': <SCons.Defaults.Variable_Method_Caller instance at 0xa1eb48>, + 'Dirs': <SCons.Defaults.Variable_Method_Caller instance at 0xa1eb90>, 'ENV': { 'INCLUDE': 'C:\\Program Files\\Microsoft Visual Studio/VC98\\include', 'LIB': 'C:\\Program Files\\Microsoft Visual Studio/VC98\\lib', 'PATH': 'C:\\Program Files\\Microsoft Visual Studio\\Common\\tools\\WIN95;C:\\Program Files\\Microsoft Visual Studio\\Common\\MSDev98\\bin;C:\\Program Files\\Microsoft Visual Studio\\Common\\tools;C:\\Program Files\\Microsoft Visual Studio/VC98\\bin', 'PATHEXT': '.COM;.EXE;.BAT;.CMD', 'SystemRoot': 'C:/WINDOWS'}, - 'ESCAPE': <function escape at 0xb7bcf454>, - 'File': <SCons.Defaults.Variable_Method_Caller instance at 0xb7c5adec>, + 'ESCAPE': <function escape at 0xb24848>, + 'File': <SCons.Defaults.Variable_Method_Caller instance at 0xa1ebd8>, 'IDLSUFFIXES': ['.idl', '.IDL'], 'INCPREFIX': '/I', 'INCSUFFIX': '', - 'INSTALL': <function installFunc at 0xb7c5e17c>, - 'INSTALLSTR': <function installStr at 0xb7c5e1b4>, + 'INSTALL': <function copyFunc at 0xb45c80>, 'LATEXSUFFIXES': ['.tex', '.ltx', '.latex'], 'LIBPREFIX': '', 'LIBPREFIXES': ['$LIBPREFIX'], @@ -406,14 +403,14 @@ 'PLATFORM': 'win32', 'PROGPREFIX': '', 'PROGSUFFIX': '.exe', - 'PSPAWN': <function piped_spawn at 0xb7bcf3ac>, + 'PSPAWN': <function piped_spawn at 0xb20488>, 'RC': 'rc', 'RCCOM': '$RC $_CPPDEFFLAGS $_CPPINCFLAGS $RCFLAGS /fo$TARGET $SOURCES', 'RCFLAGS': [], - 'RDirs': <SCons.Defaults.Variable_Method_Caller instance at 0xb7c5ae0c>, + 'RDirs': <SCons.Defaults.Variable_Method_Caller instance at 0xa1ec20>, 'SCANNERS': [], 'SHCC': '$CC', - 'SHCCCOM': <SCons.Action.FunctionAction instance at 0xb7b63bcc>, + 'SHCCCOM': <SCons.Action.FunctionAction instance at 0xb4c320>, 'SHCCFLAGS': ['$CCFLAGS'], 'SHCFLAGS': ['$CFLAGS'], 'SHCXX': '$CXX', @@ -424,19 +421,18 @@ 'SHLIBSUFFIX': '.dll', 'SHOBJPREFIX': '$OBJPREFIX', 'SHOBJSUFFIX': '$OBJSUFFIX', - 'SPAWN': <function spawn at 0xb7bcf41c>, + 'SPAWN': <function spawn at 0xb247d0>, 'STATIC_AND_SHARED_OBJECTS_ARE_THE_SAME': 1, - 'TEMPFILE': <class SCons.Platform.TempFileMunge at 0xb7be989c>, + 'TEMPFILE': <class SCons.Platform.TempFileMunge at 0xa4e170>, 'TEMPFILEPREFIX': '@', - 'TOOLS': ['msvc'], + 'TOOLS': ['msvc', 'install', 'install'], '_CPPDEFFLAGS': '${_defines(CPPDEFPREFIX, CPPDEFINES, CPPDEFSUFFIX, __env__)}', '_CPPINCFLAGS': '$( ${_concat(INCPREFIX, CPPPATH, INCSUFFIX, __env__, RDirs, TARGET, SOURCE)} $)', '_LIBDIRFLAGS': '$( ${_concat(LIBDIRPREFIX, LIBPATH, LIBDIRSUFFIX, __env__, RDirs, TARGET, SOURCE)} $)', '_LIBFLAGS': '${_concat(LIBLINKPREFIX, LIBS, LIBLINKSUFFIX, __env__)}', - '_concat': <function _concat at 0xb7c5e224>, - '_defines': <function _defines at 0xb7c5e2cc>, - '_installStr': <function installStr at 0xb7c5e1b4>, - '_stripixes': <function _stripixes at 0xb7c5e294>} + '_concat': <function _concat at 0xa3d398>, + '_defines': <function _defines at 0xa3d500>, + '_stripixes': <function _stripixes at 0xa3d488>} scons: done reading SConscript files. scons: Building targets ... scons: `.' is up to date. @@ -891,17 +887,17 @@ +-SConstruct +-f1.c +-f1.o - | +-[f1.c] + | +-f1.c | +-inc.h +-f2.c +-f2.o - | +-[f2.c] - | +-[inc.h] + | +-f2.c + | +-inc.h +-f3.c +-f3.o - | +-[f3.c] - | +-[inc.h] - +-[inc.h] + | +-f3.c + | +-inc.h + +-inc.h +-libfoo.a | +-[f1.o] | +-[f2.o] @@ -909,16 +905,16 @@ +-prog1 | +-prog1.o | | +-prog1.c - | | +-[inc.h] + | | +-inc.h | +-[libfoo.a] - +-[prog1.c] + +-prog1.c +-[prog1.o] +-prog2 | +-prog2.o | | +-prog2.c - | | +-[inc.h] + | | +-inc.h | +-[libfoo.a] - +-[prog2.c] + +-prog2.c +-[prog2.o] @@ -1112,14 +1108,10 @@ % scons -Q --debug=stacktrace scons: *** Source `prog.c' not found, needed by target `prog.o'. Stop. scons: internal stack trace: - File "/home/knight/SCons/scons.0.96.C763/bootstrap/src/engine/SCons/Job.py", line 111, in start - task.prepare() - File "/home/knight/SCons/scons.0.96.C763/bootstrap/src/engine/SCons/Taskmaster.py", line 166, in prepare - t.prepare() - File "/home/knight/SCons/scons.0.96.C763/bootstrap/src/engine/SCons/Node/FS.py", line 2137, in prepare - SCons.Node.Node.prepare(self) - File "/home/knight/SCons/scons.0.96.C763/bootstrap/src/engine/SCons/Node/__init__.py", line 806, in prepare - raise SCons.Errors.StopError, desc + File "bootstrap/src/engine/SCons/Job.py", line 114, in start + File "bootstrap/src/engine/SCons/Taskmaster.py", line 169, in prepare + File "bootstrap/src/engine/SCons/Node/FS.py", line 2220, in prepare + File "bootstrap/src/engine/SCons/Node/__init__.py", line 819, in prepare diff --git a/doc/user/variables.sgml b/doc/user/variables.xml similarity index 100% rename from doc/user/variables.sgml rename to doc/user/variables.xml diff --git a/doc/user/variants.sgml b/doc/user/variants.xml similarity index 100% rename from doc/user/variants.sgml rename to doc/user/variants.xml diff --git a/rpm/scons.spec.in b/rpm/scons.spec.in index 86cd7f55..f4564e4c 100644 --- a/rpm/scons.spec.in +++ b/rpm/scons.spec.in @@ -1,6 +1,7 @@ %define name scons -%define version 0.97 +%define version __VERSION__ %define release 1 +%define _unpackaged_files_terminate_build 0 Summary: an Open Source software construction tool Name: %{name} diff --git a/src/CHANGES.txt b/src/CHANGES.txt index f34b02fd..3699e95f 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -8,7 +8,27 @@ -RELEASE 0.97.X - XXX +RELEASE 0.XX - XXX + + From Steven Knight: + + - Fix the wix Tool module to handle null entries in $PATH variables. + + - Move the documentation of Install() and InstallAs() from the list + of functions to the list of Builders (now that they're implemented + as such). + + - Allow env.CacheDir() to be set per construction environment. The + global CacheDir() function now sets an overridable global default. + + + +RELEASE 0.97.0d20070809 - Fri, 10 Aug 2007 10:51:27 -0500 + + From Lars Albertsson: + + - Don't error if a #include line happens to match a directory + somewhere on a path (like $CPPPATH, $FORTRANPATH, etc.). From Mark Bertoglio: @@ -64,17 +84,63 @@ RELEASE 0.97.X - XXX - Add a $SWIGOUTDIR variable to allow setting the swig -outdir option, and use it to identify files created by the swig -java option. + - Add a $SWIGPATH variable that specifies the path to be searched + for included SWIG files, Also add related $SWIGINCPREFIX and + $SWIGINCSUFFIX variables that specify the prefix and suffix to + be be added to each $SWIGPATH directory when expanded on the SWIG + command line. + + - More efficient copying of construction environments (mostly borrowed + from copy.deepcopy() in the standard Python library). + + - When printing --tree=prune output, don't print [brackets] around + source files, only do so for built targets with children. + + - Fix interpretation of Builder source arguments when the Builder has + a src_suffix *and* a source_builder and the argument has no suffix. + + - Fix use of expansions like ${TARGET.dir} or ${SOURCE.dir} in the + following construction variables: $FORTRANMODDIR, $JARCHDIR, + $JARFLAGS, $LEXFLAGS, $SWIGFLAGS, $SWIGOUTDIR and $YACCFLAGS. + + - Fix dependencies on Java files generated by SWIG so they can be + detected and built in one pass. + + - Fix SWIG when used with a BuildDir(). + From Leanid Nazdrynau: - When applying Tool modules after a construction environment has already been created, don't overwrite existing $CFILESUFFIX and $CXXFILESUFFIX value. + - Support passing the Java() builder a list of explicit .java files + (not only a list of directories to be scanned for .java files). + + - Support passing .java files to the Jar() and JavaH() builders, which + then use the builder underlying the Java() builder to turn them into + .class files. (That is, the Jar()-Java() chain of builders become + multi-step, like the Program()-Object()-CFile() builders.) + + - Support passing SWIG .i files to the Java builders (Java(), + Jar(), JavaH()), to cause intermediate .java files to be created + automatically. + + - Add $JAVACLASSPATH and $JAVASOURCEPATH variables, that get added to + the javac "-classpath" and "-sourcepath" options. (Note that SCons + does *not* currently search these paths for implicit dependencies.) + + - Commonize initialization of Java-related builders. + From Jan Nijtmans: - Find Java anonymous classes when the next token after the name is an open parenthesis. + From Gary Oberbrunner: + + - Fix a code example in the man page. + From Tilo Prutz: - Add support for the file names that Java 1.5 (and 1.6) generates for diff --git a/src/RELEASE.txt b/src/RELEASE.txt index 6dd66aaf..195697e1 100644 --- a/src/RELEASE.txt +++ b/src/RELEASE.txt @@ -20,13 +20,75 @@ more effectively, please sign up for the scons-users mailing list at: -RELEASE 0.97 - Thu, 12 Apr 2007 12:36:25 -0500 +RELEASE 0.97.0d20070809 - Fri, 10 Aug 2007 10:51:27 -0500 This is the eighth beta release of SCons. Please consult the CHANGES.txt file for a list of specific changes since last release. Please note the following important changes since release 0.97: + -- env.CacheDir() NOW ONLY AFFECTS CONSTRUCTION ENVIRONMENT TARGETS + + The env.CacheDir() method now only causes derived files to be + retrieved from the specified cache directory for targets built + with the specified specified construction environment ("env"). + + Previously, any call to env.CacheDir() or CacheDir() would modify + a global setting and cause all built targets to be retrieved + from the specified cache directory. This behavior was changed so + that env.CacheDir() would be consistent with other construction + environment methods, which only affect targets built with the + specified construction environment. + + The old behavior of changing the global behavior may be preserved + by changing any env.CacheDir() calls to: + + CacheDir('/path/to/cache/directory') + + The above change is backwards-compatible and works in all earlier + versions of SCons that support CacheDir(). + + -- INTERPRETATION OF SUFFIX-LESS SOURCE ARGUMENTS HAS CHANGED + + The interpretation of source arguments (files) without suffixes + has changed in one specific configuration. + + Previously, if a Builder had a src_suffix specified (indicating + that source files without suffixes should have that suffix + appended), the suffix would only be applied to suffix-less source + arguments if the Builder did *not* have one or more attached + source Builders (that is, the Builder was not a "multi-stage" + Builder). So in the following configuration: + + build_foo = Builder(src_suffix = '.foo') + build_bar = Builder(src_suffix = '.bar', + src_builder = build_bar) + + env = Environment(BUILDERS = { + 'Foo' : build_foo, + 'Boo' : build_bar, + }) + + env.Foo('tgt1', 'src1') + env.Bar('tgt2', 'src2') + + SCons would have expected to find a source file 'src1.foo' for the + env.Foo() call, but a source file 'src2' for the env.Bar() call. + + This behavior has now been made consistent, so that the two + above calls would expect source files named 'src1.foo' and + 'src2.bar', respectively. + + Note that, if genuinely desired, the old behavior of building + from a source file without a suffix at all (when the Builder has + a src_suffix *and* a src_builder) can be specified explicity by + turning the string into a File Node directly: + + env.Bar('tgt2', File('src2')) + + The above use of File() is backwards-compatible and will work + on earlier versions of SCons. + -- THE DEFAULT EXECUTION PATH FOR Solaris HAS CHANGED On Solaris systems, SCons now adds the "/opt/SUNWspro/bin" diff --git a/src/engine/MANIFEST-xml.in b/src/engine/MANIFEST-xml.in index c43f2109..f852e92e 100644 --- a/src/engine/MANIFEST-xml.in +++ b/src/engine/MANIFEST-xml.in @@ -45,6 +45,7 @@ SCons/Tool/ilink32.xml SCons/Tool/ilink.xml SCons/Tool/__init__.xml SCons/Tool/intelc.xml +SCons/Tool/install.xml SCons/Tool/jar.xml SCons/Tool/javac.xml SCons/Tool/javah.xml @@ -63,6 +64,8 @@ SCons/Tool/msvs.xml SCons/Tool/mwcc.xml SCons/Tool/mwld.xml SCons/Tool/nasm.xml +SCons/Tool/packaging.xml +SCons/Tool/packaging/__init__.xml SCons/Tool/pdf.xml SCons/Tool/pdflatex.xml SCons/Tool/pdftex.xml diff --git a/src/engine/MANIFEST.in b/src/engine/MANIFEST.in index 4bcd1e09..9eccbdbc 100644 --- a/src/engine/MANIFEST.in +++ b/src/engine/MANIFEST.in @@ -9,6 +9,7 @@ SCons/compat/_scons_subprocess.py SCons/compat/_scons_textwrap.py SCons/compat/_scons_UserString.py SCons/compat/builtins.py +SCons/CacheDir.py SCons/Conftest.py SCons/cpp.py SCons/dblite.py @@ -51,10 +52,10 @@ SCons/Scanner/LaTeX.py SCons/Scanner/Prog.py SCons/SConf.py SCons/SConsign.py +SCons/Script/__init__.py SCons/Script/Main.py SCons/Script/SConscript.py SCons/Script/SConsOptions.py -SCons/Script/__init__.py SCons/Sig/__init__.py SCons/Sig/MD5.py SCons/Sig/TimeStamp.py @@ -75,14 +76,15 @@ SCons/Tool/c++.py SCons/Tool/cc.py SCons/Tool/cvf.py SCons/Tool/CVS.py -SCons/Tool/dmd.py SCons/Tool/default.py +SCons/Tool/dmd.py SCons/Tool/dvi.py SCons/Tool/dvipdf.py SCons/Tool/dvips.py SCons/Tool/f77.py SCons/Tool/f90.py SCons/Tool/f95.py +SCons/Tool/filesystem.py SCons/Tool/fortran.py SCons/Tool/g++.py SCons/Tool/g77.py @@ -93,17 +95,18 @@ SCons/Tool/gs.py SCons/Tool/hpc++.py SCons/Tool/hpcc.py SCons/Tool/hplink.py -SCons/Tool/jar.py -SCons/Tool/javac.py -SCons/Tool/JavaCommon.py -SCons/Tool/javah.py SCons/Tool/icc.py SCons/Tool/icl.py SCons/Tool/ifl.py SCons/Tool/ifort.py SCons/Tool/ilink.py SCons/Tool/ilink32.py +SCons/Tool/install.py SCons/Tool/intelc.py +SCons/Tool/jar.py +SCons/Tool/JavaCommon.py +SCons/Tool/javac.py +SCons/Tool/javah.py SCons/Tool/latex.py SCons/Tool/lex.py SCons/Tool/link.py @@ -119,6 +122,17 @@ SCons/Tool/msvs.py SCons/Tool/mwcc.py SCons/Tool/mwld.py SCons/Tool/nasm.py +SCons/Tool/packaging/__init__.py +SCons/Tool/packaging/ipk.py +SCons/Tool/packaging/msi.py +SCons/Tool/packaging/packager.py +SCons/Tool/packaging/rpm.py +SCons/Tool/packaging/src_tarbz2.py +SCons/Tool/packaging/src_targz.py +SCons/Tool/packaging/src_zip.py +SCons/Tool/packaging/tarbz2.py +SCons/Tool/packaging/targz.py +SCons/Tool/packaging/zip.py SCons/Tool/pdf.py SCons/Tool/pdflatex.py SCons/Tool/pdftex.py @@ -128,20 +142,22 @@ SCons/Tool/qt.py SCons/Tool/RCS.py SCons/Tool/rmic.py SCons/Tool/rpcgen.py +SCons/Tool/rpm.py SCons/Tool/SCCS.py SCons/Tool/sgiar.py SCons/Tool/sgic++.py SCons/Tool/sgicc.py SCons/Tool/sgilink.py +SCons/Tool/Subversion.py SCons/Tool/sunar.py SCons/Tool/sunc++.py SCons/Tool/suncc.py SCons/Tool/sunlink.py -SCons/Tool/Subversion.py SCons/Tool/swig.py SCons/Tool/tar.py SCons/Tool/tex.py SCons/Tool/tlib.py +SCons/Tool/wix.py SCons/Tool/yacc.py SCons/Tool/zip.py SCons/Util.py diff --git a/src/engine/SCons/ActionTests.py b/src/engine/SCons/ActionTests.py index 87fb4b08..01d09922 100644 --- a/src/engine/SCons/ActionTests.py +++ b/src/engine/SCons/ActionTests.py @@ -156,7 +156,7 @@ class Environment: return self.d def Clone(self, **kw): res = Environment() - res.d = SCons.Environment.our_deepcopy(self.d) + res.d = SCons.Util.semi_deepcopy(self.d) for k, v in kw.items(): res.d[k] = v return res diff --git a/src/engine/SCons/Builder.py b/src/engine/SCons/Builder.py index d21de467..ff31c5e6 100644 --- a/src/engine/SCons/Builder.py +++ b/src/engine/SCons/Builder.py @@ -467,28 +467,28 @@ class BuilderBase: executor.add_sources(slist) return executor + def _adjustixes(self, files, pre, suf): + if not files: + return [] + result = [] + if not SCons.Util.is_List(files): + files = [files] + + for f in files: + if SCons.Util.is_String(f): + f = SCons.Util.adjustixes(f, pre, suf) + result.append(f) + return result + def _create_nodes(self, env, target = None, source = None): """Create and return lists of target and source nodes. """ - def _adjustixes(files, pre, suf): - if not files: - return [] - result = [] - if not SCons.Util.is_List(files): - files = [files] - - for f in files: - if SCons.Util.is_String(f): - f = SCons.Util.adjustixes(f, pre, suf) - result.append(f) - return result - src_suf = self.get_src_suffix(env) target_factory = env.get_factory(self.target_factory) source_factory = env.get_factory(self.source_factory) - source = _adjustixes(source, None, src_suf) + source = self._adjustixes(source, None, src_suf) slist = env.arg2nodes(source, source_factory) pre = self.get_prefix(env, slist) @@ -505,7 +505,7 @@ class BuilderBase: splitext = lambda S,self=self,env=env: self.splitext(S,env) tlist = [ t_from_s(pre, suf, splitext) ] else: - target = _adjustixes(target, pre, suf) + target = self._adjustixes(target, pre, suf) tlist = env.arg2nodes(target, target_factory) if self.emitter: @@ -558,7 +558,7 @@ class BuilderBase: return result overwarn.warn() - + tlist, slist = self._create_nodes(env, target, source) # Check for errors with the specified target/source lists. @@ -716,20 +716,14 @@ class BuilderBase: return sdict def src_builder_sources(self, env, source, overwarn={}): - source_factory = env.get_factory(self.source_factory) - slist = env.arg2nodes(source, source_factory) - sdict = self._get_sdict(env) src_suffixes = self.src_suffixes(env) - lengths_dict = {} - for l in map(len, src_suffixes): - lengths_dict[l] = None - lengths = lengths_dict.keys() + lengths = list(set(map(len, src_suffixes))) - def match_src_suffix(node, src_suffixes=src_suffixes, lengths=lengths): - node_suffixes = map(lambda l, n=node: n.name[-l:], lengths) + def match_src_suffix(name, src_suffixes=src_suffixes, lengths=lengths): + node_suffixes = map(lambda l, n=name: n[-l:], lengths) for suf in src_suffixes: if suf in node_suffixes: return suf @@ -737,25 +731,38 @@ class BuilderBase: result = [] - for snode in slist: - match_suffix = match_src_suffix(snode) + if SCons.Util.is_List(source): + source = SCons.Util.flatten(source) + else: + source = [source] + for s in source: + if SCons.Util.is_String(s): + match_suffix = match_src_suffix(s) + if not match_suffix and not '.' in s: + src_suf = self.get_src_suffix(env) + s = self._adjustixes(s, None, src_suf)[0] + else: + match_suffix = match_src_suffix(s.name) if match_suffix: try: bld = sdict[match_suffix] except KeyError: - result.append(snode) + result.append(s) else: - tlist = bld._execute(env, None, [snode], overwarn) + tlist = bld._execute(env, None, [s], overwarn) # If the subsidiary Builder returned more than one # target, then filter out any sources that this # Builder isn't capable of building. if len(tlist) > 1: - tlist = filter(match_src_suffix, tlist) + mss = lambda t, m=match_src_suffix: m(t.name) + tlist = filter(mss, tlist) result.extend(tlist) else: - result.append(snode) + result.append(s) - return result + source_factory = env.get_factory(self.source_factory) + + return env.arg2nodes(result, source_factory) def _get_src_builders_key(self, env): return id(env) diff --git a/src/engine/SCons/BuilderTests.py b/src/engine/SCons/BuilderTests.py index 3996d5c6..bc4c52dd 100644 --- a/src/engine/SCons/BuilderTests.py +++ b/src/engine/SCons/BuilderTests.py @@ -43,6 +43,8 @@ import SCons.Action import SCons.Builder import SCons.Environment import SCons.Errors +import SCons.Subst +import SCons.Util sys.stdout = StringIO.StringIO() @@ -92,12 +94,11 @@ class Environment: return self.d.get(s, s) def subst_target_source(self, string, raw=0, target=None, source=None, dict=None, conv=None): - return SCons.Util.scons_subst(string, self, raw, target, - source, dict, conv) - def subst_list(self, string, raw=0, target=None, - source=None, dict=None, conv=None): - return SCons.Util.scons_subst_list(string, self, raw, target, - source, dict, conv) + return SCons.Subst.scons_subst(string, self, raw, target, + source, dict, conv) + def subst_list(self, string, raw=0, target=None, source=None, conv=None): + return SCons.Subst.scons_subst_list(string, self, raw, target, + source, {}, {}, conv) def arg2nodes(self, args, factory, **kw): global env_arg2nodes_called env_arg2nodes_called = 1 @@ -792,12 +793,12 @@ class BuilderTestCase(unittest.TestCase): tgt = builder2(env, source=[]) assert tgt == [], tgt - tgt = builder2(env, target='baz', - source=['test.bar', 'test2.foo', 'test3.txt'])[0] + sources = ['test.bar', 'test2.foo', 'test3.txt', 'test4'] + tgt = builder2(env, target='baz', source=sources)[0] s = str(tgt) assert s == 'baz', s s = map(str, tgt.sources) - assert s == ['test.foo', 'test2.foo', 'test3.txt'], s + assert s == ['test.foo', 'test2.foo', 'test3.txt', 'test4.foo'], s s = map(str, tgt.sources[0].sources) assert s == ['test.bar'], s @@ -899,7 +900,8 @@ class BuilderTestCase(unittest.TestCase): assert tgt.builder.source_scanner is None, tgt.builder.source_scanner assert tgt.get_source_scanner(bar_y) is None, tgt.get_source_scanner(bar_y) assert not src.has_builder(), src.has_builder() - assert src.get_source_scanner(bar_y) is None, src.get_source_scanner(bar_y) + s = src.get_source_scanner(bar_y) + assert isinstance(s, SCons.Util.Null), repr(s) # An Environment that has suffix-specified SCANNERS should # provide a source scanner to the target. @@ -926,7 +928,8 @@ class BuilderTestCase(unittest.TestCase): assert tgt.get_source_scanner(bar_y), tgt.get_source_scanner(bar_y) assert str(tgt.get_source_scanner(bar_y)) == 'EnvTestScanner', tgt.get_source_scanner(bar_y) assert not src.has_builder(), src.has_builder() - assert src.get_source_scanner(bar_y) is None, src.get_source_scanner(bar_y) + s = src.get_source_scanner(bar_y) + assert isinstance(s, SCons.Util.Null), repr(s) # Can't simply specify the scanner as a builder argument; it's # global to all invocations of this builder. @@ -937,7 +940,8 @@ class BuilderTestCase(unittest.TestCase): assert tgt.get_source_scanner(bar_y), tgt.get_source_scanner(bar_y) assert str(tgt.get_source_scanner(bar_y)) == 'EnvTestScanner', tgt.get_source_scanner(bar_y) assert not src.has_builder(), src.has_builder() - assert src.get_source_scanner(bar_y) is None, src.get_source_scanner(bar_y) + s = src.get_source_scanner(bar_y) + assert isinstance(s, SCons.Util.Null), s # Now use a builder that actually has scanners and ensure that # the target is set accordingly (using the specified scanner @@ -955,7 +959,8 @@ class BuilderTestCase(unittest.TestCase): assert tgt.get_source_scanner(bar_y) == scanner, tgt.get_source_scanner(bar_y) assert str(tgt.get_source_scanner(bar_y)) == 'TestScanner', tgt.get_source_scanner(bar_y) assert not src.has_builder(), src.has_builder() - assert src.get_source_scanner(bar_y) is None, src.get_source_scanner(bar_y) + s = src.get_source_scanner(bar_y) + assert isinstance(s, SCons.Util.Null), s @@ -1595,7 +1600,7 @@ class CompositeBuilderTestCase(unittest.TestCase): assert str(e) == expect, e flag = 0 - tgt = builder(env, target='t7', source=['test7'])[0] + tgt = builder(env, target='t7', source=[env.fs.File('test7')])[0] try: tgt.build() except SCons.Errors.UserError, e: diff --git a/src/engine/SCons/CacheDir.py b/src/engine/SCons/CacheDir.py new file mode 100644 index 00000000..6a1cc04f --- /dev/null +++ b/src/engine/SCons/CacheDir.py @@ -0,0 +1,207 @@ +# +# __COPYRIGHT__ +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +__doc__ = """ +CacheDir support +""" + +import os.path +import stat +import string +import sys + +import SCons.Action + +cache_debug = False +cache_force = False +cache_show = False + +def CacheRetrieveFunc(target, source, env): + t = target[0] + fs = t.fs + cd = env.get_CacheDir() + cachedir, cachefile = cd.cachepath(t) + if not fs.exists(cachefile): + cd.CacheDebug('CacheRetrieve(%s): %s not in cache\n', t, cachefile) + return 1 + cd.CacheDebug('CacheRetrieve(%s): retrieving from %s\n', t, cachefile) + if SCons.Action.execute_actions: + if fs.islink(cachefile): + fs.symlink(fs.readlink(cachefile), t.path) + else: + fs.copy2(cachefile, t.path) + st = fs.stat(cachefile) + fs.chmod(t.path, stat.S_IMODE(st[stat.ST_MODE]) | stat.S_IWRITE) + return 0 + +def CacheRetrieveString(target, source, env): + t = target[0] + fs = t.fs + cd = env.get_CacheDir() + cachedir, cachefile = cd.cachepath(t) + if t.fs.exists(cachefile): + return "Retrieved `%s' from cache" % t.path + return None + +CacheRetrieve = SCons.Action.Action(CacheRetrieveFunc, CacheRetrieveString) + +CacheRetrieveSilent = SCons.Action.Action(CacheRetrieveFunc, None) + +def CachePushFunc(target, source, env): + t = target[0] + if t.nocache: + return + fs = t.fs + cd = env.get_CacheDir() + cachedir, cachefile = cd.cachepath(t) + if fs.exists(cachefile): + # Don't bother copying it if it's already there. Note that + # usually this "shouldn't happen" because if the file already + # existed in cache, we'd have retrieved the file from there, + # not built it. This can happen, though, in a race, if some + # other person running the same build pushes their copy to + # the cache after we decide we need to build it but before our + # build completes. + cd.CacheDebug('CachePush(%s): %s already exists in cache\n', t, cachefile) + return + + cd.CacheDebug('CachePush(%s): pushing to %s\n', t, cachefile) + + if not fs.isdir(cachedir): + fs.makedirs(cachedir) + + tempfile = cachefile+'.tmp' + try: + if fs.islink(t.path): + fs.symlink(fs.readlink(t.path), tempfile) + else: + fs.copy2(t.path, tempfile) + fs.rename(tempfile, cachefile) + st = fs.stat(t.path) + fs.chmod(cachefile, stat.S_IMODE(st[stat.ST_MODE]) | stat.S_IWRITE) + except (IOError, OSError): + # It's possible someone else tried writing the file at the + # same time we did, or else that there was some problem like + # the CacheDir being on a separate file system that's full. + # In any case, inability to push a file to cache doesn't affect + # the correctness of the build, so just print a warning. + SCons.Warnings.warn(SCons.Warnings.CacheWriteErrorWarning, + "Unable to copy %s to cache. Cache file is %s" + % (str(target), cachefile)) + +CachePush = SCons.Action.Action(CachePushFunc, None) + +class CacheDir: + + def __init__(self, path): + try: + import SCons.Sig.MD5 + except ImportError: + msg = "No MD5 module available, CacheDir() not supported" + SCons.Warnings.warn(SCons.Warnings.NoMD5ModuleWarning, msg) + else: + self.path = path + + def CacheDebugWrite(self, fmt, target, cachefile): + self.debugFP.write(fmt % (target, os.path.split(cachefile)[1])) + + def CacheDebugQuiet(self, fmt, target, cachefile): + pass + + def CacheDebugInit(self, fmt, target, cachefile): + if cache_debug: + if cache_debug == '-': + self.debugFP = sys.stdout + else: + self.debugFP = open(cache_debug, 'w') + self.CacheDebug = self.CacheDebugWrite + self.CacheDebug(fmt, target, cachefile) + else: + self.CacheDebug = self.CacheDebugQuiet + + CacheDebug = CacheDebugInit + + def cachepath(self, node): + """ + """ + sig = node.get_cachedir_bsig() + subdir = string.upper(sig[0]) + dir = os.path.join(self.path, subdir) + return dir, os.path.join(dir, sig) + + def retrieve(self, node): + """ + This method is called from multiple threads in a parallel build, + so only do thread safe stuff here. Do thread unsafe stuff in + built(). + + Note that there's a special trick here with the execute flag + (one that's not normally done for other actions). Basically + if the user requested a no_exec (-n) build, then + SCons.Action.execute_actions is set to 0 and when any action + is called, it does its showing but then just returns zero + instead of actually calling the action execution operation. + The problem for caching is that if the file does NOT exist in + cache then the CacheRetrieveString won't return anything to + show for the task, but the Action.__call__ won't call + CacheRetrieveFunc; instead it just returns zero, which makes + the code below think that the file *was* successfully + retrieved from the cache, therefore it doesn't do any + subsequent building. However, the CacheRetrieveString didn't + print anything because it didn't actually exist in the cache, + and no more build actions will be performed, so the user just + sees nothing. The fix is to tell Action.__call__ to always + execute the CacheRetrieveFunc and then have the latter + explicitly check SCons.Action.execute_actions itself. + """ + retrieved = False + + if cache_show: + if CacheRetrieveSilent(node, [], node.get_build_env(), execute=1) == 0: + node.build(presub=0, execute=0) + retrieved = 1 + else: + if CacheRetrieve(node, [], node.get_build_env(), execute=1) == 0: + retrieved = 1 + if retrieved: + # Record build signature information, but don't + # push it out to cache. (We just got it from there!) + node.set_state(SCons.Node.executed) + SCons.Node.Node.built(node) + + return retrieved + + def push(self, node): + return CachePush(node, [], node.get_build_env()) + + def push_if_forced(self, node): + if cache_force: + return self.push(node) + +class Null(SCons.Util.Null): + def repr(self): + return 'CacheDir.Null()' + def retrieve(self, node): + return False diff --git a/src/engine/SCons/CacheDirTests.py b/src/engine/SCons/CacheDirTests.py new file mode 100644 index 00000000..564b7622 --- /dev/null +++ b/src/engine/SCons/CacheDirTests.py @@ -0,0 +1,295 @@ +# +# __COPYRIGHT__ +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +import os.path +import shutil +import sys +import unittest + +from TestCmd import TestCmd + +import SCons.CacheDir + +built_it = None + +class Action: + def __call__(self, targets, sources, env, errfunc, **kw): + global built_it + if kw.get('execute', 1): + built_it = 1 + return 0 + +class Builder: + def __init__(self, environment, action): + self.env = environment + self.action = action + self.overrides = {} + +class Environment: + def __init__(self, cachedir): + self.cachedir = cachedir + def Override(self, overrides): + return self + def get_CacheDir(self): + return self.cachedir + +class BaseTestCase(unittest.TestCase): + """ + Base fixtures common to our other unittest classes. + """ + def setUp(self): + self.test = TestCmd(workdir='') + + import SCons.Node.FS + self.fs = SCons.Node.FS.FS() + + self._CacheDir = SCons.CacheDir.CacheDir('cache') + + def File(self, name, bsig=None, action=Action()): + node = self.fs.File(name) + node.builder_set(Builder(Environment(self._CacheDir), action)) + if bsig: + node.binfo = node.BuildInfo(node) + node.binfo.ninfo.bsig = bsig + return node + +class CacheDirTestCase(BaseTestCase): + """ + Test calling CacheDir code directly. + """ + def test_cachepath(self): + """Test the cachepath() method""" + + # Verify how the cachepath() method determines the name + # of the file in cache. + def my_collect(list): + return list[0] + save_collect = SCons.Sig.MD5.collect + SCons.Sig.MD5.collect = my_collect + + try: + f5 = self.File("cd.f5", 'a_fake_bsig') + result = self._CacheDir.cachepath(f5) + dirname = os.path.join('cache', 'A') + filename = os.path.join(dirname, 'a_fake_bsig') + assert result == (dirname, filename), result + finally: + SCons.Sig.MD5.collect = save_collect + +class FileTestCase(BaseTestCase): + """ + Test calling CacheDir code through Node.FS.File interfaces. + """ + # These tests were originally in Nodes/FSTests.py and got moved + # when the CacheDir support was refactored into its own module. + # Look in the history for Node/FSTests.py if any of this needs + # to be re-examined. + def retrieve_succeed(self, target, source, env, execute=1): + self.retrieved.append(target) + return 0 + + def retrieve_fail(self, target, source, env, execute=1): + self.retrieved.append(target) + return 1 + + def push(self, target, source, env): + self.pushed.append(target) + return 0 + + def test_CacheRetrieve(self): + """Test the CacheRetrieve() function""" + + save_CacheRetrieve = SCons.CacheDir.CacheRetrieve + self.retrieved = [] + + f1 = self.File("cd.f1") + try: + SCons.CacheDir.CacheRetrieve = self.retrieve_succeed + self.retrieved = [] + built_it = None + + r = f1.retrieve_from_cache() + assert r == 1, r + assert self.retrieved == [f1], self.retrieved + assert built_it is None, built_it + + SCons.CacheDir.CacheRetrieve = self.retrieve_fail + self.retrieved = [] + built_it = None + + r = f1.retrieve_from_cache() + assert not r, r + assert self.retrieved == [f1], self.retrieved + assert built_it is None, built_it + finally: + SCons.CacheDir.CacheRetrieve = save_CacheRetrieve + + def test_CacheRetrieveSilent(self): + """Test the CacheRetrieveSilent() function""" + + save_CacheRetrieveSilent = SCons.CacheDir.CacheRetrieveSilent + + SCons.CacheDir.cache_show = 1 + + f2 = self.File("cd.f2", 'f2_bsig') + try: + SCons.CacheDir.CacheRetrieveSilent = self.retrieve_succeed + self.retrieved = [] + built_it = None + + r = f2.retrieve_from_cache() + assert r == 1, r + assert self.retrieved == [f2], self.retrieved + assert built_it is None, built_it + + SCons.CacheDir.CacheRetrieveSilent = self.retrieve_fail + self.retrieved = [] + built_it = None + + r = f2.retrieve_from_cache() + assert r is False, r + assert self.retrieved == [f2], self.retrieved + assert built_it is None, built_it + finally: + SCons.CacheDir.CacheRetrieveSilent = save_CacheRetrieveSilent + + def test_CachePush(self): + """Test the CachePush() function""" + + save_CachePush = SCons.CacheDir.CachePush + + SCons.CacheDir.CachePush = self.push + + try: + self.pushed = [] + + cd_f3 = self.test.workpath("cd.f3") + f3 = self.File(cd_f3) + f3.built() + assert self.pushed == [], self.pushed + self.test.write(cd_f3, "cd.f3\n") + f3.built() + assert self.pushed == [f3], self.pushed + + self.pushed = [] + + cd_f4 = self.test.workpath("cd.f4") + f4 = self.File(cd_f4) + f4.visited() + assert self.pushed == [], self.pushed + self.test.write(cd_f4, "cd.f4\n") + f4.clear() + f4.visited() + assert self.pushed == [], self.pushed + SCons.CacheDir.cache_force = 1 + f4.clear() + f4.visited() + assert self.pushed == [f4], self.pushed + finally: + SCons.CacheDir.CachePush = save_CachePush + + def test_no_bsig(self): + """Test that no bsig raises an InternalError""" + + f6 = self.File("cd.f6") + f6.binfo = f6.BuildInfo(f6) + exc_caught = 0 + try: + cp = self._CacheDir.cachepath(f6) + except SCons.Errors.InternalError: + exc_caught = 1 + assert exc_caught + + def test_warning(self): + """Test raising a warning if we can't copy a file to cache.""" + + test = TestCmd(workdir='') + + save_copy2 = shutil.copy2 + def copy2(src, dst): + raise OSError + shutil.copy2 = copy2 + save_mkdir = os.mkdir + def mkdir(dir, mode=0): + pass + os.mkdir = mkdir + old_warn_exceptions = SCons.Warnings.warningAsException(1) + SCons.Warnings.enableWarningClass(SCons.Warnings.CacheWriteErrorWarning) + + try: + cd_f7 = self.test.workpath("cd.f7") + self.test.write(cd_f7, "cd.f7\n") + f7 = self.File(cd_f7, 'f7_bsig') + + warn_caught = 0 + try: + f7.built() + except SCons.Warnings.CacheWriteErrorWarning: + warn_caught = 1 + assert warn_caught + finally: + shutil.copy2 = save_copy2 + os.mkdir = save_mkdir + SCons.Warnings.warningAsException(old_warn_exceptions) + SCons.Warnings.suppressWarningClass(SCons.Warnings.CacheWriteErrorWarning) + + def test_no_strfunction(self): + """Test handling no strfunction() for an action.""" + + save_CacheRetrieveSilent = SCons.CacheDir.CacheRetrieveSilent + + f8 = self.File("cd.f8", 'f8_bsig') + try: + SCons.CacheDir.CacheRetrieveSilent = self.retrieve_succeed + self.retrieved = [] + built_it = None + + r = f8.retrieve_from_cache() + assert r == 1, r + assert self.retrieved == [f8], self.retrieved + assert built_it is None, built_it + + SCons.CacheDir.CacheRetrieveSilent = self.retrieve_fail + self.retrieved = [] + built_it = None + + r = f8.retrieve_from_cache() + assert r is False, r + assert self.retrieved == [f8], self.retrieved + assert built_it is None, built_it + finally: + SCons.CacheDir.CacheRetrieveSilent = save_CacheRetrieveSilent + +if __name__ == "__main__": + suite = unittest.TestSuite() + tclasses = [ + CacheDirTestCase, + FileTestCase, + ] + for tclass in tclasses: + names = unittest.getTestCaseNames(tclass, 'test_') + suite.addTests(map(tclass, names)) + if not unittest.TextTestRunner().run(suite).wasSuccessful(): + sys.exit(1) diff --git a/src/engine/SCons/Defaults.py b/src/engine/SCons/Defaults.py index 9d0ad825..29868ecc 100644 --- a/src/engine/SCons/Defaults.py +++ b/src/engine/SCons/Defaults.py @@ -46,6 +46,7 @@ import sys import SCons.Action import SCons.Builder +import SCons.CacheDir import SCons.Environment import SCons.PathList import SCons.Sig @@ -66,6 +67,7 @@ def DefaultEnvironment(*args, **kw): _default_env = apply(SCons.Environment.Environment, args, kw) _default_env._build_signature = 1 _default_env._calc_module = SCons.Sig.default_module + _default_env._CacheDir = SCons.CacheDir.Null() return _default_env # Emitters for setting the shared attribute on object files, diff --git a/src/engine/SCons/Environment.py b/src/engine/SCons/Environment.py index 8a7721e3..012c36c3 100644 --- a/src/engine/SCons/Environment.py +++ b/src/engine/SCons/Environment.py @@ -67,6 +67,8 @@ _null = _Null CleanTargets = {} CalculatorArgs = {} +semi_deepcopy = SCons.Util.semi_deepcopy + # Pull UserError into the global name space for the benefit of # Environment().SourceSignatures(), which has some import statements # which seem to mess up its ability to reference SCons directly. @@ -82,23 +84,6 @@ AliasBuilder = SCons.Builder.Builder(action = alias_builder, is_explicit = None, name='AliasBuilder') -def our_deepcopy(x): - """deepcopy lists and dictionaries, and just copy the reference - for everything else.""" - if SCons.Util.is_Dict(x): - copy = {} - for key in x.keys(): - copy[key] = our_deepcopy(x[key]) - elif SCons.Util.is_List(x): - copy = map(our_deepcopy, x) - try: - copy = x.__class__(copy) - except AttributeError: - pass - else: - copy = x - return copy - def apply_tools(env, tools, toolpath): # Store the toolpath in the Environment. if toolpath is not None: @@ -122,7 +107,7 @@ reserved_construction_var_names = \ ['TARGET', 'TARGETS', 'SOURCE', 'SOURCES'] def copy_non_reserved_keywords(dict): - result = our_deepcopy(dict) + result = semi_deepcopy(dict) for k in result.keys(): if k in reserved_construction_var_names: SCons.Warnings.warn(SCons.Warnings.ReservedVariableWarning, @@ -191,6 +176,9 @@ class BuilderDict(UserDict): self.env = env UserDict.__init__(self, dict) + def __semi_deepcopy__(self): + return self.__class__(self.data, self.env) + def __setitem__(self, item, val): UserDict.__setitem__(self, item, val) try: @@ -255,7 +243,7 @@ class SubstitutionEnvironment: """Initialization of an underlying SubstitutionEnvironment class. """ if __debug__: logInstanceCreation(self, 'Environment.SubstitutionEnvironment') - self.fs = SCons.Node.FS.default_fs or SCons.Node.FS.FS() + self.fs = SCons.Node.FS.get_default_fs() self.ans = SCons.Node.Alias.default_ans self.lookup_list = SCons.Node.arg2nodes_lookups self._dict = kw.copy() @@ -754,10 +742,10 @@ class Base(SubstitutionEnvironment): """ if __debug__: logInstanceCreation(self, 'Environment.Base') self._memo = {} - self.fs = SCons.Node.FS.default_fs or SCons.Node.FS.FS() + self.fs = SCons.Node.FS.get_default_fs() self.ans = SCons.Node.Alias.default_ans self.lookup_list = SCons.Node.arg2nodes_lookups - self._dict = our_deepcopy(SCons.Defaults.ConstructionEnvironment) + self._dict = semi_deepcopy(SCons.Defaults.ConstructionEnvironment) self._init_special() self._dict['BUILDERS'] = BuilderDict(self._dict['BUILDERS'], self) @@ -825,6 +813,14 @@ class Base(SubstitutionEnvironment): c = SCons.Defaults.DefaultEnvironment().get_calculator() return c + def get_CacheDir(self): + try: + return self._CacheDir + except AttributeError: + cd = SCons.Defaults.DefaultEnvironment()._CacheDir + self._CacheDir = cd + return cd + def get_factory(self, factory, default='File'): """Return a factory function for creating Nodes for this construction environment. @@ -980,7 +976,11 @@ class Base(SubstitutionEnvironment): try: update_dict(val) except (AttributeError, TypeError, ValueError): - orig[val] = None + if SCons.Util.is_Dict(val): + for k, v in val.items(): + orig[k] = v + else: + orig[val] = None self.scanner_map_delete(kw) def AppendENVPath(self, name, newpath, envname = 'ENV', sep = os.pathsep): @@ -1039,7 +1039,7 @@ class Base(SubstitutionEnvironment): objects in the original Environment. """ clone = copy.copy(self) - clone._dict = our_deepcopy(self._dict) + clone._dict = semi_deepcopy(self._dict) try: cbd = clone._dict['BUILDERS'] clone._dict['BUILDERS'] = BuilderDict(cbd, clone) @@ -1235,7 +1235,11 @@ class Base(SubstitutionEnvironment): try: update_dict(val) except (AttributeError, TypeError, ValueError): - orig[val] = None + if SCons.Util.is_Dict(val): + for k, v in val.items(): + orig[k] = v + else: + orig[val] = None self.scanner_map_delete(kw) def PrependENVPath(self, name, newpath, envname = 'ENV', sep = os.pathsep): @@ -1290,13 +1294,13 @@ class Base(SubstitutionEnvironment): with new construction variables and/or values. """ try: - kwbd = our_deepcopy(kw['BUILDERS']) + kwbd = semi_deepcopy(kw['BUILDERS']) del kw['BUILDERS'] self.__setitem__('BUILDERS', kwbd) except KeyError: pass kw = copy_non_reserved_keywords(kw) - self._update(our_deepcopy(kw)) + self._update(semi_deepcopy(kw)) self.scanner_map_delete(kw) def ReplaceIxes(self, path, old_prefix, old_suffix, new_prefix, new_suffix): @@ -1470,7 +1474,11 @@ class Base(SubstitutionEnvironment): return apply(SCons.Builder.Builder, [], nkw) def CacheDir(self, path): - self.fs.CacheDir(self.subst(path)) + import SCons.CacheDir + if path is None: + self._CacheDir = SCons.CacheDir.Null() + else: + self._CacheDir = SCons.CacheDir.CacheDir(self.subst(path)) def Clean(self, targets, files): global CleanTargets @@ -1830,7 +1838,7 @@ class OverrideEnvironment(Base): # Overridden public construction environment methods. def Replace(self, **kw): kw = copy_non_reserved_keywords(kw) - self.__dict__['overrides'].update(our_deepcopy(kw)) + self.__dict__['overrides'].update(semi_deepcopy(kw)) # The entry point that will be used by the external world # to refer to a construction environment. This allows the wrapper diff --git a/src/engine/SCons/EnvironmentTests.py b/src/engine/SCons/EnvironmentTests.py index 20c1eac8..82f220ab 100644 --- a/src/engine/SCons/EnvironmentTests.py +++ b/src/engine/SCons/EnvironmentTests.py @@ -2507,18 +2507,13 @@ def generate(env): def test_CacheDir(self): """Test the CacheDir() method""" - class MyFS: - def CacheDir(self, path): - self.CD = path - env = self.TestEnvironment(CD = 'CacheDir') - env.fs = MyFS() env.CacheDir('foo') - assert env.fs.CD == 'foo', env.fs.CD + assert env._CacheDir.path == 'foo', env._CacheDir.path env.CacheDir('$CD') - assert env.fs.CD == 'CacheDir', env.fs.CD + assert env._CacheDir.path == 'CacheDir', env._CacheDir.path def test_Clean(self): """Test the Clean() method""" diff --git a/src/engine/SCons/Executor.py b/src/engine/SCons/Executor.py index 12114bc9..7d8df68b 100644 --- a/src/engine/SCons/Executor.py +++ b/src/engine/SCons/Executor.py @@ -296,10 +296,8 @@ class Null(_Executor): kw['action'] = [] apply(_Executor.__init__, (self,), kw) def get_build_env(self): - class NullEnvironment: - def get_scanner(self, key): - return None - return NullEnvironment() + import SCons.Util + return SCons.Util.Null() def get_build_scanner_path(self): return None def cleanup(self): diff --git a/src/engine/SCons/Node/FS.py b/src/engine/SCons/Node/FS.py index ad21a4db..74dc655e 100644 --- a/src/engine/SCons/Node/FS.py +++ b/src/engine/SCons/Node/FS.py @@ -223,77 +223,6 @@ def get_MkdirBuilder(): name = "MkdirBuilder") return MkdirBuilder -def CacheRetrieveFunc(target, source, env): - t = target[0] - fs = t.fs - cachedir, cachefile = t.cachepath() - if not fs.exists(cachefile): - fs.CacheDebug('CacheRetrieve(%s): %s not in cache\n', t, cachefile) - return 1 - fs.CacheDebug('CacheRetrieve(%s): retrieving from %s\n', t, cachefile) - if SCons.Action.execute_actions: - if fs.islink(cachefile): - fs.symlink(fs.readlink(cachefile), t.path) - else: - fs.copy2(cachefile, t.path) - st = fs.stat(cachefile) - fs.chmod(t.path, stat.S_IMODE(st[stat.ST_MODE]) | stat.S_IWRITE) - return 0 - -def CacheRetrieveString(target, source, env): - t = target[0] - cachedir, cachefile = t.cachepath() - if t.fs.exists(cachefile): - return "Retrieved `%s' from cache" % t.path - return None - -CacheRetrieve = SCons.Action.Action(CacheRetrieveFunc, CacheRetrieveString) - -CacheRetrieveSilent = SCons.Action.Action(CacheRetrieveFunc, None) - -def CachePushFunc(target, source, env): - t = target[0] - if t.nocache: - return - fs = t.fs - cachedir, cachefile = t.cachepath() - if fs.exists(cachefile): - # Don't bother copying it if it's already there. Note that - # usually this "shouldn't happen" because if the file already - # existed in cache, we'd have retrieved the file from there, - # not built it. This can happen, though, in a race, if some - # other person running the same build pushes their copy to - # the cache after we decide we need to build it but before our - # build completes. - fs.CacheDebug('CachePush(%s): %s already exists in cache\n', t, cachefile) - return - - fs.CacheDebug('CachePush(%s): pushing to %s\n', t, cachefile) - - if not fs.isdir(cachedir): - fs.makedirs(cachedir) - - tempfile = cachefile+'.tmp' - try: - if fs.islink(t.path): - fs.symlink(fs.readlink(t.path), tempfile) - else: - fs.copy2(t.path, tempfile) - fs.rename(tempfile, cachefile) - st = fs.stat(t.path) - fs.chmod(cachefile, stat.S_IMODE(st[stat.ST_MODE]) | stat.S_IWRITE) - except (IOError, OSError): - # It's possible someone else tried writing the file at the - # same time we did, or else that there was some problem like - # the CacheDir being on a separate file system that's full. - # In any case, inability to push a file to cache doesn't affect - # the correctness of the build, so just print a warning. - SCons.Warnings.warn(SCons.Warnings.CacheWriteErrorWarning, - "Unable to copy %s to cache. Cache file is %s" - % (str(target), cachefile)) - -CachePush = SCons.Action.Action(CachePushFunc, None) - class _Null: pass @@ -738,6 +667,15 @@ class Base(SCons.Node.Node): return ret def target_from_source(self, prefix, suffix, splitext=SCons.Util.splitext): + """ + + Generates a target entry that corresponds to this entry (usually + a source file) with the specified prefix and suffix. + + Note that this method can be overridden dynamically for generated + files that need different behavior. See Tool/swig.py for + an example. + """ return self.dir.Entry(prefix + splitext(self.name)[0] + suffix) def _Rfindalldirs_key(self, pathlist): @@ -783,6 +721,26 @@ class Base(SCons.Node.Node): cwd = self.cwd or self.fs._cwd return cwd.Rfindalldirs(pathlist) + memoizer_counters.append(SCons.Memoize.CountValue('rentry')) + + def rentry(self): + try: + return self._memo['rentry'] + except KeyError: + pass + result = self + if not self.exists(): + norm_name = _my_normcase(self.name) + for dir in self.dir.get_all_rdirs(): + try: + node = dir.entries[norm_name] + except KeyError: + if dir.entry_exists_on_disk(self.name): + result = dir.Entry(self.name) + break + self._memo['rentry'] = result + return result + class Entry(Base): """This is the class for generic Node.FS entries--that is, things that could be a File or a Dir, but we're just not sure yet. @@ -993,9 +951,6 @@ class FS(LocalFS): self.Root = {} self.SConstruct_dir = None - self.CachePath = None - self.cache_force = None - self.cache_show = None self.max_drift = default_max_drift self.Top = None @@ -1259,30 +1214,6 @@ class FS(LocalFS): d = self.Dir(d) self.Top.addRepository(d) - def CacheDebugWrite(self, fmt, target, cachefile): - self.CacheDebugFP.write(fmt % (target, os.path.split(cachefile)[1])) - - def CacheDebugQuiet(self, fmt, target, cachefile): - pass - - CacheDebug = CacheDebugQuiet - - def CacheDebugEnable(self, file): - if file == '-': - self.CacheDebugFP = sys.stdout - else: - self.CacheDebugFP = open(file, 'w') - self.CacheDebug = self.CacheDebugWrite - - def CacheDir(self, path): - try: - import SCons.Sig.MD5 - except ImportError: - msg = "No MD5 module available, CacheDir() not supported" - SCons.Warnings.warn(SCons.Warnings.NoMD5ModuleWarning, msg) - else: - self.CachePath = path - def build_dir_target_climb(self, orig, dir, tail): """Create targets in corresponding build directories @@ -1681,9 +1612,9 @@ class Dir(Base): def srcdir_duplicate(self, name): for dir in self.srcdir_list(): if dir.entry_exists_on_disk(name): - srcnode = dir.File(name) + srcnode = dir.Entry(name).disambiguate() if self.duplicate: - node = self.File(name) + node = self.Entry(name).disambiguate() node.do_duplicate(srcnode) return node else: @@ -1750,7 +1681,37 @@ class Dir(Base): diskcheck_sccs(self, name): try: return self.File(name) except TypeError: pass - return self.srcdir_duplicate(name) + node = self.srcdir_duplicate(name) + if isinstance(node, Dir): + node = None + return node + + def walk(self, func, arg): + """ + Walk this directory tree by calling the specified function + for each directory in the tree. + + This behaves like the os.path.walk() function, but for in-memory + Node.FS.Dir objects. The function takes the same arguments as + the functions passed to os.path.walk(): + + func(arg, dirname, fnames) + + Except that "dirname" will actually be the directory *Node*, + not the string. The '.' and '..' entries are excluded from + fnames. The fnames list may be modified in-place to filter the + subdirectories visited or otherwise impose a specific order. + The "arg" argument is always passed to func() and may be used + in any way (or ignored, passing None is common). + """ + entries = self.entries + names = entries.keys() + names.remove('.') + names.remove('..') + func(arg, self, names) + select_dirs = lambda n, e=entries: isinstance(e[n], Dir) + for dirname in filter(select_dirs, names): + entries[dirname].walk(func, arg) class RootDir(Dir): """A class for the root directory of a file system. @@ -2048,53 +2009,17 @@ class File(Base): so only do thread safe stuff here. Do thread unsafe stuff in built(). - Note that there's a special trick here with the execute flag - (one that's not normally done for other actions). Basically - if the user requested a no_exec (-n) build, then - SCons.Action.execute_actions is set to 0 and when any action - is called, it does its showing but then just returns zero - instead of actually calling the action execution operation. - The problem for caching is that if the file does NOT exist in - cache then the CacheRetrieveString won't return anything to - show for the task, but the Action.__call__ won't call - CacheRetrieveFunc; instead it just returns zero, which makes - the code below think that the file *was* successfully - retrieved from the cache, therefore it doesn't do any - subsequent building. However, the CacheRetrieveString didn't - print anything because it didn't actually exist in the cache, - and no more build actions will be performed, so the user just - sees nothing. The fix is to tell Action.__call__ to always - execute the CacheRetrieveFunc and then have the latter - explicitly check SCons.Action.execute_actions itself. - Returns true iff the node was successfully retrieved. """ if self.nocache: return None - b = self.is_derived() - if not b and not self.has_src_builder(): + if not self.is_derived(): return None - - retrieved = None - if b and self.fs.CachePath: - if self.fs.cache_show: - if CacheRetrieveSilent(self, [], None, execute=1) == 0: - self.build(presub=0, execute=0) - retrieved = 1 - else: - if CacheRetrieve(self, [], None, execute=1) == 0: - retrieved = 1 - if retrieved: - # Record build signature information, but don't - # push it out to cache. (We just got it from there!) - self.set_state(SCons.Node.executed) - SCons.Node.Node.built(self) - - return retrieved - + return self.get_build_env().get_CacheDir().retrieve(self) def built(self): - """Called just after this node is successfully built. + """ + Called just after this node is successfully built. """ # Push this file out to cache before the superclass Node.built() # method has a chance to clear the build signature, which it @@ -2104,13 +2029,13 @@ class File(Base): # cache so that the memoization of the self.exists() return # value doesn't interfere. self.clear_memoized_values() - if self.fs.CachePath and self.exists(): - CachePush(self, [], None) + if self.exists(): + self.get_build_env().get_CacheDir().push(self) SCons.Node.Node.built(self) def visited(self): - if self.fs.CachePath and self.fs.cache_force and self.exists(): - CachePush(self, None, None) + if self.exists(): + self.get_build_env().get_CacheDir().push_if_forced(self) def has_src_builder(self): """Return whether this Node has a source builder or not. @@ -2333,9 +2258,8 @@ class File(Base): def rstr(self): return str(self.rfile()) - def cachepath(self): - if self.nocache or not self.fs.CachePath: - return None, None + def get_cachedir_bsig(self): + import SCons.Sig.MD5 ninfo = self.get_binfo().ninfo if not hasattr(ninfo, 'bsig'): import SCons.Errors @@ -2346,14 +2270,16 @@ class File(Base): # Add the path to the cache signature, because multiple # targets built by the same action will all have the same # build signature, and we have to differentiate them somehow. - import SCons.Sig.MD5 - cache_sig = SCons.Sig.MD5.collect([ninfo.bsig, self.path]) - subdir = string.upper(cache_sig[0]) - dir = os.path.join(self.fs.CachePath, subdir) - return dir, os.path.join(dir, cache_sig) + return SCons.Sig.MD5.collect([ninfo.bsig, self.path]) default_fs = None +def get_default_fs(): + global default_fs + if not default_fs: + default_fs = FS() + return default_fs + class FileFinder: """ """ diff --git a/src/engine/SCons/Node/FSTests.py b/src/engine/SCons/Node/FSTests.py index 0b60fb96..ed8d6ec7 100644 --- a/src/engine/SCons/Node/FSTests.py +++ b/src/engine/SCons/Node/FSTests.py @@ -89,6 +89,7 @@ class Action: pass def strfunction(self, targets, sources, env): return "" + class Builder: def __init__(self, factory, action=Action()): self.factory = factory @@ -2041,6 +2042,74 @@ class RepositoryTestCase(_tempdirTestCase): r = map(lambda x, np=os.path.normpath: np(str(x)), rep) assert r == expect, r + def test_rentry(self): + """Test the Base.entry() method""" + return_true = lambda: 1 + return_false = lambda: 0 + + d1 = self.fs.Dir('d1') + d2 = self.fs.Dir('d2') + d3 = self.fs.Dir('d3') + + e1 = self.fs.Entry('e1') + e2 = self.fs.Entry('e2') + e3 = self.fs.Entry('e3') + + f1 = self.fs.File('f1') + f2 = self.fs.File('f2') + f3 = self.fs.File('f3') + + self.test.write([self.rep1, 'd2'], "") + self.test.subdir([self.rep2, 'd3']) + self.test.write([self.rep3, 'd3'], "") + + self.test.write([self.rep1, 'e2'], "") + self.test.subdir([self.rep2, 'e3']) + self.test.write([self.rep3, 'e3'], "") + + self.test.write([self.rep1, 'f2'], "") + self.test.subdir([self.rep2, 'f3']) + self.test.write([self.rep3, 'f3'], "") + + r = d1.rentry() + assert r is d1, r + + r = d2.rentry() + assert not r is d2, r + r = str(r) + assert r == os.path.join(self.rep1, 'd2'), r + + r = d3.rentry() + assert not r is d3, r + r = str(r) + assert r == os.path.join(self.rep2, 'd3'), r + + r = e1.rentry() + assert r is e1, r + + r = e2.rentry() + assert not r is e2, r + r = str(r) + assert r == os.path.join(self.rep1, 'e2'), r + + r = e3.rentry() + assert not r is e3, r + r = str(r) + assert r == os.path.join(self.rep2, 'e3'), r + + r = f1.rentry() + assert r is f1, r + + r = f2.rentry() + assert not r is f2, r + r = str(r) + assert r == os.path.join(self.rep1, 'f2'), r + + r = f3.rentry() + assert not r is f3, r + r = str(r) + assert r == os.path.join(self.rep2, 'f3'), r + def test_rdir(self): """Test the Dir.rdir() method""" return_true = lambda: 1 @@ -2468,200 +2537,6 @@ class SConstruct_dirTestCase(unittest.TestCase): fs.set_SConstruct_dir(fs.Dir('xxx')) assert fs.SConstruct_dir.path == 'xxx' -class CacheDirTestCase(unittest.TestCase): - def runTest(self): - """Test CacheDir functionality""" - test = TestCmd(workdir='') - - global built_it - - fs = SCons.Node.FS.FS() - assert fs.CachePath is None, fs.CachePath - assert fs.cache_force is None, fs.cache_force - assert fs.cache_show is None, fs.cache_show - - fs.CacheDir('cache') - assert fs.CachePath == 'cache', fs.CachePath - - save_CacheRetrieve = SCons.Node.FS.CacheRetrieve - self.retrieved = [] - def retrieve_succeed(target, source, env, self=self, execute=1): - self.retrieved.append(target) - return 0 - def retrieve_fail(target, source, env, self=self, execute=1): - self.retrieved.append(target) - return 1 - - f1 = fs.File("cd.f1") - f1.builder_set(Builder(fs.File)) - f1.env_set(Environment()) - try: - SCons.Node.FS.CacheRetrieve = retrieve_succeed - self.retrieved = [] - built_it = None - - r = f1.retrieve_from_cache() - assert r == 1, r - assert self.retrieved == [f1], self.retrieved - assert built_it is None, built_it - - SCons.Node.FS.CacheRetrieve = retrieve_fail - self.retrieved = [] - built_it = None - - r = f1.retrieve_from_cache() - assert r is None, r - assert self.retrieved == [f1], self.retrieved - assert built_it is None, built_it - finally: - SCons.Node.FS.CacheRetrieve = save_CacheRetrieve - - save_CacheRetrieveSilent = SCons.Node.FS.CacheRetrieveSilent - - fs.cache_show = 1 - - f2 = fs.File("cd.f2") - f2.builder_set(Builder(fs.File)) - f2.env_set(Environment()) - try: - SCons.Node.FS.CacheRetrieveSilent = retrieve_succeed - self.retrieved = [] - built_it = None - - r = f2.retrieve_from_cache() - assert r == 1, r - assert self.retrieved == [f2], self.retrieved - assert built_it is None, built_it - - SCons.Node.FS.CacheRetrieveSilent = retrieve_fail - self.retrieved = [] - built_it = None - - r = f2.retrieve_from_cache() - assert r is None, r - assert self.retrieved == [f2], self.retrieved - assert built_it is None, built_it - finally: - SCons.Node.FS.CacheRetrieveSilent = save_CacheRetrieveSilent - - save_CachePush = SCons.Node.FS.CachePush - def push(target, source, env, self=self): - self.pushed.append(target) - return 0 - SCons.Node.FS.CachePush = push - - try: - self.pushed = [] - - cd_f3 = test.workpath("cd.f3") - f3 = fs.File(cd_f3) - f3.built() - assert self.pushed == [], self.pushed - test.write(cd_f3, "cd.f3\n") - f3.built() - assert self.pushed == [f3], self.pushed - - self.pushed = [] - - cd_f4 = test.workpath("cd.f4") - f4 = fs.File(cd_f4) - f4.visited() - assert self.pushed == [], self.pushed - test.write(cd_f4, "cd.f4\n") - f4.visited() - assert self.pushed == [], self.pushed - fs.cache_force = 1 - f4.visited() - assert self.pushed == [f4], self.pushed - finally: - SCons.Node.FS.CachePush = save_CachePush - - # Verify how the cachepath() method determines the name - # of the file in cache. - def my_collect(list): - return list[0] - save_collect = SCons.Sig.MD5.collect - SCons.Sig.MD5.collect = my_collect - try: - f5 = fs.File("cd.f5") - f5.binfo = f5.BuildInfo(f5) - f5.binfo.ninfo.bsig = 'a_fake_bsig' - cp = f5.cachepath() - dirname = os.path.join('cache', 'A') - filename = os.path.join(dirname, 'a_fake_bsig') - assert cp == (dirname, filename), cp - finally: - SCons.Sig.MD5.collect = save_collect - - # Verify that no bsig raises an InternalERror - f6 = fs.File("cd.f6") - f6.binfo = f6.BuildInfo(f6) - exc_caught = 0 - try: - cp = f6.cachepath() - except SCons.Errors.InternalError: - exc_caught = 1 - assert exc_caught - - # Verify that we raise a warning if we can't copy a file to cache. - save_copy2 = shutil.copy2 - def copy2(src, dst): - raise OSError - shutil.copy2 = copy2 - save_mkdir = os.mkdir - def mkdir(dir, mode=0): - pass - os.mkdir = mkdir - old_warn_exceptions = SCons.Warnings.warningAsException(1) - SCons.Warnings.enableWarningClass(SCons.Warnings.CacheWriteErrorWarning) - - try: - cd_f7 = test.workpath("cd.f7") - test.write(cd_f7, "cd.f7\n") - f7 = fs.File(cd_f7) - f7.binfo = f7.BuildInfo(f7) - f7.binfo.ninfo.bsig = 'f7_bsig' - - warn_caught = 0 - try: - f7.built() - except SCons.Warnings.CacheWriteErrorWarning: - warn_caught = 1 - assert warn_caught - finally: - shutil.copy2 = save_copy2 - os.mkdir = save_mkdir - SCons.Warnings.warningAsException(old_warn_exceptions) - SCons.Warnings.suppressWarningClass(SCons.Warnings.CacheWriteErrorWarning) - - # Verify that we don't blow up if there's no strfunction() - # for an action. - act = Action() - act.strfunction = None - f8 = fs.File("cd.f8") - f8.builder_set(Builder(fs.File, action=act)) - f8.env_set(Environment()) - try: - SCons.Node.FS.CacheRetrieveSilent = retrieve_succeed - self.retrieved = [] - built_it = None - - r = f8.retrieve_from_cache() - assert r == 1, r - assert self.retrieved == [f8], self.retrieved - assert built_it is None, built_it - - SCons.Node.FS.CacheRetrieveSilent = retrieve_fail - self.retrieved = [] - built_it = None - - r = f8.retrieve_from_cache() - assert r is None, r - assert self.retrieved == [f8], self.retrieved - assert built_it is None, built_it - finally: - SCons.Node.FS.CacheRetrieveSilent = save_CacheRetrieveSilent - class clearTestCase(unittest.TestCase): def runTest(self): """Test clearing FS nodes of cached data.""" @@ -3007,7 +2882,6 @@ if __name__ == "__main__": suite.addTest(has_src_builderTestCase()) suite.addTest(prepareTestCase()) suite.addTest(SConstruct_dirTestCase()) - suite.addTest(CacheDirTestCase()) suite.addTest(clearTestCase()) suite.addTest(disambiguateTestCase()) suite.addTest(postprocessTestCase()) diff --git a/src/engine/SCons/Node/NodeTests.py b/src/engine/SCons/Node/NodeTests.py index ad9eb660..09ab5c78 100644 --- a/src/engine/SCons/Node/NodeTests.py +++ b/src/engine/SCons/Node/NodeTests.py @@ -33,6 +33,7 @@ import UserList import SCons.Errors import SCons.Node +import SCons.Util @@ -977,7 +978,7 @@ class NodeTestCase(unittest.TestCase): target = SCons.Node.Node() source = SCons.Node.Node() s = target.get_source_scanner(source) - assert s is None, s + assert isinstance(s, SCons.Util.Null), s ts1 = Scanner() ts2 = Scanner() diff --git a/src/engine/SCons/PathList.py b/src/engine/SCons/PathList.py index 943e9adf..be645ca2 100644 --- a/src/engine/SCons/PathList.py +++ b/src/engine/SCons/PathList.py @@ -138,7 +138,8 @@ class _PathList: value = string.join(map(str, value), '') elif type == TYPE_OBJECT: value = node_conv(value) - result.append(value) + if value: + result.append(value) return tuple(result) diff --git a/src/engine/SCons/PathListTests.py b/src/engine/SCons/PathListTests.py index d0ba2a03..8203ccff 100644 --- a/src/engine/SCons/PathListTests.py +++ b/src/engine/SCons/PathListTests.py @@ -47,7 +47,7 @@ class subst_pathTestCase(unittest.TestCase): s = self.kw[s] return s - self.env = FakeEnvironment(AAA = 'aaa') + self.env = FakeEnvironment(AAA = 'aaa', NULL = '') def test_node(self): """Test the subst_path() method on a Node @@ -111,10 +111,10 @@ class subst_pathTestCase(unittest.TestCase): assert result == ('x',), result def test_subst(self): - """Test the subst_path() method on a substitution string + """Test the subst_path() method on substitution strings """ - pl = SCons.PathList.PathList(('$AAA',)) + pl = SCons.PathList.PathList(('$AAA', '$NULL')) result = pl.subst_path(self.env, 'y', 'z') diff --git a/src/engine/SCons/Scanner/LaTeX.py b/src/engine/SCons/Scanner/LaTeX.py index 645a894d..c0a38b56 100644 --- a/src/engine/SCons/Scanner/LaTeX.py +++ b/src/engine/SCons/Scanner/LaTeX.py @@ -29,12 +29,12 @@ This module implements the dependency scanner for LaTeX code. __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" +import os.path +import string import SCons.Scanner -import string -import os.path -def LaTeXScanner(fs = SCons.Node.FS.default_fs): +def LaTeXScanner(): """Return a prototype Scanner instance for scanning LaTeX source files""" ds = LaTeX(name = "LaTeXScanner", suffixes = '$LATEXSUFFIXES', diff --git a/src/engine/SCons/Script/Main.py b/src/engine/SCons/Script/Main.py index a3c0a514..a76165f6 100644 --- a/src/engine/SCons/Script/Main.py +++ b/src/engine/SCons/Script/Main.py @@ -54,6 +54,7 @@ import traceback # 'lib', # 'scons-%d' % SCons.__version__)] + sys.path[1:] +import SCons.CacheDir import SCons.Debug import SCons.Defaults import SCons.Environment @@ -641,10 +642,15 @@ def _load_site_scons_dir(topdir, site_dir_name=None): SCons.Tool.DefaultToolpath.append(os.path.abspath(site_tools_dir)) def version_string(label, module): - fmt = "\t%s: v%s.%s, %s, by %s on %s\n" + version = module.__version__ + build = module.__build__ + if build: + if build[0] != '.': + build = '.' + build + version = version + build + fmt = "\t%s: v%s, %s, by %s on %s\n" return fmt % (label, - module.__version__, - module.__build__, + version, module.__date__, module.__developer__, module.__buildsys__) @@ -720,7 +726,7 @@ def _main(parser): # Now that we're in the top-level SConstruct directory, go ahead # and initialize the FS object that represents the file system, # and make it the build engine default. - fs = SCons.Node.FS.default_fs = SCons.Node.FS.FS() + fs = SCons.Node.FS.get_default_fs() for rep in options.repository: fs.Repository(rep) @@ -770,15 +776,14 @@ def _main(parser): if options.silent: SCons.Action.print_actions = None - if options.cache_debug: - fs.CacheDebugEnable(options.cache_debug) if options.cache_disable: - def disable(self): pass - fs.CacheDir = disable + SCons.CacheDir.CacheDir = SCons.Util.Null() + if options.cache_debug: + SCons.CacheDir.cache_debug = options.cache_debug if options.cache_force: - fs.cache_force = 1 + SCons.CacheDir.cache_force = True if options.cache_show: - fs.cache_show = 1 + SCons.CacheDir.cache_show = True if options.site_dir: _load_site_scons_dir(d, options.site_dir) diff --git a/src/engine/SCons/Script/SConsOptions.py b/src/engine/SCons/Script/SConsOptions.py index 053fff1f..46ece273 100644 --- a/src/engine/SCons/Script/SConsOptions.py +++ b/src/engine/SCons/Script/SConsOptions.py @@ -166,6 +166,65 @@ class SConsValues(optparse.Values): self.__SConscript_settings__[name] = value +class SConsOption(optparse.Option): + def convert_value(self, opt, value): + if value is not None: + if self.nargs in (1, '?'): + return self.check_value(opt, value) + else: + return tuple(map(lambda v, o=opt, s=self: s.check_value(o, v), value)) + + def process(self, opt, value, values, parser): + + # First, convert the value(s) to the right type. Howl if any + # value(s) are bogus. + value = self.convert_value(opt, value) + + # And then take whatever action is expected of us. + # This is a separate method to make life easier for + # subclasses to add new actions. + return self.take_action( + self.action, self.dest, opt, value, values, parser) + + def _check_nargs_optional(self): + if self.nargs == '?' and self._short_opts: + fmt = "option %s: nargs='?' is incompatible with short options" + raise SCons.Errors.UserError, fmt % self._short_opts[0] + + try: + _orig_CONST_ACTIONS = optparse.Option.CONST_ACTIONS + + _orig_CHECK_METHODS = optparse.Option.CHECK_METHODS + + except AttributeError: + # optparse.Option had no CONST_ACTIONS before Python 2.5. + + _orig_CONST_ACTIONS = ("store_const",) + + def _check_const(self): + if self.action not in self.CONST_ACTIONS and self.const is not None: + raise OptionError( + "'const' must not be supplied for action %r" % self.action, + self) + + # optparse.Option collects its list of unbound check functions + # up front. This sucks because it means we can't just override + # the _check_const() function like a normal method, we have to + # actually replace it in the list. This seems to be the most + # straightforward way to do that. + + _orig_CHECK_METHODS = [optparse.Option._check_action, + optparse.Option._check_type, + optparse.Option._check_choice, + optparse.Option._check_dest, + _check_const, + optparse.Option._check_nargs, + optparse.Option._check_callback] + + CHECK_METHODS = _orig_CHECK_METHODS + [_check_nargs_optional] + + CONST_ACTIONS = _orig_CONST_ACTIONS + optparse.Option.TYPED_ACTIONS + class SConsOptionGroup(optparse.OptionGroup): """ A subclass for SCons-specific option groups. @@ -232,7 +291,12 @@ class SConsOptionParser(optparse.OptionParser): option = self._long_opt[opt] if option.takes_value(): nargs = option.nargs - if len(rargs) < nargs: + if nargs == '?': + if had_explicit_value: + value = rargs.pop(0) + else: + value = option.const + elif len(rargs) < nargs: if nargs == 1: self.error(_("%s option requires an argument") % opt) else: @@ -396,7 +460,8 @@ def Parser(version): formatter = SConsIndentedHelpFormatter(max_help_position=30) - op = SConsOptionParser(add_help_option=False, + op = SConsOptionParser(option_class=SConsOption, + add_help_option=False, formatter=formatter, usage="usage: scons [OPTION] [TARGET] ...",) diff --git a/src/engine/SCons/Script/__init__.py b/src/engine/SCons/Script/__init__.py index 8204c65f..4010d80b 100644 --- a/src/engine/SCons/Script/__init__.py +++ b/src/engine/SCons/Script/__init__.py @@ -296,6 +296,8 @@ GlobalDefaultEnvironmentFunctions = [ 'Execute', 'File', 'FindFile', + 'FindInstalledFiles', + 'FindSourceFiles', 'Flatten', 'GetBuildPath', 'Ignore', @@ -311,11 +313,9 @@ GlobalDefaultEnvironmentFunctions = [ 'SourceCode', 'SourceSignatures', 'Split', + 'Tag', 'TargetSignatures', 'Value', - 'Tag', - 'FindInstalledFiles', - 'FindSourceFiles', ] GlobalDefaultBuilders = [ diff --git a/src/engine/SCons/Tool/JavaCommonTests.py b/src/engine/SCons/Tool/JavaCommonTests.py index 40f0a47f..358f6757 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 bf3df563..97a4e702 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 2deb1f19..5c3b383c 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 5e631fdc..46aefbb2 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 8494fd69..b7483036 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 5083c9f8..828bb9ee 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 00000000..4b57a688 --- /dev/null +++ b/src/engine/SCons/Tool/install.xml @@ -0,0 +1,52 @@ + + + + +Sets construction variables for file +and directory installation. + + +INSTALL +INSTALLSTR + + + + + +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. + + +env.Install('/usr/local/bin', source = ['foo', 'bar']) + + + + + + +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. + + +env.InstallAs(target = '/usr/local/bin/foo', + source = 'foo_debug') +env.InstallAs(target = ['../lib/libfoo.a', '../lib/libbar.a'], + source = ['libFOO.a', 'libBAR.a']) + + + diff --git a/src/engine/SCons/Tool/jar.py b/src/engine/SCons/Tool/jar.py index cb0a8eb6..4f221c04 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 0deaaaeb..a0d730e8 100644 --- a/src/engine/SCons/Tool/jar.xml +++ b/src/engine/SCons/Tool/jar.xml @@ -22,7 +22,13 @@ JARCOMSTR Builds a Java archive (.jar) file -from a source tree of .class files. +from the specified list of sources. +Any directories in the source list +will be searched for .class files). +Any .java files in the source list +will be compiled to .class 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. env.Jar(target = 'foo.jar', source = 'classes') + +env.Jar(target = 'bar.jar', + source = ['bar1.java', 'bar2.java']) diff --git a/src/engine/SCons/Tool/javac.py b/src/engine/SCons/Tool/javac.py index 85dfc3fd..5703b2d1 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 248eda2a..f5af9757 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 JAVACCOMSTR @@ -22,16 +24,21 @@ JAVACCOMSTR -Builds one or more Java class files -from one or more source trees of .java 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 +.java files, +or directory trees which will be scanned +for .java files. + SCons will parse each source .java file to find the classes (including inner classes) defined within that file, and from that figure out the target .class 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: env.Java(target = 'classes', source = 'src') env.Java(target = 'classes', source = ['src1', 'src2']) +env.Java(target = 'classes', source = ['File1.java', 'File2.java']) @@ -107,6 +115,27 @@ builder. + + +Specifies the list of directories that +will be searched for Java +.class file. +The directories in this list will be added to the +&javac; and &javah; command lines +via the option. +The individual directory names will be +separated by the operating system's path separate character +(: on UNIX/Linux/POSIX, +; on Windows). + +Note that this currently just adds the specified +directory via the option. +&SCons; does not currently search the +&cv-JAVACLASSPATH; directories for dependency +.class files. + + + The suffix for Java class files; @@ -115,6 +144,27 @@ by default. + + +Specifies the list of directories that +will be searched for input +.java file. +The directories in this list will be added to the +&javac; command line +via the option. +The individual directory names will be +separated by the operating system's path separate character +(: on UNIX/Linux/POSIX, +; on Windows). + +Note that this currently just adds the specified +directory via the option. +&SCons; does not currently search the +&cv-JAVASOURCEPATH; directories for dependency +.java files. + + + The suffix for Java files; diff --git a/src/engine/SCons/Tool/javah.py b/src/engine/SCons/Tool/javah.py index 26fcc532..7eb4969e 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 c6487e7c..20fe3eec 100644 --- a/src/engine/SCons/Tool/javah.xml +++ b/src/engine/SCons/Tool/javah.xml @@ -16,6 +16,7 @@ JAVACLASSSUFFIX JAVAHCOMSTR +JAVACLASSPATH @@ -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 .class files, +The source can be the names of .class files, +the names of .java files +to be compiled into .class 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 31f21a9d..e599f8ae 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 c5f40b7c..e8f6a091 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 8e7f652a..bf4e96ef 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. --> -TODO +Sets construction variables for the &b-Package; Builder. + + + + -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: + +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 ⌖, 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. - 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' ) + + - + -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 +Architecture: +field in an Ipkg +control file, +and as part of the name of a generated RPM file. - + -TODO +A hook for modifying the file that controls the packaging build +(the .spec for RPM, +the control for Ipkg, +the .wxs for MSI). +If set, the function will be called +after the SCons template for the file has been written. +XXX + + +The name of a file containing the change log text +to be included in the package. +This is included as the +%changelog +section of the RPM +.spec file. + + - + -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. - + -The shorthand of the license this project is under (gpl, lpgl, bsd etc.). +A language-specific long description for +the specified lang. +This is used to populate a +%description -l +section of an RPM +.spec file. - + -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. - + -The version of the project, given as a string. +Specfies the name of the project to package. - + -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". -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. - + -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. -TODO +The URL +(web address) +of the location from which the project was retrieved. +This is used to fill in the +Source: +field in the controlling information for Ipkg and RPM packages. - + -TODO +A short summary of what the project is about. +This is used to fill in the +Summary: +field in the controlling information for Ipkg and RPM packages, +and as the +Description: +field in MSI packages. - + -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 +Vendor: +field in the controlling information for RPM packages, +and the +Manufacturer: +field in the controlling information for MSI packages. - + -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. - + + -TODO +This is used to fill in the +Depends: +field in the controlling information for Ipkg packages. - + -TODO +This is used to fill in the +Description: +field in the controlling information for Ipkg packages. +The default value is +$SUMMARY\n$DESCRIPTION - + -TODO +This is used to fill in the +Maintainer: +field in the controlling information for Ipkg packages. - + -TODO +This is used to fill in the +Priority: +field in the controlling information for Ipkg packages. - + -TODO +This is used to fill in the +Section: +field in the controlling information for Ipkg packages. - + + + -TODO +This is used to fill in the +Language: +attribute in the controlling information for MSI packages. - + -TODO +The text of the software license in RTF format. +Carriage return characters will be +replaced with the RTF equivalent \\par. - + TODO - + + -internal, but overridable +This is used to fill in the +AutoReqProv: +field in the RPM +.spec file. @@ -201,188 +292,254 @@ internal, but overridable - + -internal, but overridable +This is used to fill in the +BuildRequires: +field in the RPM +.spec file. - + internal, but overridable - + -TODO +internal, but overridable - + -TODO +This is used to fill in the +Conflicts: +field in the RPM +.spec file. - + -TODO +This value is used as the default attributes +for the files in the RPM package. +The default value is +(-,root,root). -TODO +This is used to fill in the +Distribution: +field in the RPM +.spec file. - + -TODO +This is used to fill in the +Epoch: +field in the controlling information for RPM packages. - + -TODO +This is used to fill in the +ExcludeArch: +field in the RPM +.spec file. - + -TODO +This is used to fill in the +ExclusiveArch: +field in the RPM +.spec file. - + -TODO +This is used to fill in the +Group: +field in the RPM +.spec file. - + -TODO +This is used to fill in the +Group(lang): +field in the RPM +.spec file. +Note that +lang +is not literal +and should be replaced by +the appropriate language code. - + -TODO +This is used to fill in the +Icon: +field in the RPM +.spec file. - + -TODO +internal, but overridable - + -TODO +This is used to fill in the +Packager: +field in the RPM +.spec file. - + -TODO +This is used to fill in the +Provides: +field in the RPM +.spec file. - + -TODO +This is used to fill in the +%post: +section in the RPM +.spec file. - + -TODO +This is used to fill in the +%pre: +section in the RPM +.spec file. -TODO +This is used to fill in the +Prefix: +field in the RPM +.spec file. - - -TODO - - - - + internal, but overridable - + -TODO +This is used to fill in the +%postun: +section in the RPM +.spec file. - + -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 +%preun: +section in the RPM +.spec file. - + -TODO +This is used to fill in the +Requires: +field in the RPM +.spec file. - + -TODO +This is used to fill in the +Serial: +field in the RPM +.spec file. - + -TODO +This is used to fill in the +Url: +field in the RPM +.spec file. - + + + - - -TODO - - - + diff --git a/src/engine/SCons/Tool/packaging/rpm.py b/src/engine/SCons/Tool/packaging/rpm.py index 49b8ff85..94b7b7aa 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 5326e8d2..8ca1b89c 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 679d6832..580ef97e 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 SWIGCOMSTR @@ -94,6 +98,36 @@ variable. + + +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;. + + + + + +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. + + + + + +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. + + + Specifies the output directory in which @@ -105,3 +139,55 @@ and translated into the swig -outdir option on the command line. + + + +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 #: + + +env = Environment(SWIGPATH='#/include') + + +The directory look-up can also be forced using the +&Dir;() +function: + + +include = Dir('include') +env = Environment(SWIGPATH=include) + + +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;: + + +env = Environment(SWIGCOM="my_swig -o $TARGET $_SWIGINCFLAGS $SORUCES") + + + diff --git a/src/engine/SCons/Tool/wix.py b/src/engine/SCons/Tool/wix.py index b133947b..3aa3375e 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 cbccb294..34f60cb6 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 diff --git a/src/engine/SCons/Util.py b/src/engine/SCons/Util.py index 22aca088..3dfa2872 100644 --- a/src/engine/SCons/Util.py +++ b/src/engine/SCons/Util.py @@ -312,16 +312,16 @@ def print_tree(root, child_func, prune=0, showtags=0, margin=[0], visited={}): return [" ","| "][m] margins = map(MMM, margin[:-1]) - if visited.has_key(rname): + children = child_func(root) + + if prune and visited.has_key(rname) and children: print string.join(tags + margins + ['+-[', rname, ']'], '') return print string.join(tags + margins + ['+-', rname], '') - if prune: - visited[rname] = 1 + visited[rname] = 1 - children = child_func(root) if children: margin.append(1) map(lambda C, cf=child_func, p=prune, i=IDX(showtags), m=margin, v=visited: @@ -404,6 +404,64 @@ def flatten(sequence, scalarp=is_Scalar, result=None): flatten(item, scalarp, result) return result + + +# The SCons "semi-deep" copy. +# +# This makes separate copies of lists (including UserList objects) +# dictionaries (including UserDict objects) and tuples, but just copies +# references to anything else it finds. +# +# A special case is any object that has a __semi_deepcopy__() method, +# which we invoke to create the copy, which is used by the BuilderDict +# class because of its extra initialization argument. +# +# The dispatch table approach used here is a direct rip-off from the +# normal Python copy module. + +_semi_deepcopy_dispatch = d = {} + +def _semi_deepcopy_dict(x): + copy = {} + for key, val in x.items(): + # The regular Python copy.deepcopy() also deepcopies the key, + # as follows: + # + # copy[semi_deepcopy(key)] = semi_deepcopy(val) + # + # Doesn't seem like we need to, but we'll comment it just in case. + copy[key] = semi_deepcopy(val) + return copy +d[types.DictionaryType] = _semi_deepcopy_dict + +def _semi_deepcopy_list(x): + return map(semi_deepcopy, x) +d[types.ListType] = _semi_deepcopy_list + +def _semi_deepcopy_tuple(x): + return tuple(map(semi_deepcopy, x)) +d[types.TupleType] = _semi_deepcopy_tuple + +def _semi_deepcopy_inst(x): + if hasattr(x, '__semi_deepcopy__'): + return x.__semi_deepcopy__() + elif isinstance(x, UserDict): + return x.__class__(_semi_deepcopy_dict(x)) + elif isinstance(x, UserList): + return x.__class__(_semi_deepcopy_list(x)) + else: + return x +d[types.InstanceType] = _semi_deepcopy_inst + +def semi_deepcopy(x): + copier = _semi_deepcopy_dispatch.get(type(x)) + if copier: + return copier(x) + else: + return x + + + class Proxy: """A simple generic Proxy class, forwarding all calls to subject. So, for the benefit of the python newbie, what does @@ -1044,4 +1102,35 @@ def RenameFunction(function, name): +# From Dinu C. Gherman, +# Python Cookbook, second edition, recipe 6.17, p. 277. +# Also: +# http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/68205 +# ASPN: Python Cookbook: Null Object Design Pattern + +class Null: + """ Null objects always and reliably "do nothging." """ + + def __new__(cls, *args, **kwargs): + if not '_inst' in vars(cls): + #cls._inst = type.__new__(cls, *args, **kwargs) + cls._inst = apply(type.__new__, (cls,) + args, kwargs) + return cls._inst + def __init__(self, *args, **kwargs): + pass + def __call__(self, *args, **kwargs): + return self + def __repr__(self): + return "Null()" + def __nonzero__(self): + return False + def __getattr__(self, mname): + return self + def __setattr__(self, name, value): + return self + def __delattr__(self, name): + return self + + + del __revision__ diff --git a/src/engine/SCons/UtilTests.py b/src/engine/SCons/UtilTests.py index db6d9f6e..1149f358 100644 --- a/src/engine/SCons/UtilTests.py +++ b/src/engine/SCons/UtilTests.py @@ -106,7 +106,7 @@ class UtilTestCase(unittest.TestCase): return foo, expect, withtags - def tree_case_2(self): + def tree_case_2(self, prune=1): """Fixture for the render_tree() and print_tree() tests.""" stdlib_h = self.Node("stdlib.h") @@ -124,6 +124,10 @@ class UtilTestCase(unittest.TestCase): +-[stdlib.h] """ + if not prune: + expect = string.replace(expect, '[', '') + expect = string.replace(expect, ']', '') + lines = string.split(expect, '\n')[:-1] lines = map(lambda l: '[E BSPACN ]'+l, lines) withtags = string.join(lines, '\n') + '\n' @@ -163,7 +167,7 @@ class UtilTestCase(unittest.TestCase): actual = sys.stdout.getvalue() assert withtags == actual, (withtags, actual) - node, expect, withtags = self.tree_case_2() + node, expect, withtags = self.tree_case_2(prune=0) sys.stdout = StringIO.StringIO() print_tree(node, get_children, 1) diff --git a/src/engine/setup.py b/src/engine/setup.py index 4b511b07..692b0a04 100644 --- a/src/engine/setup.py +++ b/src/engine/setup.py @@ -63,7 +63,6 @@ software.""", keywords = "scons, cons, make, build tool, make tool", packages = ["SCons", "SCons.Node", - "SCons.Optik", "SCons.Scanner", "SCons.Sig", "SCons.Script"]) diff --git a/src/setup.py b/src/setup.py index 5614adba..71233042 100644 --- a/src/setup.py +++ b/src/setup.py @@ -29,7 +29,7 @@ import stat import string import sys -Version = "0.97" +Version = "__VERSION__" man_pages = [ 'scons.1', @@ -376,13 +376,13 @@ arguments = { 'packages' : ["SCons", "SCons.compat", "SCons.Node", - "SCons.Optik", "SCons.Options", "SCons.Platform", "SCons.Scanner", "SCons.Script", "SCons.Sig", - "SCons.Tool"], + "SCons.Tool", + "SCons.Tool.packaging"], 'package_dir' : {'' : 'engine'}, 'data_files' : [('man/man1', man_pages)], 'scripts' : scripts, diff --git a/src/test_interrupts.py b/src/test_interrupts.py index d18bece6..9e91cc50 100644 --- a/src/test_interrupts.py +++ b/src/test_interrupts.py @@ -62,8 +62,13 @@ else: scons_lib_dir = os.path.join(cwd, 'build', 'scons') MANIFEST = os.path.join(scons_lib_dir, 'MANIFEST') -files = string.split(open(MANIFEST).read()) -files = filter(lambda f: f[-3:] == '.py', files) +try: + fp = open(MANIFEST) +except IOError: + test.skip_test('%s does not exist; skipping test.\n' % MANIFEST) +else: + files = string.split(fp.read()) + files = filter(lambda f: f[-3:] == '.py', files) # some regexps to parse the python files tryexc_pat = re.compile( diff --git a/src/test_pychecker.py b/src/test_pychecker.py index 368520f9..00325598 100644 --- a/src/test_pychecker.py +++ b/src/test_pychecker.py @@ -72,10 +72,6 @@ ignore = [ 'SCons/compat/__init__.py', 'SCons/compat/builtins.py', 'SCons/compat/_subprocess.py', - 'SCons/Optik/__init__.py', - 'SCons/Optik/errors.py', - 'SCons/Optik/option.py', - 'SCons/Optik/option_parser.py', ] u = {} diff --git a/src/test_strings.py b/src/test_strings.py index a3ed6e84..0d6e6ac6 100644 --- a/src/test_strings.py +++ b/src/test_strings.py @@ -124,12 +124,13 @@ check_list = [ 'src', search_list = [ '*.py' ], remove_list = [ + 'engine/SCons/compat/_scons_optparse.py', 'engine/SCons/compat/_scons_sets.py', 'engine/SCons/compat/_scons_sets15.py', 'engine/SCons/compat/_scons_subprocess.py', + 'engine/SCons/compat/_scons_textwrap.py', 'engine/SCons/Conftest.py', 'engine/SCons/dblite.py', - 'engine/SCons/Optik', ], ), @@ -147,31 +148,34 @@ check_list = [ 'debian', 'dist', 'gentoo', + 'engine/SCons/compat/_scons_optparse.py', 'engine/SCons/compat/_scons_sets.py', 'engine/SCons/compat/_scons_sets15.py', 'engine/SCons/compat/_scons_subprocess.py', + 'engine/SCons/compat/_scons_textwrap.py', 'engine/SCons/Conftest.py', 'engine/SCons/dblite.py', - 'engine/SCons/Optik', 'MANIFEST', 'os_spawnv_fix.diff', 'setup.cfg', ], # We run epydoc on the *.py files, which generates *.pyc files. remove_patterns = [ - '*.pyc' + '*.pyc', ] ), CheckExpandedCopyright( build_local, remove_list = [ + 'SCons/compat/_scons_optparse.py', 'SCons/compat/_scons_sets.py', 'SCons/compat/_scons_sets15.py', 'SCons/compat/_scons_subprocess.py', + 'SCons/compat/_scons_textwrap.py', 'SCons/Conftest.py', 'SCons/dblite.py', - 'SCons/Optik', + 'scons-%s.egg-info' % scons_version, ], ), @@ -194,6 +198,7 @@ check_list = [ 'doc/user/SCons-win32-install-2.jpg', 'doc/user/SCons-win32-install-3.jpg', 'doc/user/SCons-win32-install-4.jpg', + 'examples', 'gentoo', 'QMTest/classes.qmc', 'QMTest/configuration', @@ -206,12 +211,13 @@ check_list = [ 'src/engine/MANIFEST.in', 'src/engine/MANIFEST-xml.in', 'src/engine/setup.cfg', + 'src/engine/SCons/compat/_scons_optparse.py', 'src/engine/SCons/compat/_scons_sets.py', 'src/engine/SCons/compat/_scons_sets15.py', 'src/engine/SCons/compat/_scons_subprocess.py', + 'src/engine/SCons/compat/_scons_textwrap.py', 'src/engine/SCons/Conftest.py', 'src/engine/SCons/dblite.py', - 'src/engine/SCons/Optik', 'src/script/MANIFEST.in', 'src/script/setup.cfg', ], diff --git a/test/AS/ml.py b/test/AS/ml.py index 0cb0e9ec..633befd8 100644 --- a/test/AS/ml.py +++ b/test/AS/ml.py @@ -39,7 +39,7 @@ _exe = TestSCons._exe test = TestSCons.TestSCons() -if sys.platform == 'win32': +if sys.platform != 'win32': test.skip_test("Skipping ml test on non-win32 platform '%s'\n" % sys.platform) ml = test.where_is('ml') diff --git a/test/AS/nasm.py b/test/AS/nasm.py index f96db7e6..f1b99eee 100644 --- a/test/AS/nasm.py +++ b/test/AS/nasm.py @@ -45,7 +45,7 @@ if not nasm: test.skip_test('nasm not found; skipping test\n') if string.find(sys.platform, 'linux') == -1: - test.skip_test("skipping test on non-Linux platform '%s'\n" % sys.platfrom) + test.skip_test("skipping test on non-Linux platform '%s'\n" % sys.platform) try: import popen2 diff --git a/test/Actions/addpost-link.py b/test/Actions/addpost-link.py new file mode 100644 index 00000000..f97d4a3e --- /dev/null +++ b/test/Actions/addpost-link.py @@ -0,0 +1,76 @@ +#!/usr/bin/env python +# +# __COPYRIGHT__ +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +""" +Verify that AddPostAction() on a program target doesn't interfere with +linking. + +This is a test for fix of Issue 1004, reported by Matt Doar and +packaged by Gary Oberbrunner. +""" + +import TestSCons + + +test = TestSCons.TestSCons() + +test.write('SConstruct', """\ +env = Environment() + +mylib = env.StaticLibrary('mytest', 'test_lib.c') + +myprog = env.Program('test1.c', + LIBPATH = ['.'], + LIBS = ['mytest']) +if ARGUMENTS['case']=='2': + AddPostAction(myprog, Action('strip ' + myprog[0].abspath)) +""") + +test.write('test1.c', """\ +extern void test_lib_fn(); +int main(int argc, char **argv) { + test_lib_fn(); + return 0; +} +""") + +test.write('test_lib.c', r"""\ +#include + +void test_lib_fn() { + printf("Hello world\n"); +} +""") + +test.run(arguments="-Q case=1", stderr=None) + +test.run(arguments="-Q -c case=1") + +test.must_not_exist('test1.o') + +test.run(arguments="-Q case=2", stderr=None) + +test.pass_test() diff --git a/test/Actions/pre-post.py b/test/Actions/pre-post.py index 7566f2f9..674c628a 100644 --- a/test/Actions/pre-post.py +++ b/test/Actions/pre-post.py @@ -49,9 +49,11 @@ import stat env = Environment(XXX='bar%(_exe)s') def before(env, target, source): - f=open(str(target[0]), "wb") + a=str(target[0]) + f=open(a, "wb") f.write("Foo\\n") f.close() + os.chmod(a, os.stat(a)[stat.ST_MODE] | stat.S_IXUSR) f=open("before.txt", "ab") f.write(os.path.splitext(str(target[0]))[0] + "\\n") f.close() diff --git a/test/AddOption/optional-arg.py b/test/AddOption/optional-arg.py new file mode 100644 index 00000000..f7a03378 --- /dev/null +++ b/test/AddOption/optional-arg.py @@ -0,0 +1,102 @@ +#!/usr/bin/env python +# +# __COPYRIGHT__ +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +""" +Verify use of the nargs='?' keyword argument to specify a long +command-line option with an optional argument value. +""" + +import string + +import TestSCons + +test = TestSCons.TestSCons() + +test.write('SConstruct', """\ +AddOption('--install', + nargs='?', + dest='install', + default='/default/directory', + const='/called/default/directory', + action='store', + type='string', + metavar='DIR', + help='installation directory') +print GetOption('install') +""") + +test.run('-Q -q', + stdout="/default/directory\n") + +test.run('-Q -q next-arg', + stdout="/default/directory\n", + status=1) + +test.run('-Q -q . --install', + stdout="/called/default/directory\n") + +test.run('-Q -q . --install next-arg', + stdout="/called/default/directory\n", + status=1) + +test.run('-Q -q . first-arg --install', + stdout="/called/default/directory\n", + status=1) + +test.run('-Q -q . first-arg --install next-arg', + stdout="/called/default/directory\n", + status=1) + +test.run('-Q -q . --install=/command/line/directory', + stdout="/command/line/directory\n") + +test.run('-Q -q . --install=/command/line/directory next-arg', + stdout="/command/line/directory\n", + status=1) + +test.run('-Q -q . first-arg --install=/command/line/directory', + stdout="/command/line/directory\n", + status=1) + +test.run('-Q -q . first-arg --install=/command/line/directory next-arg', + stdout="/command/line/directory\n", + status=1) + + +test.write('SConstruct', """\ +AddOption('-X', nargs='?') +""") + +expect = r""" +scons: \*\*\* option -X: nargs='\?' is incompatible with short options +File "[^"]+", line \d+, in \S+ +""" + +test.run(status=2, stderr=expect, match=TestSCons.match_re) + + + +test.pass_test() diff --git a/test/BuildDir/CPPPATH-subdir.py b/test/BuildDir/CPPPATH-subdir.py index 72542798..9d3bb983 100644 --- a/test/BuildDir/CPPPATH-subdir.py +++ b/test/BuildDir/CPPPATH-subdir.py @@ -58,6 +58,7 @@ env.Library('foo', 'foo.c') test.write(['src', 'glscry', 'foo.c'], """\ #include +int foo(void) { return 0; } """) diff --git a/test/CPPPATH/match-dir.py b/test/CPPPATH/match-dir.py new file mode 100644 index 00000000..f8501c6d --- /dev/null +++ b/test/CPPPATH/match-dir.py @@ -0,0 +1,61 @@ +#!/usr/bin/env python +# +# __COPYRIGHT__ +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +""" +Verify that we don't blow up if there's a directory name within +$CPPPATH that matches a #include file name. +""" + +import TestSCons + +test = TestSCons.TestSCons() + +test.subdir(['src'], + ['src', 'inc'], + ['src', 'inc', 'inc2']) + +test.write('SConstruct', """\ +SConscript('src/SConscript', build_dir = 'build', duplicate = 0) +""") + +test.write(['src', 'SConscript'], """\ +env = Environment(CPPPATH = ['#build/inc', '#build/inc/inc2']) +env.Object('foo.c') +""") + +test.write(['src', 'foo.c'], """\ +#include "inc1" +""") + +test.subdir(['src', 'inc', 'inc1']) + +test.write(['src', 'inc', 'inc2', 'inc1'], "\n") + +test.run(arguments = '.') + +test.up_to_date(arguments = '.') + +test.pass_test() diff --git a/test/CacheDir/BuildDir.py b/test/CacheDir/BuildDir.py index d03bfa63..a41d397f 100644 --- a/test/CacheDir/BuildDir.py +++ b/test/CacheDir/BuildDir.py @@ -39,11 +39,6 @@ test.subdir('cache', 'src') cache = test.workpath('cache') cat_out = test.workpath('cat.out') -test.write(['src', 'SConstruct'], """\ -CacheDir(r'%(cache)s') -SConscript('SConscript') -""" % locals()) - test.write(['src', 'SConscript'], """\ def cat(env, source, target): target = str(target[0]) @@ -72,7 +67,7 @@ test.write(['src', 'ccc.in'], "ccc.in\n") # test.write('SConstruct', """\ env = Environment(TWO = '2') -env.CacheDir(r'%s') +CacheDir(r'%s') BuildDir('build', 'src', duplicate=0) SConscript('build/SConscript') """ % test.workpath('cache${TWO}')) diff --git a/test/CacheDir/environment.py b/test/CacheDir/environment.py new file mode 100644 index 00000000..391fb94f --- /dev/null +++ b/test/CacheDir/environment.py @@ -0,0 +1,163 @@ +#!/usr/bin/env python +# +# __COPYRIGHT__ +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +""" +Verify that whether or not a target gets retrieved from a CacheDir +is configurable by construction environment. +""" + +import os + +import TestSCons + +test = TestSCons.TestSCons() + +cache = test.workpath('cache') + +src_aaa_out = test.workpath('src', 'aaa.out') +src_bbb_out = test.workpath('src', 'bbb.out') +src_ccc_out = test.workpath('src', 'ccc.out') +src_cat_out = test.workpath('src', 'cat.out') +src_all = test.workpath('src', 'all') + +test.subdir('cache', 'src') + +test.write(['src', 'SConstruct'], """\ +CacheDir(r'%(cache)s') +SConscript('SConscript') +""" % locals()) + +test.write(['src', 'SConscript'], """\ +def cat(env, source, target): + target = str(target[0]) + open('cat.out', 'ab').write(target + "\\n") + source = map(str, source) + f = open(target, "wb") + for src in source: + f.write(open(src, "rb").read()) + f.close() +env_cache = Environment(BUILDERS={'Cat':Builder(action=cat)}) +env_nocache = env_cache.Clone() +env_nocache.CacheDir(None) +env_cache.Cat('aaa.out', 'aaa.in') +env_nocache.Cat('bbb.out', 'bbb.in') +env_cache.Cat('ccc.out', 'ccc.in') +env_nocache.Cat('all', ['aaa.out', 'bbb.out', 'ccc.out']) +""") + +test.write(['src', 'aaa.in'], "aaa.in\n") +test.write(['src', 'bbb.in'], "bbb.in\n") +test.write(['src', 'ccc.in'], "ccc.in\n") + +# Verify that building with -n and an empty cache reports that proper +# build operations would be taken, but that nothing is actually built +# and that the cache is still empty. +test.run(chdir = 'src', arguments = '-n .', stdout = test.wrap_stdout("""\ +cat(["aaa.out"], ["aaa.in"]) +cat(["bbb.out"], ["bbb.in"]) +cat(["ccc.out"], ["ccc.in"]) +cat(["all"], ["aaa.out", "bbb.out", "ccc.out"]) +""")) + +test.must_not_exist(src_aaa_out) +test.must_not_exist(src_bbb_out) +test.must_not_exist(src_ccc_out) +test.must_not_exist(src_all) +test.fail_test(len(os.listdir(cache))) + +# Verify that a normal build works correctly, and clean up. +# This should populate the cache with our derived files. +test.run(chdir = 'src', arguments = '.') + +test.must_match(['src', 'all'], "aaa.in\nbbb.in\nccc.in\n") +test.must_match(src_cat_out, "aaa.out\nbbb.out\nccc.out\nall\n") + +test.up_to_date(chdir = 'src', arguments = '.') + +test.run(chdir = 'src', arguments = '-c .') +test.unlink(src_cat_out) + +# Verify that we now retrieve the derived files from cache, +# not rebuild them. Then clean up. +test.run(chdir = 'src', arguments = '.', stdout = test.wrap_stdout("""\ +Retrieved `aaa.out' from cache +cat(["bbb.out"], ["bbb.in"]) +Retrieved `ccc.out' from cache +cat(["all"], ["aaa.out", "bbb.out", "ccc.out"]) +""")) + +test.must_match(src_cat_out, "bbb.out\nall\n") + +test.up_to_date(chdir = 'src', arguments = '.') + +test.run(chdir = 'src', arguments = '-c .') +test.unlink(src_cat_out) + +# Verify that rebuilding with -n reports that files were retrieved +# from the cache, but that nothing really was. +test.run(chdir = 'src', arguments = '-n .', stdout = test.wrap_stdout("""\ +Retrieved `aaa.out' from cache +cat(["bbb.out"], ["bbb.in"]) +Retrieved `ccc.out' from cache +cat(["all"], ["aaa.out", "bbb.out", "ccc.out"]) +""")) + +test.must_not_exist(src_aaa_out) +test.must_not_exist(src_bbb_out) +test.must_not_exist(src_ccc_out) +test.must_not_exist(src_all) + +# Verify that rebuilding with -s retrieves everything from the cache +# even though it doesn't report anything. +test.run(chdir = 'src', arguments = '-s .', stdout = "") + +test.must_match(['src', 'all'], "aaa.in\nbbb.in\nccc.in\n") + +test.must_match(src_cat_out, "bbb.out\nall\n") + +test.up_to_date(chdir = 'src', arguments = '.') + +test.run(chdir = 'src', arguments = '-c .') +test.unlink(src_cat_out) + +# Verify that updating one input file builds its derived file and +# dependency but that the other files are retrieved from cache. +test.write(['src', 'bbb.in'], "bbb.in 2\n") + +test.run(chdir = 'src', arguments = '.', stdout = test.wrap_stdout("""\ +Retrieved `aaa.out' from cache +cat(["bbb.out"], ["bbb.in"]) +Retrieved `ccc.out' from cache +cat(["all"], ["aaa.out", "bbb.out", "ccc.out"]) +""")) + +test.must_match(['src', 'all'], "aaa.in\nbbb.in 2\nccc.in\n") +test.must_match(src_cat_out, "bbb.out\nall\n") + +test.up_to_date(chdir = 'src', arguments = '.') + + +test.pass_test() diff --git a/test/option--cd.py b/test/CacheDir/option--cd.py similarity index 100% rename from test/option--cd.py rename to test/CacheDir/option--cd.py diff --git a/test/option--cf.py b/test/CacheDir/option--cf.py similarity index 100% rename from test/option--cf.py rename to test/CacheDir/option--cf.py diff --git a/test/option--cs.py b/test/CacheDir/option--cs.py similarity index 100% rename from test/option--cs.py rename to test/CacheDir/option--cs.py diff --git a/test/Case.py b/test/Case.py index 9b6bb947..663aa40d 100644 --- a/test/Case.py +++ b/test/Case.py @@ -65,6 +65,9 @@ void bar() { } """) +if sys.platform == 'darwin': + test.skip_test("Skipping test on Darwin/OSX; it has partial case sensitivity.") + if sys.platform in ['cygwin', 'win32']: sys.stdout.write("Using case-insensitive filesystem, testing for failure\n") sys.stdout.flush() diff --git a/test/Fortran/FORTRANMODDIR.py b/test/Fortran/FORTRANMODDIR.py index f0c500cc..a81439ab 100644 --- a/test/Fortran/FORTRANMODDIR.py +++ b/test/Fortran/FORTRANMODDIR.py @@ -54,6 +54,8 @@ test.write('SConstruct', """ env = Environment(FORTRANCOM = r'%(_python_)s myfortran.py $FORTRANMODDIR $SOURCE $TARGET', FORTRANMODDIR = 'modules') env.Object(target = 'test1.obj', source = 'test1.f') +env.Object(target = 'sub/test2.obj', source = 'test1.f', + FORTRANMODDIR='${TARGET.dir}') """ % locals()) test.write('test1.f', """\ @@ -86,6 +88,9 @@ test.must_match('test1.obj', "myfortran.py wrote test1.obj\n") test.must_match(['modules', 'mod_foo.mod'], "myfortran.py wrote mod_foo.mod\n") test.must_not_exist(['modules', 'mod_bar.mod']) +test.must_match(['sub', 'test2.obj'], "myfortran.py wrote test2.obj\n") +test.must_match(['sub', 'mod_foo.mod'], "myfortran.py wrote mod_foo.mod\n") + test.up_to_date(arguments = '.') diff --git a/test/Java/JARCHDIR.py b/test/Java/JARCHDIR.py index 9250843a..f7d9fca1 100644 --- a/test/Java/JARCHDIR.py +++ b/test/Java/JARCHDIR.py @@ -28,8 +28,14 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" Test that when JARCHDIR that our command to create .jar files correctly finds all the .class files (by putting -C in front of each class file argument). + +Includes logic to make sure that expansions of $JARCHDIR that include +${TARGET} or ${SOURCE} work. """ +import os +import string + import TestSCons test = TestSCons.TestSCons() @@ -50,6 +56,8 @@ else: if not where_jar: test.skip_test("Could not find Java jar, skipping test(s).\n") + + test.write('SConstruct', """ dir = 'dist' env = Environment(tools = ['javac', 'jar'], @@ -64,9 +72,19 @@ jar = env.Jar(File('c.jar', dir), bin) env = env.Clone(JARCHDIR = '.') inner = env.Jar('inner.jar', 'Inner$$Class.class') +target_env = env.Clone(JARCHDIR = '${TARGET.dir}') +target_env.Jar('out/t.jar', 'in/t.class') + +source_env = env.Clone(JARCHDIR = '${SOURCE.dir}') +source_env.Jar('out/s.jar', 'in/s.class') + Default(bin, jar, inner) """ % locals()) + + +test.subdir('in') + test.write('a.java', """\ package foo.bar; public class a {} @@ -77,8 +95,36 @@ package foo.bar; public class b {} """) +test.write(['in', 's.class'], "s.class\n") + +# Okay, this is bogus, but we're going with it for testing purposes. +# If jar gets a command line like: +# +# jar cf out/t.jar -C out /tmp/tmpXYZZY/in/t.class +# +# Empirically, it doesn't seem to treat the absolute path name +# of the argument class file as an absolute path, but looks for +# "out/tmp/tmpXYZZY/in/t.class". SCons, however, still looks for it in +# the path name specified on the command line. To make this test work, +# we're going to just create the t.class file in both locations, and +# we can revisit this if someone actually tries to use ${TARGET.dir} +# in a real-life expansion. Right now, it at least makes sure things +# don't blow up (i.e., validates that we pass the right arguments to +# env.subst() in the code that handle jar). + +p = test.workpath('out') +for d in string.split(test.workpath('in'), os.sep): + p = p + d + test.subdir(p) + p = p + os.sep + +test.write([p, 't.class'], "t.class\n") +test.write(['in', 't.class'], "t.class\n") + test.write('Inner$Class.class', "Inner$Class.class\n") test.run(arguments = '.') + + test.pass_test() diff --git a/test/Java/JAVACCOM.py b/test/Java/JAVACCOM.py index 7086a2a2..b6a30e93 100644 --- a/test/Java/JAVACCOM.py +++ b/test/Java/JAVACCOM.py @@ -60,7 +60,7 @@ test.write(['src', 'file3.java'], "file3.java\n/*javac*/\n") test.run() -test.must_match(['classes', 'src', 'file1.class'], +test.must_match(['classes', 'file1.class'], "file1.java\nfile2.java\nfile3.java\n") diff --git a/test/Java/JAVACCOMSTR.py b/test/Java/JAVACCOMSTR.py index 44b14496..88fa31da 100644 --- a/test/Java/JAVACCOMSTR.py +++ b/test/Java/JAVACCOMSTR.py @@ -62,16 +62,16 @@ test.write(['src', 'file1.java'], "file1.java\n/*javac*/\n") test.write(['src', 'file2.java'], "file2.java\n/*javac*/\n") test.write(['src', 'file3.java'], "file3.java\n/*javac*/\n") -classes_src_file1_class = os.path.join('classes', 'src', 'file1.class') +classes_file1_class = os.path.join('classes', 'file1.class') src_file1_java= os.path.join('src', 'file1.java') src_file2_java= os.path.join('src', 'file2.java') src_file3_java= os.path.join('src', 'file3.java') test.run(stdout = test.wrap_stdout("""\ -Compiling class(es) %(classes_src_file1_class)s from %(src_file1_java)s %(src_file2_java)s %(src_file3_java)s +Compiling class(es) %(classes_file1_class)s from %(src_file1_java)s %(src_file2_java)s %(src_file3_java)s """ % locals())) -test.must_match(['classes', 'src', 'file1.class'], +test.must_match(['classes', 'file1.class'], "file1.java\nfile2.java\nfile3.java\n") diff --git a/test/Java/JAVACLASSPATH.py b/test/Java/JAVACLASSPATH.py new file mode 100644 index 00000000..0ae7dea5 --- /dev/null +++ b/test/Java/JAVACLASSPATH.py @@ -0,0 +1,104 @@ +#!/usr/bin/env python +# +# __COPYRIGHT__ +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +""" +Verify that use of $JAVASOURCEPATH allows finding Java .class +files in alternate locations by adding the -classpath option +to the javac command line. +""" + +import TestSCons + +_python_ = TestSCons._python_ + +test = TestSCons.TestSCons() + +ENV = test.java_ENV() + +if test.detect_tool('javac', ENV=ENV): + where_javac = test.detect('JAVAC', 'javac', ENV=ENV) +else: + where_javac = test.where_is('javac') +if not where_javac: + test.skip_test("Could not find Java javac, skipping test(s).\n") + +if test.detect_tool('javah', ENV=ENV): + where_javah = test.detect('JAVAH', 'javah', ENV=ENV) +else: + where_javah = test.where_is('javah') +if not where_javah: + test.skip_test("Could not find Java javah, skipping test(s).\n") + +test.write('SConstruct', """ +env = Environment(tools = ['javac', 'javah'], + JAVAC = r'%(where_javac)s', + JAVAH = r'%(where_javah)s') +j1 = env.Java(target = 'class1', source = 'com1/Example1.java') +j2 = env.Java(target = 'class2', source = 'com2/Example2.java') +env.JavaH(target = 'outdir', source = [j1, j2], JAVACLASSPATH = 'class2') +""" % locals()) + +test.subdir('com1', 'com2') + +test.write(['com1', 'Example1.java'], """\ +package com; + +public class Example1 +{ + + public static void main(String[] args) + { + + } + +} +""") + +test.write(['com2', 'Example2.java'], """\ +package com; + +public class Example2 +{ + + public static void main(String[] args) + { + + } + +} +""") + +test.run(arguments = '.') + +test.must_exist(['class1', 'com', 'Example1.class']) +test.must_exist(['class2', 'com', 'Example2.class']) + +test.must_exist(['outdir', 'com_Example1.h']) +test.must_exist(['outdir', 'com_Example2.h']) + +test.up_to_date(arguments = '.') + +test.pass_test() diff --git a/test/Java/JAVASOURCEPATH.py b/test/Java/JAVASOURCEPATH.py new file mode 100644 index 00000000..069e2282 --- /dev/null +++ b/test/Java/JAVASOURCEPATH.py @@ -0,0 +1,81 @@ +#!/usr/bin/env python +# +# __COPYRIGHT__ +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +""" +Verify that use of $JAVASOURCEPATH allows finding source .java +files in alternate locations by adding the -sourcepath option +to the javac command line. +""" + +import TestSCons + +_python_ = TestSCons._python_ + +test = TestSCons.TestSCons() + +ENV = test.java_ENV() + +if test.detect_tool('javac', ENV=ENV): + where_javac = test.detect('JAVAC', 'javac', ENV=ENV) +else: + where_javac = test.where_is('javac') +if not where_javac: + test.skip_test("Could not find Java javac, skipping test(s).\n") + +test.write('SConstruct', """ +env = Environment(tools = ['javac', 'javah'], + JAVAC = r'%(where_javac)s') +bar = env.Java(target = 'bar/classes', + source = 'bar/src/TestBar.java', + JAVASOURCEPATH = ['foo/src']) +""" % locals()) + +test.subdir('foo', + ['foo', 'src'], + ['foo', 'src', 'com'], + ['foo', 'src', 'com', 'foo'], + ['foo', 'src', 'com', 'foo', 'test'], + 'bar', ['bar', 'src']) + +test.write(['foo', 'src', 'com', 'foo', 'test', 'TestFoo.java'], """\ +package com.foo.test; +public class TestFoo {;} +""") + +test.write(['bar', 'src', 'TestBar.java'], """\ +package com.bar.test; +import com.foo.test.TestFoo; +class TestBar extends TestFoo {;} +""") + +test.run(arguments = '.') + +test.must_exist(['bar', 'classes', 'com', 'bar', 'test', 'TestBar.class']) +test.must_exist(['bar', 'classes', 'com', 'foo', 'test', 'TestFoo.class']) + +test.up_to_date(arguments = '.') + +test.pass_test() diff --git a/test/Java/Java-1.4.py b/test/Java/Java-1.4.py index 8c3af594..3d3d47ab 100644 --- a/test/Java/Java-1.4.py +++ b/test/Java/Java-1.4.py @@ -58,6 +58,7 @@ env.Java(target = 'class2', source = 'com/sub/bar') env.Java(target = 'class3', source = ['src1', 'src2']) env.Java(target = 'class4', source = ['src4']) env.Java(target = 'class5', source = ['src5']) +env.Java(target = 'class6', source = ['src6']) """ % locals()) test.subdir('com', @@ -67,7 +68,8 @@ test.subdir('com', 'src1', 'src2', 'src4', - 'src5') + 'src5', + 'src6') test.write(['com', 'sub', 'foo', 'Example1.java'], """\ package com.sub.foo; @@ -273,23 +275,27 @@ class TestSCons { class Foo { } """) -test.run(arguments = '.') +# Test private inner class instantiation, courtesy Tilo Prutz: +# http://scons.tigris.org/issues/show_bug.cgi?id=1594 +test.write(['src6', 'TestSCons.java'], """\ +class test +{ + test() + { + super(); + new inner(); + } -def get_class_files(dir): - def find_class_files(arg, dirname, fnames): - for fname in fnames: - if fname[-6:] == '.class': - arg.append(os.path.join(dirname, fname)) - result = [] - os.path.walk(dir, find_class_files, result) - result.sort() - return result + static class inner + { + private inner() {} + } +} +""") -classes_1 = get_class_files(test.workpath('class1')) -classes_2 = get_class_files(test.workpath('class2')) -classes_3 = get_class_files(test.workpath('class3')) -classes_4 = get_class_files(test.workpath('class4')) -classes_5 = get_class_files(test.workpath('class5')) + + +test.run(arguments = '.') expect_1 = [ test.workpath('class1', 'com', 'other', 'Example2.class'), @@ -327,9 +333,27 @@ expect_5 = [ test.workpath('class5', 'TestSCons.class'), ] +expect_6 = [ + test.workpath('class6', 'test$1.class'), + test.workpath('class6', 'test$inner.class'), + test.workpath('class6', 'test.class'), +] + failed = None -def classes_must_match(dir, expect, got): +def get_class_files(dir): + def find_class_files(arg, dirname, fnames): + for fname in fnames: + if fname[-6:] == '.class': + arg.append(os.path.join(dirname, fname)) + result = [] + os.path.walk(dir, find_class_files, result) + result.sort() + return result + +def classes_must_match(dir, expect): + global failed + got = get_class_files(test.workpath(dir)) if expect != got: sys.stderr.write("Expected the following class files in '%s':\n" % dir) for c in expect: @@ -339,13 +363,40 @@ def classes_must_match(dir, expect, got): sys.stderr.write(' %s\n' % c) failed = 1 -classes_must_match('class1', expect_1, classes_1) -classes_must_match('class2', expect_2, classes_2) -classes_must_match('class3', expect_3, classes_3) -classes_must_match('class4', expect_4, classes_4) +def classes_must_not_exist(dir, expect): + global failed + present = filter(os.path.exists, expect) + if present: + sys.stderr.write("Found the following unexpected class files in '%s' after cleaning:\n" % dir) + for c in present: + sys.stderr.write(' %s\n' % c) + failed = 1 + +classes_must_match('class1', expect_1) +classes_must_match('class2', expect_2) +classes_must_match('class3', expect_3) +classes_must_match('class4', expect_4) +classes_must_match('class5', expect_5) +classes_must_match('class6', expect_6) test.fail_test(failed) test.up_to_date(options='--debug=explain', arguments = '.') +test.run(arguments = '-c .') + +classes_must_not_exist('class1', expect_1) +classes_must_not_exist('class2', expect_2) +classes_must_not_exist('class3', expect_3) +classes_must_not_exist('class4', expect_4) +classes_must_not_exist('class5', expect_5) +# This test case should pass, but doesn't. +# The expect_6 list contains the class files that the Java compiler +# actually creates, apparently because of the "private" instantiation +# of the "inner" class. Our parser doesn't currently detect this, so +# it doesn't know to remove that generated class file. +#classes_must_not_exist('class6', expect_6) + +test.fail_test(failed) + test.pass_test() diff --git a/test/Java/Java-1.5.py b/test/Java/Java-1.5.py index 0b3ba27a..4ac3d96c 100644 --- a/test/Java/Java-1.5.py +++ b/test/Java/Java-1.5.py @@ -59,6 +59,7 @@ env.Java(target = 'class2', source = 'com/sub/bar') env.Java(target = 'class3', source = ['src1', 'src2']) env.Java(target = 'class4', source = ['src4']) env.Java(target = 'class5', source = ['src5']) +env.Java(target = 'class6', source = ['src6']) """ % locals()) test.subdir('com', @@ -68,7 +69,8 @@ test.subdir('com', 'src1', 'src2', 'src4', - 'src5') + 'src5', + 'src6') test.write(['com', 'sub', 'foo', 'Example1.java'], """\ package com.sub.foo; @@ -274,23 +276,27 @@ class TestSCons { class Foo { } """) -test.run(arguments = '.') +# Test private inner class instantiation, courtesy Tilo Prutz: +# http://scons.tigris.org/issues/show_bug.cgi?id=1594 +test.write(['src6', 'TestSCons.java'], """\ +class test +{ + test() + { + super(); + new inner(); + } -def get_class_files(dir): - def find_class_files(arg, dirname, fnames): - for fname in fnames: - if fname[-6:] == '.class': - arg.append(os.path.join(dirname, fname)) - result = [] - os.path.walk(dir, find_class_files, result) - result.sort() - return result + static class inner + { + private inner() {} + } +} +""") -classes_1 = get_class_files(test.workpath('class1')) -classes_2 = get_class_files(test.workpath('class2')) -classes_3 = get_class_files(test.workpath('class3')) -classes_4 = get_class_files(test.workpath('class4')) -classes_5 = get_class_files(test.workpath('class5')) + + +test.run(arguments = '.') expect_1 = [ test.workpath('class1', 'com', 'other', 'Example2.class'), @@ -328,9 +334,27 @@ expect_5 = [ test.workpath('class5', 'TestSCons.class'), ] +expect_6 = [ + test.workpath('class6', 'test$1.class'), + test.workpath('class6', 'test$inner.class'), + test.workpath('class6', 'test.class'), +] + failed = None -def classes_must_match(dir, expect, got): +def get_class_files(dir): + def find_class_files(arg, dirname, fnames): + for fname in fnames: + if fname[-6:] == '.class': + arg.append(os.path.join(dirname, fname)) + result = [] + os.path.walk(dir, find_class_files, result) + result.sort() + return result + +def classes_must_match(dir, expect): + global failed + got = get_class_files(test.workpath(dir)) if expect != got: sys.stderr.write("Expected the following class files in '%s':\n" % dir) for c in expect: @@ -340,13 +364,40 @@ def classes_must_match(dir, expect, got): sys.stderr.write(' %s\n' % c) failed = 1 -classes_must_match('class1', expect_1, classes_1) -classes_must_match('class2', expect_2, classes_2) -classes_must_match('class3', expect_3, classes_3) -classes_must_match('class4', expect_4, classes_4) +def classes_must_not_exist(dir, expect): + global failed + present = filter(os.path.exists, expect) + if present: + sys.stderr.write("Found the following unexpected class files in '%s' after cleaning:\n" % dir) + for c in present: + sys.stderr.write(' %s\n' % c) + failed = 1 + +classes_must_match('class1', expect_1) +classes_must_match('class2', expect_2) +classes_must_match('class3', expect_3) +classes_must_match('class4', expect_4) +classes_must_match('class5', expect_5) +classes_must_match('class6', expect_6) test.fail_test(failed) test.up_to_date(options='--debug=explain', arguments = '.') +test.run(arguments = '-c .') + +classes_must_not_exist('class1', expect_1) +classes_must_not_exist('class2', expect_2) +classes_must_not_exist('class3', expect_3) +classes_must_not_exist('class4', expect_4) +classes_must_not_exist('class5', expect_5) +# This test case should pass, but doesn't. +# The expect_6 list contains the class files that the Java compiler +# actually creates, apparently because of the "private" instantiation +# of the "inner" class. Our parser doesn't currently detect this, so +# it doesn't know to remove that generated class file. +#classes_must_not_exist('class6', expect_6) + +test.fail_test(failed) + test.pass_test() diff --git a/test/Java/Java-1.6.py b/test/Java/Java-1.6.py index 0b4ddd7e..f2b629af 100644 --- a/test/Java/Java-1.6.py +++ b/test/Java/Java-1.6.py @@ -59,6 +59,7 @@ env.Java(target = 'class2', source = 'com/sub/bar') env.Java(target = 'class3', source = ['src1', 'src2']) env.Java(target = 'class4', source = ['src4']) env.Java(target = 'class5', source = ['src5']) +env.Java(target = 'class6', source = ['src6']) """ % locals()) test.subdir('com', @@ -68,7 +69,8 @@ test.subdir('com', 'src1', 'src2', 'src4', - 'src5') + 'src5', + 'src6') test.write(['com', 'sub', 'foo', 'Example1.java'], """\ package com.sub.foo; @@ -274,23 +276,27 @@ class TestSCons { class Foo { } """) -test.run(arguments = '.') +# Test private inner class instantiation, courtesy Tilo Prutz: +# http://scons.tigris.org/issues/show_bug.cgi?id=1594 +test.write(['src6', 'TestSCons.java'], """\ +class test +{ + test() + { + super(); + new inner(); + } -def get_class_files(dir): - def find_class_files(arg, dirname, fnames): - for fname in fnames: - if fname[-6:] == '.class': - arg.append(os.path.join(dirname, fname)) - result = [] - os.path.walk(dir, find_class_files, result) - result.sort() - return result + static class inner + { + private inner() {} + } +} +""") -classes_1 = get_class_files(test.workpath('class1')) -classes_2 = get_class_files(test.workpath('class2')) -classes_3 = get_class_files(test.workpath('class3')) -classes_4 = get_class_files(test.workpath('class4')) -classes_5 = get_class_files(test.workpath('class5')) + + +test.run(arguments = '.') expect_1 = [ test.workpath('class1', 'com', 'other', 'Example2.class'), @@ -328,9 +334,27 @@ expect_5 = [ test.workpath('class5', 'TestSCons.class'), ] +expect_6 = [ + test.workpath('class6', 'test$1.class'), + test.workpath('class6', 'test$inner.class'), + test.workpath('class6', 'test.class'), +] + failed = None -def classes_must_match(dir, expect, got): +def get_class_files(dir): + def find_class_files(arg, dirname, fnames): + for fname in fnames: + if fname[-6:] == '.class': + arg.append(os.path.join(dirname, fname)) + result = [] + os.path.walk(dir, find_class_files, result) + result.sort() + return result + +def classes_must_match(dir, expect): + global failed + got = get_class_files(test.workpath(dir)) if expect != got: sys.stderr.write("Expected the following class files in '%s':\n" % dir) for c in expect: @@ -340,13 +364,40 @@ def classes_must_match(dir, expect, got): sys.stderr.write(' %s\n' % c) failed = 1 -classes_must_match('class1', expect_1, classes_1) -classes_must_match('class2', expect_2, classes_2) -classes_must_match('class3', expect_3, classes_3) -classes_must_match('class4', expect_4, classes_4) +def classes_must_not_exist(dir, expect): + global failed + present = filter(os.path.exists, expect) + if present: + sys.stderr.write("Found the following unexpected class files in '%s' after cleaning:\n" % dir) + for c in present: + sys.stderr.write(' %s\n' % c) + failed = 1 + +classes_must_match('class1', expect_1) +classes_must_match('class2', expect_2) +classes_must_match('class3', expect_3) +classes_must_match('class4', expect_4) +classes_must_match('class5', expect_5) +classes_must_match('class6', expect_6) test.fail_test(failed) test.up_to_date(options='--debug=explain', arguments = '.') +test.run(arguments = '-c .') + +classes_must_not_exist('class1', expect_1) +classes_must_not_exist('class2', expect_2) +classes_must_not_exist('class3', expect_3) +classes_must_not_exist('class4', expect_4) +classes_must_not_exist('class5', expect_5) +# This test case should pass, but doesn't. +# The expect_6 list contains the class files that the Java compiler +# actually creates, apparently because of the "private" instantiation +# of the "inner" class. Our parser doesn't currently detect this, so +# it doesn't know to remove that generated class file. +#classes_must_not_exist('class6', expect_6) + +test.fail_test(failed) + test.pass_test() diff --git a/test/Java/multi-step.py b/test/Java/multi-step.py new file mode 100644 index 00000000..1b698385 --- /dev/null +++ b/test/Java/multi-step.py @@ -0,0 +1,567 @@ +#!/usr/bin/env python +# +# __COPYRIGHT__ +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +""" +Real-world test (courtesy Leanid Nazdrynau) of the multi-step +capabilities of the various Java Builders. +""" + +import TestSCons + +test = TestSCons.TestSCons() + +# This test requires javac and swig +ENV = test.java_ENV() + +if test.detect_tool('javac', ENV=ENV): + where_javac = test.detect('JAVAC', 'javac', ENV=ENV) +else: + where_javac = test.where_is('javac') +if not where_javac: + test.skip_test("Could not find Java javac, skipping test(s).\n") + +swig = test.where_is('swig') +if not swig: + test.skip_test('Can not find installed "swig", skipping test.\n') + + + +test.subdir(['src'], + ['src', 'HelloApplet'], + ['src', 'HelloApplet', 'com'], + ['src', 'javah'], + ['src', 'jni'], + ['src', 'server'], + ['src', 'server', 'JavaSource'], + ['src', 'server', 'JavaSource', 'com'], + ['src', 'server', 'JavaSource', 'com', 'gnu'], + ['src', 'server', 'JavaSource', 'com', 'gnu', 'scons'], + ['src', 'server', 'JavaSource', 'com', 'gnu', 'scons', 'web'], + ['src', 'server', 'JavaSource', 'com', 'gnu', 'scons', 'web', 'tools'], + ['src', 'server', 'WebContent'], + ['src', 'server', 'WebContent', 'META-INF'], + ['src', 'server', 'WebContent', 'WEB-INF'], + ['src', 'server', 'WebContent', 'WEB-INF', 'conf'], + ['src', 'server', 'WebContent', 'WEB-INF', 'lib'], + ['src', 'server', 'WebContent', 'theme']) + +test.write(['SConstruct'], """\ +import os,sys +env=Environment(tools = ['default', 'javac', 'javah']) +Export('env') +env.PrependENVPath('PATH',os.environ.get('PATH',[])) +env['INCPREFIX']='-I' +env.Append(SWIGFLAGS=['-c++','$_CPPINCFLAGS']) + +#this is for JNI +#env.Append(CCFLAGS=['/IN:/jdk/v1.3.1/include','/IN:/jdk/v1.3.1/include/win32']) + +#this for windows only C++ build +#env.Append(CXXFLAGS='-GX') + +env.Append(CPPPATH='.') + +env.BuildDir('buildout', 'src', duplicate=0) + +if sys.platform=='darwin': + env.Append(CPPPATH=['/System/Library/Frameworks/JavaVM.framework/Headers']) + +#If you do not have swig on your system please remove 'buildout/jni/SConscript' line from next call +env.SConscript(['buildout/server/JavaSource/SConscript', + 'buildout/HelloApplet/SConscript', + 'buildout/jni/SConscript', + 'buildout/javah/SConscript']) +""") + +test.write(['src', 'HelloApplet', 'Hello.html'], """\ + + + Applet Hello + + +
+ + +
+ + + +""") + +test.write(['src', 'HelloApplet', 'SConscript'], """\ +import os +Import ("env") +denv=env.Copy() +classes=denv.Java(target='classes',source=['com']) +#set correct path for jar +denv['JARCHDIR']=os.path.join(denv.Dir('.').get_abspath(),'classes') +denv.Jar('HelloApplet',classes) + + +#To sign applet you have to create keystore before and made a calls like this + +#keystore='/path/to/jarsignkey' +#denv['JARSIGNFLAGS']='-keystore '+keystore+' -storepass pass -keypass passkey' +#denv['JARSIGNALIAS']='ALIAS' +#denv['JARCOM']=[denv['JARCOM'],'$JARSIGNCOM'] + +""") + +test.write(['src', 'HelloApplet', 'com', 'Hello.java'], """\ +package com.Hello; +import java.awt.*; +import java.applet.*; + +public class Hello extends Applet { + public void paint(Graphics g) { + g.drawString("Hello from SCons signed applet",250,150); + } + } + +""") + +test.write(['src', 'javah', 'MyID.cc'], """\ +#include "MyID.h" +int getMyID() +{ + return 0; +} +""") + +test.write(['src', 'javah', 'MyID.java'], """\ +import java.util.*; +import java.io.IOException; +import java.lang.reflect.*; + +public class MyID +{ + static private long current = System.currentTimeMillis(); + static public String get() + { + current++; + return new Long( current ).toString(); + } +} +""") + +test.write(['src', 'javah', 'SConscript'], """\ +Import('env') +denv=env.Copy() +denv['JARCHDIR']=denv.Dir('.').get_abspath() +denv.Jar('myid','MyID.java') +denv.JavaH(denv.Dir('.').get_abspath(),'MyID.java') +denv.SharedLibrary('myid','MyID.cc') + +""") + +test.write(['src', 'jni', 'A.java'], """\ +package web.jni; + +import web.jni.*; + +public class A +{ +class C +{ + void echo2( String text ) + { + System.out.println( text+"aa" ); + + } +} +class B +{ + void echo( String text ) + { + System.out.println( text ); + C c = new C(); + c.echo2("from B callin C"); + } +} + public void main( String[] x) + { + B b = new B(); + b.echo("123"); + C c = new C(); + c.echo2("456"); + } +} +""") + +test.write(['src', 'jni', 'JniWrapper.cc'], """\ +#include +#include + +#include "JniWrapper.h" + + + +JniWrapper::JniWrapper( JNIEnv *pEnv ) + : mpEnv( pEnv ) +{ +} + +JniWrapper::JniWrapper( const JniWrapper& rJniWrapper ) + : mpEnv( rJniWrapper.mpEnv ) +{ +} + +JniWrapper::~JniWrapper() +{ + +} + +JniWrapper& JniWrapper::operator=( const JniWrapper& rJniWrapper ) +{ + if ( this != &rJniWrapper ) + { + mpEnv = rJniWrapper.mpEnv; + } + return *this; +} + +std::string JniWrapper::unmarshalString( jstring value ) +{ + std::string result; + if( value ) + { + const char *pStr = mpEnv->GetStringUTFChars( value, 0 ); + result = pStr; + mpEnv->ReleaseStringUTFChars( value, pStr ); + } + return result; +} + +jobject JniWrapper::marshalDouble( double value ) +{ + jclass classObject = mpEnv->FindClass( "java/lang/Double" ); + jmethodID constructorId = mpEnv->GetMethodID( classObject, "", "(D)V" ); + jobject result = mpEnv->NewObject( classObject, constructorId, value ); + + return result; +} + +jobject JniWrapper::getVectorElement( jobject values, int i ) +{ + jclass vectorClass = mpEnv->FindClass( "java/util/Vector" ); + jmethodID methodID = mpEnv->GetMethodID( vectorClass, + "elementAt", + "(I)Ljava/lang/Object;" ); + jobject result = mpEnv->CallObjectMethod( values, methodID, i ); + + return result; +} + +jobject JniWrapper::newVector() +{ + jclass vectorClass = mpEnv->FindClass( "java/util/Vector" ); + jmethodID constructorID = mpEnv->GetMethodID( vectorClass, "", "()V" ); + jobject result = mpEnv->NewObject( vectorClass, constructorID ); + + return result; +} + +void JniWrapper::addElement( jobject vector, jobject element ) +{ + jclass vectorClass = mpEnv->FindClass( "java/util/Vector" ); + jmethodID addElementMethodID = mpEnv->GetMethodID( vectorClass, + "addElement", + "(Ljava/lang/Object;)V" ); + + mpEnv->CallVoidMethod( vector, addElementMethodID, element ); +} + +jobject JniWrapper::marshalDoubleVector( const std::vector& rVector ) +{ + jobject result = newVector(); + + for ( int i = 0; i < rVector.size(); i++ ) + { + addElement( result, marshalDouble( rVector[i] ) ); + } + + return result; +} + +std::pair JniWrapper::unmarshalPairString( jobject vector ) +{ + std::pair result; + result.first = unmarshalString( (jstring)getVectorElement( vector, 0 ) ); + result.second = unmarshalString( (jstring)getVectorElement( vector, 1 ) ); + + return result; +} +""") + +test.write(['src', 'jni', 'JniWrapper.h'], """\ +#ifndef JniWrapper_h +#define JniWrapper_h + +#include +/** + * Provides routines for dealing with JNI translation etc. + */ + +class JniWrapper +{ +public: + JniWrapper( JNIEnv *pEnv ); + JniWrapper( const JniWrapper& rJniWrapper ); + virtual ~JniWrapper(); + JniWrapper& operator=( const JniWrapper& rJniWrapper ); + + + std::string unmarshalString( jstring value ); + + jstring marshalString( const std::string& value ); + + jbyteArray marshalByteArray( const std::string& value ); + + double unmarshalDouble( jobject value ); + + jobject marshalDouble( double value ); + jobject marshallStringVector( const std::vector& rMap ); + + jobject marshalDoubleVector( const std::vector& rVector ); + std::pair unmarshalPairString( jobject ); + +protected: + JNIEnv *mpEnv; + +private: + JniWrapper(); + jobject newVector(); + void addElement( jobject vector, jobject element ); + jobject getVectorElement( jobject values, int i ); + +}; + +#endif // JniWrapper_h + + +""") + +test.write(['src', 'jni', 'SConscript'], """\ +Import ("env") +denv=env.Copy() + +denv.Append(SWIGFLAGS=['-java']) +denv.SharedLibrary('scons',['JniWrapper.cc','Sample.i']) +denv['JARCHDIR']=denv.Dir('.').get_abspath() +denv.Jar(['Sample.i','A.java']) +""") + +test.write(['src', 'jni', 'Sample.h'], """\ +#include +#include + +class SampleTest +{ +public: + std::vector test1( std::pair param ) + { + std::vector result; + result.push_back(10); + return result; + } +}; + +""") + +test.write(['src', 'jni', 'Sample.i'], """\ +%module Sample + +%{ +#include "Sample.h" +#include "JniWrapper.h" +%} + +%typemap(jni) std::vector, std::vector& "jobject" +%typemap(jtype) std::vector, std::vector& "java.util.Vector" +%typemap(jstype) std::vector, std::vector& "java.util.Vector" + +// return a Vector of Doubles +%typemap(javaout) std::vector { + return $jnicall; +} +%typemap(out) std::vector { + JniWrapper JniWrapper(jenv); + $result = JniWrapper.marshalDoubleVector( $1 ); +} + +/********************************************************************* + * + * Pairs of String (IN/OUT) + * + *********************************************************************/ +%typemap(jni) std::pair, const std::pair& "jobject" +%typemap(jtype) std::pair, const std::pair& "java.util.Vector" +%typemap(jstype) std::pair, const std::pair& "java.util.Vector" +%typemap(javain) std::pair, const std::pair& "$javainput" + +// pass in by reference a Vector of std::string +%typemap(in) const std::pair& { + $1 = new std::pair(); + JniWrapper JniWrapper(jenv); + *($1) = JniWrapper.unmarshalPairString( $input ); +} + +//cleanup +%typemap(freearg) const std::pair& { + delete $1; +} + +%include "Sample.h" + +// generate:Sample.java +// generate:SampleJni.java +// generate:SampleTest.java +""") + +test.write(['src', 'server', 'JavaSource', 'SConscript'], """\ +import os +Import ("env") +classes=env.Java(target='classes',source=['com']) + +HelloApplet=os.path.join('#/buildout/HelloApplet/HelloApplet.jar') +env['WARXFILES']=['SConscript','.cvsignore'] +env['WARXDIRS']=['CVS'] +#env.War('scons',[classes,Dir('../WebContent'),HelloApplet]) +""") + +test.write(['src', 'server', 'JavaSource', 'com', 'gnu', 'scons', 'web', 'tools', 'Bool.java'], """\ +package com.gnu.scons.web.tools; +public class Bool { + boolean flag; + + public Bool() + { + flag = false; + } + + public Bool( boolean aFlag ) + { + flag = aFlag; + } + + public boolean booleanValue() + { + return flag; + } +} +""") + +test.write(['src', 'server', 'JavaSource', 'com', 'gnu', 'scons', 'web', 'tools', 'StringUtils.java'], """\ +package com.gnu.scons.web.tools; + +import java.util.Iterator; +import java.util.Map; + +public class StringUtils +{ + public static String toPercent( String value ) + { + if ( value.equals("") ) + { + return ""; + } + else + { + return value + "%"; + } + } + +} +""") + +test.write(['src', 'server', 'WebContent', 'index.html'], """\ + + + + +index.html + + +

go?action=home

+ + +""") + +test.write(['src', 'server', 'WebContent', 'META-INF', 'MANIFEST.MF'], """\ +Manifest-Version: 1.0 +Class-Path: + +""") + +test.write(['src', 'server', 'WebContent', 'WEB-INF', 'web.xml'], """\ + + + + scons + + WebExample + WebExample + com.gnu.scons.web.tool.WebExample + + + WebExample + /go + + + index.html + index.htm + + +""") + +test.write(['src', 'server', 'WebContent', 'WEB-INF', 'conf', 'app.properties'], """\ +logging = webExample.Example +""") + +test.write(['src', 'server', 'WebContent', 'theme', 'Master.css'], """\ +body +{ + font-family: Helvetica,Sans-Serif; + font-size: 11pt; +} +""") + +test.run(arguments = '.') + +test.must_exist(['buildout', 'javah', 'myid.jar']) +test.must_exist(['buildout', 'javah', 'MyID', 'MyID.class']) + +test.must_exist(['buildout', 'jni', 'Sample.class']) +test.must_exist(['buildout', 'jni', 'Sample.java']) +test.must_exist(['buildout', 'jni', 'SampleJNI.class']) +test.must_exist(['buildout', 'jni', 'SampleJNI.java']) +test.must_exist(['buildout', 'jni', 'SampleTest.class']) +test.must_exist(['buildout', 'jni', 'SampleTest.java']) + +test.up_to_date(arguments = '.') + +test.pass_test() diff --git a/test/Java/source-files.py b/test/Java/source-files.py new file mode 100644 index 00000000..8d2506fb --- /dev/null +++ b/test/Java/source-files.py @@ -0,0 +1,127 @@ +#!/usr/bin/env python +# +# __COPYRIGHT__ +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +""" +Verify that we can pass the Java() builder explicit lists of .java +files as sources. +""" + +import TestSCons + +_python_ = TestSCons._python_ + +test = TestSCons.TestSCons() + +ENV = test.java_ENV() + +if test.detect_tool('javac', ENV=ENV): + where_javac = test.detect('JAVAC', 'javac', ENV=ENV) +else: + where_javac = test.where_is('javac') +if not where_javac: + test.skip_test("Could not find Java javac, skipping test(s).\n") + + +test.write('SConstruct', """ +env = Environment(tools = ['javac', 'javah'], + JAVAC = r'%(where_javac)s') +env.Java(target = 'class1', source = 'com/Example1.java') +env.Java(target = 'class2', source = ['com/Example2.java', 'com/Example3.java']) +""" % locals()) + +test.subdir('com', 'src') + +test.write(['com', 'Example1.java'], """\ +package com; + +public class Example1 +{ + + public static void main(String[] args) + { + + } + +} +""") + +test.write(['com', 'Example2.java'], """\ +package com; + +public class Example2 +{ + + public static void main(String[] args) + { + + } + +} +""") + +test.write(['com', 'Example3.java'], """\ +package com; + +public class Example3 +{ + + public static void main(String[] args) + { + + } + +} +""") + +test.write(['com', 'Example4.java'], """\ +package com; + +public class Example4 +{ + + public static void main(String[] args) + { + + } + +} +""") + +test.run(arguments = '.') + +test.must_exist (['class1', 'com', 'Example1.class']) +test.must_not_exist(['class1', 'com', 'Example2.class']) +test.must_not_exist(['class1', 'com', 'Example3.class']) +test.must_not_exist(['class1', 'com', 'Example4.class']) + +test.must_not_exist(['class2', 'com', 'Example1.class']) +test.must_exist (['class2', 'com', 'Example2.class']) +test.must_exist (['class2', 'com', 'Example3.class']) +test.must_not_exist(['class2', 'com', 'Example4.class']) + +test.up_to_date(arguments = '.') + +test.pass_test() diff --git a/test/Java/swig-dependencies.py b/test/Java/swig-dependencies.py new file mode 100644 index 00000000..c6961f27 --- /dev/null +++ b/test/Java/swig-dependencies.py @@ -0,0 +1,135 @@ +#!/usr/bin/env python +# +# __COPYRIGHT__ +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +""" +Verify that dependencies on SWIG-generated .java files work correctly. + +Test case courtesy Jonathan (toolshed@tigris.org). +""" + +import TestSCons + +test = TestSCons.TestSCons() + +ENV = test.java_ENV() +if test.detect_tool('javac', ENV=ENV): + where_javac = test.detect('JAVAC', 'javac', ENV=ENV) +else: + where_javac = test.where_is('javac') +if not where_javac: + test.skip_test("Could not find Java javac, skipping test(s).\n") + +if test.detect_tool('jar', ENV=ENV): + where_jar = test.detect('JAR', 'jar', ENV=ENV) +else: + where_jar = test.where_is('jar') +if not where_jar: + test.skip_test("Could not find Java jar, skipping test(s).\n") + + +test.subdir(['foo'], + ['java'], + ['java', 'build']) + +test.write(['SConstruct'], """\ +import os + +env = Environment(ENV = os.environ) + +env.Append(CPPFLAGS = ' -g -Wall') + +Export('env') + +SConscript('#foo/SConscript') +SConscript('#java/SConscript') +""") + +test.write(['foo', 'SConscript'], """\ +Import('env') + +env.SharedLibrary('foo', 'foo.cpp') +""") + +test.write(['foo', 'foo.cpp'], """\ +#include "foo.h" + +int fooAdd(int a, int b) { + return a + b; +} +""") + +test.write(['foo', 'foo.h'], """\ +int fooAdd(int, int); +""") + +test.write(['java', 'Java_foo_interface.i'], """\ +#include "foo.h" + +%module foopack +""") + +test.write(['java', 'SConscript'], """\ +import os + +Import('env') + +# unnecessary? +env = env.Copy() + +env.Prepend(CPPPATH = ['#foo',]) + +libadd = ['foo',] + +libpath = ['#foo',] + +#swigflags = '-c++ -java -Wall -package foopack -Ifoo' +swigflags = '-c++ -java -Wall -Ifoo' + +Java_foo_interface = env.SharedLibrary( + 'Java_foo_interface', + 'Java_foo_interface.i', + LIBS = libadd, + LIBPATH = libpath, + SWIGFLAGS = swigflags, + SWIGOUTDIR = Dir('build'), + SWIGCXXFILESUFFIX = "_wrap.cpp") + +foopack_jar_javac = env.Java('classes', 'build') + +env['JARCHDIR'] = 'java/classes' +foopack_jar = env.Jar(target = 'foopack.jar', source = 'classes') +""") + +test.run(arguments = '.') + +#test.must_exist(['java', 'classes', 'foopack', 'foopack.class']) +#test.must_exist(['java', 'classes', 'foopack', 'foopackJNI.class']) +test.must_exist(['java', 'classes', 'foopack.class']) +test.must_exist(['java', 'classes', 'foopackJNI.class']) + +test.up_to_date(arguments = '.') + +test.pass_test() diff --git a/test/LEX/LEXFLAGS.py b/test/LEX/LEXFLAGS.py index b6a06fa1..e72fa9e8 100644 --- a/test/LEX/LEXFLAGS.py +++ b/test/LEX/LEXFLAGS.py @@ -35,36 +35,42 @@ _exe = TestSCons._exe test = TestSCons.TestSCons() +test.subdir('in') + test.write('mylex.py', """ import getopt import string import sys -cmd_opts, args = getopt.getopt(sys.argv[1:], 'tx', []) +cmd_opts, args = getopt.getopt(sys.argv[1:], 'I:tx', []) opt_string = '' +i_arguments = '' for opt, arg in cmd_opts: - opt_string = opt_string + ' ' + opt + if opt == '-I': i_arguments = i_arguments + ' ' + arg + else: opt_string = opt_string + ' ' + opt for a in args: contents = open(a, 'rb').read() - sys.stdout.write(string.replace(contents, 'LEXFLAGS', opt_string)) + contents = string.replace(contents, 'LEXFLAGS', opt_string) + contents = string.replace(contents, 'I_ARGS', i_arguments) + sys.stdout.write(contents) sys.exit(0) """) test.write('SConstruct', """ env = Environment(LEX = r'%(_python_)s mylex.py', - LEXFLAGS = '-x', + LEXFLAGS = '-x -I${TARGET.dir} -I${SOURCE.dir}', tools=['default', 'lex']) -env.CFile(target = 'aaa', source = 'aaa.l') +env.CFile(target = 'out/aaa', source = 'in/aaa.l') """ % locals()) -test.write('aaa.l', "aaa.l\nLEXFLAGS\n") +test.write(['in', 'aaa.l'], "aaa.l\nLEXFLAGS\nI_ARGS\n") test.run('.', stderr = None) # Read in with mode='r' because mylex.py implicitley wrote to stdout # with mode='w'. -test.must_match('aaa.c', "aaa.l\n -x -t\n", mode='r') +test.must_match(['out', 'aaa.c'], "aaa.l\n -x -t\n out in\n", mode='r') diff --git a/test/SWIG/SWIG.py b/test/SWIG/SWIG.py index dfee5ef2..491cb7c7 100644 --- a/test/SWIG/SWIG.py +++ b/test/SWIG/SWIG.py @@ -28,26 +28,15 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" Verify that the swig tool generates file names that we expect. """ -import os -import string -import sys import TestSCons -if sys.platform =='darwin': - # change to make it work with stock OS X python framework - # we can't link to static libpython because there isn't one on OS X - # so we link to a framework version. However, testing must also - # use the same version, or else you get interpreter errors. - python = "/System/Library/Frameworks/Python.framework/Versions/Current/bin/python" - _python_ = '"' + python + '"' -else: - _python_ = TestSCons._python_ - _exe = TestSCons._exe _obj = TestSCons._obj test = TestSCons.TestSCons() +_python_ = test.get_quoted_platform_python() + test.write('myswig.py', r""" diff --git a/test/SWIG/SWIGFLAGS.py b/test/SWIG/SWIGFLAGS.py new file mode 100644 index 00000000..22c311b0 --- /dev/null +++ b/test/SWIG/SWIGFLAGS.py @@ -0,0 +1,69 @@ +#!/usr/bin/env python +# +# __COPYRIGHT__ +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +""" +Verify that we can use ${SOURCE} expansions in $SWIGFLAGS. +""" + +import sys + +import TestSCons + +test = TestSCons.TestSCons() + +swig = test.where_is('swig') + +if not swig: + test.skip_test('Can not find installed "swig", skipping test.\n') + + + +test.subdir('src') + +test.write(['src', 'foo.i'], """\ +%module foo + +%include bar.i +""") + +test.write(['src', 'bar.i'], """\ +%module bar +""") + +test.write('SConstruct', """ +# Note that setting the -I option in $SWIGFLAGS is not good and the +# documentation says to use $SWIGPATH. This is just for testing. +env = Environment(SWIGFLAGS='-python -I${SOURCE.dir}') +env.CFile(target = 'foo', source = ['src/foo.i']) +""") + +test.run() + +test.up_to_date(arguments = "foo_wrap.c") + + + +test.pass_test() diff --git a/test/SWIG/SWIGOUTDIR.py b/test/SWIG/SWIGOUTDIR.py index 69d535cb..b638a3bd 100644 --- a/test/SWIG/SWIGOUTDIR.py +++ b/test/SWIG/SWIGOUTDIR.py @@ -29,10 +29,21 @@ Verify that use of the $SWIGOUTDIR variable causes SCons to recognize that Java files are created in the specified output directory. """ +import sys + import TestSCons test = TestSCons.TestSCons() +test = TestSCons.TestSCons() + +swig = test.where_is('swig') + +if not swig: + test.skip_test('Can not find installed "swig", skipping test.\n') + + + test.write(['SConstruct'], """\ env = Environment(tools = ['default', 'swig']) diff --git a/test/SWIG/SWIGPATH.py b/test/SWIG/SWIGPATH.py new file mode 100644 index 00000000..dd2db47e --- /dev/null +++ b/test/SWIG/SWIGPATH.py @@ -0,0 +1,91 @@ +#!/usr/bin/env python +# +# __COPYRIGHT__ +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +""" +Verify that use of SWIGPATH finds dependency files in subdirectories. +""" + +import TestSCons + +test = TestSCons.TestSCons() + +swig = test.where_is('swig') + +if not swig: + test.skip_test('Can not find installed "swig", skipping test.\n') + +_python_ = test.get_quoted_platform_python() + + + +test.subdir('inc1', 'inc2') + +test.write(['inc2', 'dependency.i'], """\ +%module dependency +""") + +test.write("dependent.i", """\ +%module dependent + +%include dependency.i +""") + +test.write('SConstruct', """ +foo = Environment(SWIGFLAGS='-python', + SWIGPATH=['inc1', 'inc2']) +swig = foo.Dictionary('SWIG') +bar = foo.Clone(SWIG = r'%(_python_)s wrapper.py ' + swig) +foo.CFile(target = 'dependent', source = ['dependent.i']) +""" % locals()) + +test.run() + +test.up_to_date(arguments = "dependent_wrap.c") + +test.write(['inc1', 'dependency.i'], """\ +%module dependency + +extern char *dependency_1(); +""") + +test.not_up_to_date(arguments = "dependent_wrap.c") + +test.write(['inc2', 'dependency.i'], """\ +%module dependency +extern char *dependency_2(); +""") + +test.up_to_date(arguments = "dependent_wrap.c") + +test.unlink(['inc1', 'dependency.i']) + +test.not_up_to_date(arguments = "dependent_wrap.c") + +test.up_to_date(arguments = "dependent_wrap.c") + + + +test.pass_test() diff --git a/test/SWIG/build-dir.py b/test/SWIG/build-dir.py new file mode 100644 index 00000000..593a26a6 --- /dev/null +++ b/test/SWIG/build-dir.py @@ -0,0 +1,167 @@ +#!/usr/bin/env python +# +# __COPYRIGHT__ +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +""" +Make sure SWIG works when a BuildDir (or build_dir) is used. + +Test case courtesy Joe Maruszewski. +""" + +import os.path +import sys + +import TestSCons + +test = TestSCons.TestSCons() + +# swig-python expects specific filenames. +# the platform specific suffix won't necessarily work. +if sys.platform == 'win32': + _dll = '.dll' +else: + _dll = '.so' + +test.subdir(['source']) + +python_include_dir = test.get_python_inc() + +Python_h = os.path.join(python_include_dir, 'Python.h') + +if not os.path.exists(Python_h): + test.skip_test('Can not find %s, skipping test.\n' % Python_h) + +python_frameworks_flags = test.get_python_frameworks_flags() + +test.write(['SConstruct'], """\ +# +# Create the build environment. +# +env = Environment(CPPPATH = [".", r'%(python_include_dir)s'], + CPPDEFINES = "NDEBUG", + SWIGFLAGS = ["-python", "-c++"], + SWIGCXXFILESUFFIX = "_wrap.cpp", + LDMODULEPREFIX='_', + LDMODULESUFFIX='%(_dll)s', + FRAMEWORKSFLAGS='%(python_frameworks_flags)s') + +import sys +if sys.version[0] == '1': + # SWIG requires the -classic flag on pre-2.0 Python versions. + env.Append(SWIGFLAGS = '-classic') + +Export("env") + +# +# Build the libraries. +# +SConscript("source/SConscript", build_dir = "build") +""" % locals()) + +test.write(['source', 'SConscript'], """\ +Import("env") +lib = env.SharedLibrary("_linalg", + "linalg.i", + SHLIBPREFIX = "", + SHLIBSUFFIX = ".pyd") +""") + +test.write(['source', 'Vector.hpp'], """\ +class Vector +{ + public: + Vector(int size = 0) : _size(size) + { + _v = new double[_size]; + for (int i = 0; i < _size; ++i) + _v[i] = 0.0; + } + + ~Vector() { delete [] _v; } + + int size() const { return _size; } + + double& operator[](int key) { return _v[key]; } + double const& operator[](int key) const { return _v[key]; } + + private: + int _size; + double* _v; +}; +""") + +test.write(['source', 'linalg.i'], """\ +%module linalg +%{ +#include +#include "Vector.hpp" +%} + + +class Vector +{ +public: + Vector(int n = 0); + ~Vector(); + + %extend + { + const char* __str__() { return "linalg.Vector()"; } + int __len__() { return $self->size(); } + double __getitem__(int key) { return $self->operator[](key); } + void __setitem__(int key, double value) { $self->operator[](key) = value; } + + %pythoncode %{ + def __iter__(self): + for i in xrange(len(self)): + yield self[i] + %} + } +}; +""") + +test.write(['source', 'test.py'], """\ +#!/usr/bin/env python +import linalg + + +x = linalg.Vector(5) +print x + +x[1] = 99.5 +x[3] = 8.3 +x[4] = 11.1 + + +for i, v in enumerate(x): + print "\tx[%d] = %g" % (i, v) + +""") + +test.run(arguments = '.') + +test.up_to_date(arguments = '.') + +test.pass_test() diff --git a/test/SWIG/implicit-dependencies.py b/test/SWIG/implicit-dependencies.py index 81e3cf9b..9b3eb8e3 100644 --- a/test/SWIG/implicit-dependencies.py +++ b/test/SWIG/implicit-dependencies.py @@ -32,17 +32,6 @@ import sys import TestSCons -if sys.platform =='darwin': - # change to make it work with stock OS X python framework - # we can't link to static libpython because there isn't one on OS X - # so we link to a framework version. However, testing must also - # use the same version, or else you get interpreter errors. - python = "/System/Library/Frameworks/Python.framework/Versions/Current/bin/python" - _python_ = '"' + python + '"' -else: - python = TestSCons.python - _python_ = TestSCons._python_ - test = TestSCons.TestSCons() swig = test.where_is('swig') @@ -50,10 +39,9 @@ swig = test.where_is('swig') if not swig: test.skip_test('Can not find installed "swig", skipping test.\n') +_python_ = test.get_quoted_platform_python() -version = sys.version[:3] # see also sys.prefix documentation - test.write("dependency.i", """\ %module dependency diff --git a/test/SWIG/live.py b/test/SWIG/live.py index d319af78..5070d8e2 100644 --- a/test/SWIG/live.py +++ b/test/SWIG/live.py @@ -34,17 +34,6 @@ import sys import TestSCons -if sys.platform =='darwin': - # change to make it work with stock OS X python framework - # we can't link to static libpython because there isn't one on OS X - # so we link to a framework version. However, testing must also - # use the same version, or else you get interpreter errors. - python = "/System/Library/Frameworks/Python.framework/Versions/Current/bin/python" - _python_ = '"' + python + '"' -else: - python = TestSCons.python - _python_ = TestSCons._python_ - # swig-python expects specific filenames. # the platform specific suffix won't necessarily work. if sys.platform == 'win32': @@ -59,29 +48,22 @@ swig = test.where_is('swig') if not swig: test.skip_test('Can not find installed "swig", skipping test.\n') +python = test.get_platform_python() +_python_ = test.get_quoted_platform_python() -version = sys.version[:3] # see also sys.prefix documentation # handle testing on other platforms: ldmodule_prefix = '_' -frameworks = '' -platform_sys_prefix = sys.prefix -if sys.platform == 'darwin': - # OS X has a built-in Python but no static libpython - # so you should link to it using apple's 'framework' scheme. - # (see top of file for further explanation) - frameworks = '-framework Python' - platform_sys_prefix = '/System/Library/Frameworks/Python.framework/Versions/%s/' % version - -python_include_dir = os.path.join(platform_sys_prefix, - 'include', - 'python' + version) +python_include_dir = test.get_python_inc() + Python_h = os.path.join(python_include_dir, 'Python.h') if not os.path.exists(Python_h): test.skip_test('Can not find %s, skipping test.\n' % Python_h) + +python_frameworks_flags = test.get_python_frameworks_flags() test.write("wrapper.py", """import os @@ -96,7 +78,7 @@ foo = Environment(SWIGFLAGS='-python', CPPPATH='%(python_include_dir)s/', LDMODULEPREFIX='%(ldmodule_prefix)s', LDMODULESUFFIX='%(_dll)s', - FRAMEWORKSFLAGS='%(frameworks)s', + FRAMEWORKSFLAGS='%(python_frameworks_flags)s', ) import sys diff --git a/test/SWIG/noproxy.py b/test/SWIG/noproxy.py index c0f6da61..8b0adb02 100644 --- a/test/SWIG/noproxy.py +++ b/test/SWIG/noproxy.py @@ -33,17 +33,6 @@ import sys import TestSCons -if sys.platform =='darwin': - # change to make it work with stock OS X python framework - # we can't link to static libpython because there isn't one on OS X - # so we link to a framework version. However, testing must also - # use the same version, or else you get interpreter errors. - python = "/System/Library/Frameworks/Python.framework/Versions/Current/bin/python" - _python_ = '"' + python + '"' -else: - python = TestSCons.python - _python_ = TestSCons._python_ - # swig-python expects specific filenames. # the platform specific suffix won't necessarily work. if sys.platform == 'win32': @@ -58,21 +47,14 @@ swig = test.where_is('swig') if not swig: test.skip_test('Can not find installed "swig", skipping test.\n') - - -version = sys.version[:3] # see also sys.prefix documentation +_python_ = test.get_quoted_platform_python() # handle testing on other platforms: ldmodule_prefix = '_' -frameworks = '' -platform_sys_prefix = sys.prefix -if sys.platform == 'darwin': - # OS X has a built-in Python but no static libpython - # so you should link to it using apple's 'framework' scheme. - # (see top of file for further explanation) - frameworks = '-framework Python' - platform_sys_prefix = '/System/Library/Frameworks/Python.framework/Versions/%s/' % version +python_include_dir = test.get_python_inc() + +python_frameworks_flags = test.get_python_frameworks_flags() test.write("dependency.i", """\ %module dependency @@ -86,10 +68,10 @@ test.write("dependent.i", """\ test.write('SConstruct', """ foo = Environment(SWIGFLAGS=['-python', '-noproxy'], - CPPPATH='%(platform_sys_prefix)s/include/python%(version)s/', + CPPPATH='%(python_include_dir)s', LDMODULEPREFIX='%(ldmodule_prefix)s', LDMODULESUFFIX='%(_dll)s', - FRAMEWORKSFLAGS='%(frameworks)s', + FRAMEWORKSFLAGS='%(python_frameworks_flags)s', ) swig = foo.Dictionary('SWIG') diff --git a/test/SWIG/remove-modules.py b/test/SWIG/remove-modules.py index f5d4010f..5f15dcf9 100644 --- a/test/SWIG/remove-modules.py +++ b/test/SWIG/remove-modules.py @@ -50,27 +50,17 @@ if not swig: -version = sys.version[:3] # see also sys.prefix documentation - # handle testing on other platforms: ldmodule_prefix = '_' -frameworks = '' -platform_sys_prefix = sys.prefix -if sys.platform == 'darwin': - # OS X has a built-in Python but no static libpython - # so you should link to it using apple's 'framework' scheme. - # (see top of file for further explanation) - frameworks = '-framework Python' - platform_sys_prefix = '/System/Library/Frameworks/Python.framework/Versions/%s/' % version - -python_include_dir = os.path.join(platform_sys_prefix, - 'include', - 'python' + version) +python_include_dir = test.get_python_inc() + Python_h = os.path.join(python_include_dir, 'Python.h') if not os.path.exists(Python_h): test.skip_test('Can not find %s, skipping test.\n' % Python_h) + +python_frameworks_flags = test.get_python_frameworks_flags() test.write("module.i", """\ @@ -79,10 +69,10 @@ test.write("module.i", """\ test.write('SConstruct', """ foo = Environment(SWIGFLAGS='-python', - CPPPATH='%(platform_sys_prefix)s/include/python%(version)s/', + CPPPATH='%(python_include_dir)s', LDMODULEPREFIX='%(ldmodule_prefix)s', LDMODULESUFFIX='%(_dll)s', - FRAMEWORKSFLAGS='%(frameworks)s', + FRAMEWORKSFLAGS='%(python_frameworks_flags)s', ) import sys diff --git a/test/Scanner/generated.py b/test/Scanner/generated.py index 99b57871..2dfd3226 100644 --- a/test/Scanner/generated.py +++ b/test/Scanner/generated.py @@ -232,12 +232,13 @@ for k in fromdict.keys(): # do env.subst on: # $RMIC $RMICFLAGS -d ${TARGET.attributes.java_lookupdir} ... # When $TARGET is None, so $TARGET.attributes would throw an - # exception. + # exception, which SCons would turn into a UserError. They're + # not important for this test, so just catch 'em. f = fromdict[k] - if SCons.Util.is_String(f) and \ - string.find(f, "TARGET") == -1 and \ - string.find(f, "SOURCE") == -1: + try: todict[k] = env.subst(f) + except SCons.Errors.UserError: + pass todict["CFLAGS"] = fromdict["CPPFLAGS"] + " " + \ string.join(map(lambda x: "-I" + x, env["CPPPATH"])) + " " + \ string.join(map(lambda x: "-L" + x, env["LIBPATH"])) diff --git a/test/TEX/auxiliaries.py b/test/TEX/auxiliaries.py index 39984b3b..e189d574 100644 --- a/test/TEX/auxiliaries.py +++ b/test/TEX/auxiliaries.py @@ -124,7 +124,7 @@ ps_output_1 = test.read(['build', 'docs', 'test.ps']) # Adding blank lines will cause SCons to re-run the builds, but the # actual contents of the output files should be the same modulo -# the CreationDate header. +# the CreationDate header and some other PDF garp. test.write(['docs', 'test.tex'], tex_input + "\n\n\n") test.run(stderr=None) @@ -137,7 +137,19 @@ ps_output_2 = test.read(['build', 'docs', 'test.ps']) pdf_output_1 = test.normalize_pdf(pdf_output_1) pdf_output_2 = test.normalize_pdf(pdf_output_2) -assert pdf_output_1 == pdf_output_2, test.diff_substr(pdf_output_1, pdf_output_2, 80, 80) +if pdf_output_1 != pdf_output_2: + import sys + test.write(['build', 'docs', 'test.normalized.1.pdf'], pdf_output_1) + test.write(['build', 'docs', 'test.normalized.2.pdf'], pdf_output_2) + sys.stdout.write("***** 1 and 2 are different!\n") + sys.stdout.write(test.diff_substr(pdf_output_1, pdf_output_2, 80, 80) + '\n') + sys.stdout.write("Output from run 1:\n") + sys.stdout.write(test.stdout(-1) + '\n') + sys.stdout.write("Output from run 2:\n") + sys.stdout.write(test.stdout() + '\n') + sys.stdout.flush() + test.fail_test() + assert ps_output_1 == ps_output_2, test.diff_substr(ps_output_1, ps_output_2, 80, 80) diff --git a/test/TEX/bibtex-latex-rerun.py b/test/TEX/bibtex-latex-rerun.py index a0ba5c2b..91917133 100644 --- a/test/TEX/bibtex-latex-rerun.py +++ b/test/TEX/bibtex-latex-rerun.py @@ -98,13 +98,24 @@ pdf_output_3 = test.read('bibtest.pdf') # If the PDF file is now different than the second run, modulo the -# creation timestamp and the ID, then something else odd has happened, -# so fail. +# creation timestamp and the ID and some other PDF garp, then something +# else odd has happened, so fail. pdf_output_2 = test.normalize_pdf(pdf_output_2) pdf_output_3 = test.normalize_pdf(pdf_output_3) -assert pdf_output_2 == pdf_output_3, test.diff_substr(pdf_output_2, pdf_output_3, 80, 80) +if pdf_output_2 != pdf_output_3: + import sys + test.write('bibtest.normalized.2.pdf', pdf_output_2) + test.write('bibtest.normalized.3.pdf', pdf_output_3) + sys.stdout.write("***** 2 and 3 are different!\n") + sys.stdout.write(test.diff_substr(pdf_output_2, pdf_output_3, 80, 80) + '\n') + sys.stdout.write("Output from run 2:\n") + sys.stdout.write(test.stdout(-2) + '\n') + sys.stdout.write("Output from run 3:\n") + sys.stdout.write(test.stdout() + '\n') + sys.stdout.flush() + test.fail_test() diff --git a/test/YACC/YACCFLAGS.py b/test/YACC/YACCFLAGS.py index b7e2167b..91b391b8 100644 --- a/test/YACC/YACCFLAGS.py +++ b/test/YACC/YACCFLAGS.py @@ -42,37 +42,43 @@ else: test = TestSCons.TestSCons() +test.subdir('in') + test.write('myyacc.py', """ import getopt import string import sys -cmd_opts, args = getopt.getopt(sys.argv[1:], 'o:x', []) +cmd_opts, args = getopt.getopt(sys.argv[1:], 'o:I:x', []) output = None opt_string = '' +i_arguments = '' for opt, arg in cmd_opts: if opt == '-o': output = open(arg, 'wb') + elif opt == '-I': i_arguments = i_arguments + ' ' + arg else: opt_string = opt_string + ' ' + opt for a in args: contents = open(a, 'rb').read() - output.write(string.replace(contents, 'YACCFLAGS', opt_string)) + contents = string.replace(contents, 'YACCFLAGS', opt_string) + contents = string.replace(contents, 'I_ARGS', i_arguments) + output.write(contents) output.close() sys.exit(0) """) test.write('SConstruct', """ env = Environment(YACC = r'%(_python_)s myyacc.py', - YACCFLAGS = '-x', + YACCFLAGS = '-x -I${TARGET.dir} -I${SOURCE.dir}', tools=['yacc', '%(linker)s', '%(compiler)s']) -env.CFile(target = 'aaa', source = 'aaa.y') +env.CFile(target = 'out/aaa', source = 'in/aaa.y') """ % locals()) -test.write('aaa.y', "aaa.y\nYACCFLAGS\n") +test.write(['in', 'aaa.y'], "aaa.y\nYACCFLAGS\nI_ARGS\n") test.run('.', stderr = None) -test.must_match('aaa.c', "aaa.y\n -x\n") +test.must_match(['out', 'aaa.c'], "aaa.y\n -x\n out in\n") diff --git a/test/import.py b/test/import.py index a26d745f..9c5d3afb 100644 --- a/test/import.py +++ b/test/import.py @@ -29,6 +29,7 @@ Verify that we can import and use the contents of Platform and Tool modules directly. """ +import os import re import sys @@ -36,6 +37,14 @@ import TestSCons test = TestSCons.TestSCons() +# Before executing the any of the platform or tool modules, add some +# null entries to the environment $PATH variable to make sure there's +# no code that tries to index elements from the list before making sure +# they're non-null. +# (This was a problem in checkpoint release 0.97.d020070809.) +os.environ['PATH'] = os.pathsep + os.environ['PATH'] + \ + os.pathsep + os.pathsep + '/no/such/dir' + os.pathsep + SConstruct_path = test.workpath('SConstruct') platforms = [ @@ -216,6 +225,7 @@ env = Environment(tools = ['%(tool)s']) import SCons.Tool.%(tool)s env = Environment() +SCons.Tool.%(tool)s.exists(env) SCons.Tool.%(tool)s.generate(env) """ diff --git a/test/long-lines.py b/test/long-lines.py index 1c501e35..340cd9ad 100644 --- a/test/long-lines.py +++ b/test/long-lines.py @@ -46,6 +46,13 @@ elif sys.platform == 'cygwin': arflag = 'o' linkflag_init = '-L' + test.workpath() linkflag = ' -L' + test.workpath() +elif sys.platform in ('darwin', 'irix6'): + lib_shared_dll = 'libshared' + TestSCons._dll + lib_static_lib = 'libstatic.a' + arflag_init = 'r' + arflag = 'v' + linkflag_init = '-L' + test.workpath() + linkflag = ' -L' + test.workpath() else: lib_shared_dll = 'libshared.so' lib_static_lib = 'libstatic.a' diff --git a/test/option--random.py b/test/option--random.py index 8c7ef1e0..eebd34ee 100644 --- a/test/option--random.py +++ b/test/option--random.py @@ -64,7 +64,7 @@ test.run(arguments = '-n -Q') non_random_output = test.stdout() tries = 0 -max_tries = 3 +max_tries = 10 while test.stdout() == non_random_output: if tries >= max_tries: print "--random generated the non-random output %s times!" % max_tries @@ -82,7 +82,7 @@ test.run(arguments = '-n -Q') non_random_output = test.stdout() tries = 0 -max_tries = 3 +max_tries = 10 while test.stdout() == non_random_output: if tries >= max_tries: print "--random generated the non-random output %s times!" % max_tries diff --git a/test/option/debug-time.py b/test/option/debug-time.py index bf18b97d..e8873cfb 100644 --- a/test/option/debug-time.py +++ b/test/option/debug-time.py @@ -117,6 +117,7 @@ scons_time = get_scons_time(stdout) command_time = get_command_time(stdout) failures = [] +warnings = [] if not within_tolerance(expected_command_time, command_time, 0.01): failures.append("""\ @@ -134,15 +135,21 @@ outside of the 1%% tolerance. """ % locals()) if not within_tolerance(total_time, expected_total_time, 0.15): - failures.append("""\ -SCons -j1 reported total build time of %(total_time)s, + # This tolerance check seems empirically to work fine if there's + # a light load on the system, but on a heavily loaded system the + # timings get screwy and it can fail frequently. Some obvious + # attempts to work around the problem didn't, so just treat it as + # a warning for now. + warnings.append("""\ +Warning: SCons -j1 reported total build time of %(total_time)s, but the actual measured build time was %(expected_total_time)s (end-to-end time of %(complete_time)s less Python overhead of %(overhead)s), outside of the 15%% tolerance. """ % locals()) +if failures or warnings: + print string.join([test.stdout()] + failures + warnings, '\n') if failures: - print string.join([test.stdout()] + failures, '\n') test.fail_test(1) test.run(arguments = "--debug=time . SLEEP=0") diff --git a/test/option/tree-all.py b/test/option/tree-all.py index 92b90652..ec7c7d89 100644 --- a/test/option/tree-all.py +++ b/test/option/tree-all.py @@ -122,14 +122,14 @@ tree3 = """ +-. +-Bar.c +-Bar.ooo - | +-[Bar.c] + | +-Bar.c | +-Bar.h | +-Foo.h +-Foo.c +-Foo.ooo - | +-[Foo.c] - | +-[Foo.h] - | +-[Bar.h] + | +-Foo.c + | +-Foo.h + | +-Bar.h +-Foo.xxx | +-[Foo.ooo] | +-[Bar.ooo] diff --git a/test/option/tree-derived.py b/test/option/tree-derived.py index a10faa23..3ccada8e 100644 --- a/test/option/tree-derived.py +++ b/test/option/tree-derived.py @@ -98,8 +98,8 @@ dtree3 = """ +-bar.ooo +-foo.ooo +-foo.xxx - +-[foo.ooo] - +-[bar.ooo] + +-foo.ooo + +-bar.ooo """ test.run(arguments = "--tree=derived,prune .") diff --git a/test/packaging/msi/file-placement.py b/test/packaging/msi/file-placement.py index 08b0ba65..c2aaf356 100644 --- a/test/packaging/msi/file-placement.py +++ b/test/packaging/msi/file-placement.py @@ -37,17 +37,19 @@ test = TestSCons.TestSCons() try: from xml.dom.minidom import * except ImportError: - test.skip_test('Canoot import xml.dom.minidom skipping test\n') + test.skip_test('Cannot import xml.dom.minidom; skipping test\n') wix = test.Environment().WhereIs('candle') -if wix: - # - # Test the default directory layout - # - test.write( 'file1.exe', "file1" ) +if not wix: + test.skip_test("No 'candle' found; skipping test\n") - test.write('SConstruct', """ +# +# Test the default directory layout +# +test.write( 'file1.exe', "file1" ) + +test.write('SConstruct', """ env = Environment(tools=['default', 'packaging']) f1 = env.Install( '/bin/' , 'file1.exe' ) @@ -61,28 +63,28 @@ env.Package( NAME = 'foo', ) """) - test.run(arguments='', stderr = None) +test.run(arguments='', stderr = None) - dom = parse( test.workpath( 'foo-1.2.wxs' ) ) - dirs = dom.getElementsByTagName( 'Directory' ) +dom = parse( test.workpath( 'foo-1.2.wxs' ) ) +dirs = dom.getElementsByTagName( 'Directory' ) - test.fail_test( not dirs[0].attributes['Name'].value == 'SourceDir' ) - test.fail_test( not dirs[1].attributes['Name'].value == 'PFiles' ) - test.fail_test( not dirs[2].attributes['Name'].value == 'NANOSOF1' ) - test.fail_test( not dirs[3].attributes['Name'].value == 'FOO-1.2' ) +test.fail_test( not dirs[0].attributes['Name'].value == 'SourceDir' ) +test.fail_test( not dirs[1].attributes['Name'].value == 'PFiles' ) +test.fail_test( not dirs[2].attributes['Name'].value == 'NANOSOF1' ) +test.fail_test( not dirs[3].attributes['Name'].value == 'FOO-1.2' ) - # - # Try to put 7 files into 5 distinct directories of varying depth and overlapping count - # - test.write( 'file1.exe', "file1" ) - test.write( 'file2.exe', "file2" ) - test.write( 'file3.dll', "file3" ) - test.write( 'file4.dll', "file4" ) - test.write( 'file5.class', "file5" ) - test.write( 'file6.class', "file6" ) - test.write( 'file7.class', "file7" ) - - test.write('SConstruct', """ +# +# Try to put 7 files into 5 distinct directories of varying depth and overlapping count +# +test.write( 'file1.exe', "file1" ) +test.write( 'file2.exe', "file2" ) +test.write( 'file3.dll', "file3" ) +test.write( 'file4.dll', "file4" ) +test.write( 'file5.class', "file5" ) +test.write( 'file6.class', "file6" ) +test.write( 'file7.class', "file7" ) + +test.write('SConstruct', """ env = Environment(tools=['default', 'packaging']) f1 = env.Install( '/bin/' , 'file1.exe' ) f2 = env.Install( '/bin/' , 'file2.exe' ) @@ -103,35 +105,35 @@ env.Package( NAME = 'foo', ) """) - test.run(arguments='', stderr = None) +test.run(arguments='', stderr = None) - dom = parse( test.workpath( 'foo-1.2.wxs' ) ) - files = dom.getElementsByTagName( 'File' ) +dom = parse( test.workpath( 'foo-1.2.wxs' ) ) +files = dom.getElementsByTagName( 'File' ) - test.fail_test( not files[0].parentNode.parentNode.attributes['LongName'].value == 'bin' ) - test.fail_test( not files[1].parentNode.parentNode.attributes['LongName'].value == 'bin' ) - test.fail_test( not files[2].parentNode.parentNode.attributes['LongName'].value == 'lib' ) - test.fail_test( not files[3].parentNode.parentNode.attributes['LongName'].value == 'lib' ) - - test.fail_test( not files[4].parentNode.parentNode.attributes['LongName'].value == 'teco' ) - test.fail_test( not files[4].parentNode.parentNode.parentNode.attributes['LongName'].value == 'edu' ) - test.fail_test( not files[4].parentNode.parentNode.parentNode.parentNode.attributes['LongName'].value == 'java' ) +test.fail_test( not files[0].parentNode.parentNode.attributes['LongName'].value == 'bin' ) +test.fail_test( not files[1].parentNode.parentNode.attributes['LongName'].value == 'bin' ) +test.fail_test( not files[2].parentNode.parentNode.attributes['LongName'].value == 'lib' ) +test.fail_test( not files[3].parentNode.parentNode.attributes['LongName'].value == 'lib' ) + +test.fail_test( not files[4].parentNode.parentNode.attributes['LongName'].value == 'teco' ) +test.fail_test( not files[4].parentNode.parentNode.parentNode.attributes['LongName'].value == 'edu' ) +test.fail_test( not files[4].parentNode.parentNode.parentNode.parentNode.attributes['LongName'].value == 'java' ) - test.fail_test( not files[5].parentNode.parentNode.attributes['LongName'].value == 'teco' ) - test.fail_test( not files[5].parentNode.parentNode.parentNode.attributes['LongName'].value == 'java' ) +test.fail_test( not files[5].parentNode.parentNode.attributes['LongName'].value == 'teco' ) +test.fail_test( not files[5].parentNode.parentNode.parentNode.attributes['LongName'].value == 'java' ) - test.fail_test( not files[6].parentNode.parentNode.attributes['LongName'].value == 'tec' ) - test.fail_test( not files[6].parentNode.parentNode.parentNode.attributes['LongName'].value == 'java' ) +test.fail_test( not files[6].parentNode.parentNode.attributes['LongName'].value == 'tec' ) +test.fail_test( not files[6].parentNode.parentNode.parentNode.attributes['LongName'].value == 'java' ) - # - # Test distinct directories put into distinct features - # - test.write( 'file1.exe', "file1" ) - test.write( 'file2.exe', "file2" ) - test.write( 'file3.dll', "file3" ) - test.write( 'file3-.dll', "file3" ) +# +# Test distinct directories put into distinct features +# +test.write( 'file1.exe', "file1" ) +test.write( 'file2.exe', "file2" ) +test.write( 'file3.dll', "file3" ) +test.write( 'file3-.dll', "file3" ) - test.write('SConstruct', """ +test.write('SConstruct', """ env = Environment(tools=['default', 'packaging']) f1 = env.Install( '/bin/' , 'file1.exe' ) f2 = env.Install( '/bin/' , 'file2.exe' ) @@ -152,21 +154,19 @@ env.Package( NAME = 'foo', ) """) - test.run(arguments='', stderr = None) - - dom = parse( test.workpath( 'foo-1.2.wxs' ) ) - features = dom.getElementsByTagName( 'Feature' ) +test.run(arguments='', stderr = None) - test.fail_test( not features[1].attributes['Title'].value == 'Core Part' ) - componentrefs = features[1].getElementsByTagName( 'ComponentRef' ) - test.fail_test( not componentrefs[0].attributes['Id'].value == 'file1.exe' ) - test.fail_test( not componentrefs[1].attributes['Id'].value == 'file2.exe' ) - test.fail_test( not componentrefs[2].attributes['Id'].value == 'file3.dll1' ) +dom = parse( test.workpath( 'foo-1.2.wxs' ) ) +features = dom.getElementsByTagName( 'Feature' ) - test.fail_test( not features[2].attributes['Title'].value == 'Java Part' ) - componentrefs = features[2].getElementsByTagName( 'ComponentRef' ) - test.fail_test( not componentrefs[0].attributes['Id'].value == 'file3.dll' ) +test.fail_test( not features[1].attributes['Title'].value == 'Core Part' ) +componentrefs = features[1].getElementsByTagName( 'ComponentRef' ) +test.fail_test( not componentrefs[0].attributes['Id'].value == 'file1.exe' ) +test.fail_test( not componentrefs[1].attributes['Id'].value == 'file2.exe' ) +test.fail_test( not componentrefs[2].attributes['Id'].value == 'file3.dll1' ) -else: - test.no_result() +test.fail_test( not features[2].attributes['Title'].value == 'Java Part' ) +componentrefs = features[2].getElementsByTagName( 'ComponentRef' ) +test.fail_test( not componentrefs[0].attributes['Id'].value == 'file3.dll' ) +test.pass_test() diff --git a/test/packaging/msi/package.py b/test/packaging/msi/package.py index 24bd26d9..e6ce6682 100644 --- a/test/packaging/msi/package.py +++ b/test/packaging/msi/package.py @@ -42,14 +42,16 @@ except ImportError: wix = test.Environment().WhereIs('candle') -if wix: - # - # build with minimal tag set and test for the given package meta-data - # - test.write( 'file1.exe', "file1" ) - test.write( 'file2.exe', "file2" ) - - test.write('SConstruct', """ +if not wix: + test.skip_test("No 'candle' found; skipping test\n") + +# +# build with minimal tag set and test for the given package meta-data +# +test.write( 'file1.exe', "file1" ) +test.write( 'file2.exe', "file2" ) + +test.write('SConstruct', """ import os env = Environment(tools=['default', 'packaging']) @@ -69,32 +71,32 @@ env.Package( NAME = 'foo', env.Alias( 'install', [ f1, f2 ] ) """) - test.run(arguments='', stderr = None) +test.run(arguments='', stderr = None) - test.must_exist( 'foo-1.2.wxs' ) - test.must_exist( 'foo-1.2.msi' ) +test.must_exist( 'foo-1.2.wxs' ) +test.must_exist( 'foo-1.2.msi' ) - dom = parse( test.workpath( 'foo-1.2.wxs' ) ) - Product = dom.getElementsByTagName( 'Product' )[0] - Package = dom.getElementsByTagName( 'Package' )[0] +dom = parse( test.workpath( 'foo-1.2.wxs' ) ) +Product = dom.getElementsByTagName( 'Product' )[0] +Package = dom.getElementsByTagName( 'Package' )[0] - test.fail_test( not Product.attributes['Manufacturer'].value == 'Nanosoft_2000' ) - test.fail_test( not Product.attributes['Version'].value == '1.2' ) - test.fail_test( not Product.attributes['Name'].value == 'foo' ) +test.fail_test( not Product.attributes['Manufacturer'].value == 'Nanosoft_2000' ) +test.fail_test( not Product.attributes['Version'].value == '1.2' ) +test.fail_test( not Product.attributes['Name'].value == 'foo' ) - test.fail_test( not Package.attributes['Description'].value == 'balalalalal' ) - test.fail_test( not Package.attributes['Comments'].value == 'this should be reallly really long' ) +test.fail_test( not Package.attributes['Description'].value == 'balalalalal' ) +test.fail_test( not Package.attributes['Comments'].value == 'this should be reallly really long' ) - # - # build with file tags resulting in multiple components in the msi installer - # - test.write( 'file1.exe', "file1" ) - test.write( 'file2.exe', "file2" ) - test.write( 'file3.html', "file3" ) - test.write( 'file4.dll', "file4" ) - test.write( 'file5.dll', "file5" ) +# +# build with file tags resulting in multiple components in the msi installer +# +test.write( 'file1.exe', "file1" ) +test.write( 'file2.exe', "file2" ) +test.write( 'file3.html', "file3" ) +test.write( 'file4.dll', "file4" ) +test.write( 'file5.dll', "file5" ) - test.write('SConstruct', """ +test.write('SConstruct', """ import os env = Environment(tools=['default', 'packaging']) f1 = env.Install( '/usr/' , 'file1.exe' ) @@ -121,18 +123,19 @@ env.Package( NAME = 'foo', env.Alias( 'install', [ f1, f2, f3, f4, f5 ] ) """) - test.run(arguments='', stderr = None) +test.run(arguments='', stderr = None) + +test.must_exist( 'foo-1.2.wxs' ) +test.must_exist( 'foo-1.2.msi' ) + +dom = parse( test.workpath( 'foo-1.2.wxs' ) ) +elements = dom.getElementsByTagName( 'Feature' ) +test.fail_test( not elements[1].attributes['Title'].value == 'Main Part' ) +test.fail_test( not elements[2].attributes['Title'].value == 'Documentation' ) +test.fail_test( not elements[3].attributes['Title'].value == 'Another Feature' ) +test.fail_test( not elements[3].attributes['Description'].value == 'with a long description' ) +test.fail_test( not elements[4].attributes['Title'].value == 'Java Part' ) - test.must_exist( 'foo-1.2.wxs' ) - test.must_exist( 'foo-1.2.msi' ) - dom = parse( test.workpath( 'foo-1.2.wxs' ) ) - elements = dom.getElementsByTagName( 'Feature' ) - test.fail_test( not elements[1].attributes['Title'].value == 'Main Part' ) - test.fail_test( not elements[2].attributes['Title'].value == 'Documentation' ) - test.fail_test( not elements[3].attributes['Title'].value == 'Another Feature' ) - test.fail_test( not elements[3].attributes['Description'].value == 'with a long description' ) - test.fail_test( not elements[4].attributes['Title'].value == 'Java Part' ) -else: - test.no_result() +test.pass_test() diff --git a/test/packaging/option--package-type.py b/test/packaging/option--package-type.py index 68a075c6..00a569e0 100644 --- a/test/packaging/option--package-type.py +++ b/test/packaging/option--package-type.py @@ -35,6 +35,8 @@ _python_ = TestSCons._python_ test = TestSCons.TestSCons() +rpm_build_root = test.workpath('rpm_build_root') + scons = test.program rpm = test.Environment().WhereIs('rpm') @@ -50,6 +52,7 @@ test.write('SConstruct', """ # -*- coding: iso-8859-15 -*- env=Environment(tools=['default', 'packaging']) env.Prepend(RPM = 'TAR_OPTIONS=--wildcards ') +env.Append(RPMFLAGS = r' --buildroot %(rpm_build_root)s') prog=env.Install( '/bin', 'main' ) env.Package( NAME = 'foo', VERSION = '1.2.3', diff --git a/test/packaging/rpm/cleanup.py b/test/packaging/rpm/cleanup.py index 26bf79ba..5472fbbc 100644 --- a/test/packaging/rpm/cleanup.py +++ b/test/packaging/rpm/cleanup.py @@ -45,6 +45,8 @@ rpm = test.Environment().WhereIs('rpm') if not rpm: test.skip_test('rpm not found, skipping test\n') +rpm_build_root = test.workpath('rpm_build_root') + test.subdir('src') test.write( [ 'src', 'main.c' ], r""" @@ -57,7 +59,10 @@ int main( int argc, char* argv[] ) test.write('SConstruct', """ env=Environment(tools=['default', 'packaging']) +env['ENV']['RPM_BUILD_ROOT'] = r'%(rpm_build_root)s/foo-1.2.3' + env.Prepend(RPM = 'TAR_OPTIONS=--wildcards ') +env.Append(RPMFLAGS = r' --buildroot %(rpm_build_root)s') prog = env.Install( '/bin/' , Program( 'src/main.c') ) diff --git a/test/packaging/rpm/internationalization.py b/test/packaging/rpm/internationalization.py index 66c22917..af0bc75b 100644 --- a/test/packaging/rpm/internationalization.py +++ b/test/packaging/rpm/internationalization.py @@ -47,6 +47,8 @@ rpm = test.Environment().WhereIs('rpm') if not rpm: test.skip_test('rpm not found, skipping test\n') +rpm_build_root = test.workpath('rpm_build_root') + # # test INTERNATIONAL PACKAGE META-DATA # @@ -64,6 +66,7 @@ import os env = Environment(tools=['default', 'packaging']) env.Prepend(RPM = 'TAR_OPTIONS=--wildcards ') +env.Append(RPMFLAGS = r' --buildroot %(rpm_build_root)s') prog = env.Install( '/bin', Program( 'main.c' ) ) diff --git a/test/packaging/rpm/package.py b/test/packaging/rpm/package.py index a5f9f0fc..2a372658 100644 --- a/test/packaging/rpm/package.py +++ b/test/packaging/rpm/package.py @@ -43,6 +43,8 @@ rpm = test.Environment().WhereIs('rpm') if not rpm: test.skip_test('rpm not found, skipping test\n') +rpm_build_root = test.workpath('rpm_build_root') + test.subdir('src') test.write( [ 'src', 'main.c' ], r""" @@ -58,6 +60,7 @@ import os env=Environment(tools=['default', 'packaging']) env.Prepend(RPM = 'TAR_OPTIONS=--wildcards ') +env.Append(RPMFLAGS = r' --buildroot %(rpm_build_root)s') prog = env.Install( '/bin/' , Program( 'src/main.c') ) diff --git a/test/packaging/rpm/tagging.py b/test/packaging/rpm/tagging.py index 198799a1..d0fce837 100644 --- a/test/packaging/rpm/tagging.py +++ b/test/packaging/rpm/tagging.py @@ -45,6 +45,8 @@ rpm = test.Environment().WhereIs('rpm') if not rpm: test.skip_test('rpm not found, skipping test\n') +rpm_build_root = test.workpath('rpm_build_root') + # # Test adding an attr tag to the built program. # @@ -61,7 +63,10 @@ test.write('SConstruct', """ import os env = Environment(tools=['default', 'packaging']) + env.Prepend(RPM = 'TAR_OPTIONS=--wildcards ') +env.Append(RPMFLAGS = r' --buildroot %(rpm_build_root)s') + install_dir= os.path.join( ARGUMENTS.get('prefix', '/'), 'bin/' ) prog_install = env.Install( install_dir , Program( 'src/main.c' ) ) env.Tag( prog_install, UNIX_ATTR = '(0755, root, users)' ) diff --git a/test/scons-time/run/archive/zip.py b/test/scons-time/run/archive/zip.py index 67cfc3a4..b5b122b8 100644 --- a/test/scons-time/run/archive/zip.py +++ b/test/scons-time/run/archive/zip.py @@ -29,6 +29,8 @@ Verify basic generation of timing information from an input fake-project .zip file. """ +import sys + import TestSCons_time test = TestSCons_time.TestSCons_time() @@ -37,6 +39,28 @@ test.write_fake_scons_py() test.write_sample_project('foo.zip') +try: + import zipfile + # There's a bug in the Python 2.1 zipfile library that makes it blow + # up on 64-bit architectures, when trying to read normal 32-bit zip + # files. Check for it by trying to read the archive we just created, + # and skipping the test gracefully if there's a problem. + zf = zipfile.ZipFile('foo.zip', 'r') + for name in zf.namelist(): + zf.read(name) +except ImportError: + # This "shouldn't happen" because the early Python versions that + # have no zipfile module don't support the scons-time script, + # so the initialization above should short-circuit this test. + # But just in case... + fmt = "Python %s has no zipfile module. Skipping test.\n" + test.skip_test(fmt % sys.version[:3]) +except zipfile.BadZipfile, e: + if str(e)[:11] == 'Bad CRC-32 ': + fmt = "Python %s zipfile module doesn't work on 64-bit architectures. Skipping test.\n" + test.skip_test(fmt % sys.version[:3]) + raise + test.run(arguments = 'run foo.zip') test.must_exist('foo-000-0.log', diff --git a/test/scons-time/run/option/quiet.py b/test/scons-time/run/option/quiet.py index 5d5d7cfe..f5a3d8c0 100644 --- a/test/scons-time/run/option/quiet.py +++ b/test/scons-time/run/option/quiet.py @@ -39,7 +39,7 @@ test.diff_function = TestSCons_time.diff_re def tempdir_re(*args): - import os + import os,sys import os.path import string import tempfile @@ -49,6 +49,9 @@ def tempdir_re(*args): x = apply(os.path.join, args) x = re.escape(x) x = string.replace(x, 'time\\-', 'time\\-[^%s]*' % sep) + if sys.platform=='darwin': + # OSX has /tmp in /private/tmp. + x = '(/private)?' + x return x scons_py = re.escape(test.workpath('src', 'script', 'scons.py')) diff --git a/test/scons-time/run/option/verbose.py b/test/scons-time/run/option/verbose.py index cdf5b5a2..fb95dab5 100644 --- a/test/scons-time/run/option/verbose.py +++ b/test/scons-time/run/option/verbose.py @@ -40,7 +40,7 @@ test.diff_function = TestSCons_time.diff_re def tempdir_re(*args): - import os + import os,sys import os.path import string import tempfile @@ -50,6 +50,9 @@ def tempdir_re(*args): x = apply(os.path.join, args) x = re.escape(x) x = string.replace(x, 'time\\-', 'time\\-[^%s]*' % sep) + if sys.platform=='darwin': + # OSX has /tmp in /private/tmp. + x = '(/private)?' + x return x scons_py = re.escape(test.workpath('src', 'script', 'scons.py')) -- 2.26.2