From f311f5ac8b8da71b93166bf566aa0a89c91abd50 Mon Sep 17 00:00:00 2001 From: Steven Knight Date: Fri, 1 Jun 2007 21:14:13 +0000 Subject: Merged revisions 1907-1940,1942-1967 via svnmerge from http://scons.tigris.org/svn/scons/branches/core ........ r1914 | stevenknight | 2007-05-19 20:18:45 -0700 (Sat, 19 May 2007) | 4 lines Use the dict() builtin, not a by-hand function, to assemble --debug=explain info. Update our backwards-compatibility dict() function so its calling signature matches the later SCons dict() builtin, and so it actually works. ........ r1920 | stevenknight | 2007-05-21 19:59:00 -0700 (Mon, 21 May 2007) | 4 lines Issue 1652: only add the {base}_p.c and {base}_data.c files if the /proxy or /dlldata arguments are present (respectively). (Allan Erskine) ........ r1921 | stevenknight | 2007-05-21 20:09:54 -0700 (Mon, 21 May 2007) | 2 lines Add initial .svnt/conf file for experimental use. ........ r1924 | stevenknight | 2007-05-22 17:51:34 -0700 (Tue, 22 May 2007) | 3 lines Don't let tool initialization overwrite ${C,CXX}FILESUFFIX if they're already set. ........ r1925 | stevenknight | 2007-05-22 19:14:27 -0700 (Tue, 22 May 2007) | 3 lines Change the --debug=explain message when AlwaysBuild() is set from the default "unknown reasons" to "because AlwaysBuild() is specified." ........ r1927 | stevenknight | 2007-05-23 05:20:32 -0700 (Wed, 23 May 2007) | 3 lines Issue 1658: Find Java anonymous classes when the next token after the name is an open parenthesis. (Jan Nijtmans) ........ r1928 | stevenknight | 2007-05-23 11:50:20 -0700 (Wed, 23 May 2007) | 3 lines Issue 1313: add support for {Get,Set}Option('help') and {Get,Set}Option('random') . ........ r1929 | stevenknight | 2007-05-23 11:56:18 -0700 (Wed, 23 May 2007) | 3 lines Issue 1362: Push/retrieve built symlinks to/from a CacheDir() as symlinks, not by copying file contents. ........ r1930 | stevenknight | 2007-05-23 12:55:12 -0700 (Wed, 23 May 2007) | 3 lines Issue 1638: add LaTeX scanner support for finding dependencies from \usepackage{} directives. (Sohail Somani) ........ r1932 | stevenknight | 2007-05-24 05:06:45 -0700 (Thu, 24 May 2007) | 3 lines Add a section mentioning that libraries can be built from mixed lists of source code and object files. (Follow-up from IRC chat.) ........ r1933 | stevenknight | 2007-05-24 11:18:30 -0700 (Thu, 24 May 2007) | 2 lines Issue 1467: add /opt/SUNWspro/bin to the default execution $PATH on Solaris. ........ r1934 | stevenknight | 2007-05-24 13:10:01 -0700 (Thu, 24 May 2007) | 3 lines Support running tests when Python is in a path that contains spaces (like "C:\Program Files\Python..."). ........ r1935 | stevenknight | 2007-05-24 13:11:52 -0700 (Thu, 24 May 2007) | 4 lines Issue 1479: print multiple projects in a Visual Studio 7.[01] solution file, generating a separate GUID for each instead of re-using the solution GUID. (Mark Bertoglio) ........ r1937 | stevenknight | 2007-05-26 14:35:17 -0700 (Sat, 26 May 2007) | 4 lines Issue 1659: when stringifying a generator action, fall back to using the default construction environment, not an empty dictionary, if not environment was supplied. ........ r1938 | stevenknight | 2007-05-29 05:14:37 -0700 (Tue, 29 May 2007) | 2 lines Re-run tests if any of the test infrastructure changed, too. ........ r1940 | stevenknight | 2007-05-29 06:58:42 -0700 (Tue, 29 May 2007) | 2 lines Issue 1634: "define HAVE_FEATURE 1" lines in generated config.h files. ........ r1943 | stevenknight | 2007-05-29 13:24:34 -0700 (Tue, 29 May 2007) | 2 lines Issue 1426: Generalize AlwaysBuild() to non-File Nodes. ........ r1945 | stevenknight | 2007-05-30 08:15:25 -0700 (Wed, 30 May 2007) | 3 lines Clean up emitter unit tests: subdivide one large test case into separate tests, code renaming and reorganizing for readability. ........ r1947 | stevenknight | 2007-05-30 10:22:49 -0700 (Wed, 30 May 2007) | 4 lines Issue 1656: two PDB fixes: 1) support expansion of $TARGET, etc. in emitted file names 2) put the output PDB file in the target's build_dir ........ r1951 | stevenknight | 2007-05-31 12:51:42 -0700 (Thu, 31 May 2007) | 3 lines Refactor the checkLogAndStdout() function into a TestSCons method so we can split the sub-tests into their own scripts. ........ r1952 | stevenknight | 2007-05-31 13:00:56 -0700 (Thu, 31 May 2007) | 3 lines Also move the definition of what system library we need to use for Configure tests into the TestSCons class. ........ r1953 | stevenknight | 2007-05-31 14:12:16 -0700 (Thu, 31 May 2007) | 2 lines Refactor the Configure context subtests into separate scripts. ........ r1954 | stevenknight | 2007-05-31 14:18:11 -0700 (Thu, 31 May 2007) | 3 lines Get rid of the work_dir argument to checkLogAndStdout(), since we're no longer executing sub-tests from separate subdirectories. ........ r1955 | stevenknight | 2007-05-31 14:35:20 -0700 (Thu, 31 May 2007) | 2 lines Move the test to its correct subdirectory. Oops. ........ r1958 | stevenknight | 2007-06-01 08:35:50 -0700 (Fri, 01 Jun 2007) | 2 lines Skip the Visual C/C++ PDB + BuildDir test when not run on Windows. ........ r1959 | stevenknight | 2007-06-01 09:35:09 -0700 (Fri, 01 Jun 2007) | 2 lines Support an AddMethod() global function and construction environment method. ........ r1960 | stevenknight | 2007-06-01 09:52:59 -0700 (Fri, 01 Jun 2007) | 3 lines Python 1.5 compatibility in the test infrastructure added to support the refactored Configure tests. ........ r1963 | stevenknight | 2007-06-01 12:29:48 -0700 (Fri, 01 Jun 2007) | 2 lines Python 1.5 compatibility fix for AddMethod(). ........ --- .svnt/conf | 18 + QMTest/TestSCons.py | 137 +++++ doc/man/scons.1 | 62 +- doc/user/caching.in | 25 + doc/user/libraries.in | 60 ++ doc/user/libraries.sgml | 50 ++ doc/user/main.in | 3 + src/CHANGES.txt | 65 +++ src/RELEASE.txt | 27 + src/engine/SCons/Action.py | 6 +- src/engine/SCons/ActionTests.py | 8 + src/engine/SCons/Builder.py | 9 +- src/engine/SCons/BuilderTests.py | 112 ++-- src/engine/SCons/Conftest.py | 2 +- src/engine/SCons/Environment.py | 20 +- src/engine/SCons/EnvironmentTests.py | 67 ++- src/engine/SCons/Node/FS.py | 12 +- src/engine/SCons/Node/__init__.py | 23 +- src/engine/SCons/Platform/sunos.py | 2 +- src/engine/SCons/Scanner/LaTeX.py | 6 +- src/engine/SCons/Script/Main.py | 27 +- src/engine/SCons/Script/__init__.py | 1 + src/engine/SCons/Taskmaster.py | 3 +- src/engine/SCons/TaskmasterTests.py | 9 +- src/engine/SCons/Tool/JavaCommon.py | 40 +- src/engine/SCons/Tool/JavaCommonTests.py | 24 + src/engine/SCons/Tool/__init__.py | 5 +- src/engine/SCons/Tool/midl.py | 14 +- src/engine/SCons/Tool/mslink.py | 16 +- src/engine/SCons/Tool/msvs.py | 6 +- src/engine/SCons/Util.py | 76 +++ src/engine/SCons/compat/builtins.py | 6 +- test/AddMethod.py | 61 ++ test/AlwaysBuild.py | 32 +- test/CFILESUFFIX.py | 19 +- test/CXX/CXXFILESUFFIX.py | 15 +- test/CacheDir/symlink.py | 68 +++ test/Configure/Action-error.py | 48 ++ test/Configure/BuildDir-SConscript.py | 159 ++++++ test/Configure/BuildDir.py | 91 +++ test/Configure/Builder-call.py | 57 ++ test/Configure/Configure.py | 939 ------------------------------- test/Configure/ConfigureDryRunError.py | 99 ++++ test/Configure/SConscript.py | 74 +++ test/Configure/basic.py | 83 +++ test/Configure/cache-not-ok.py | 96 ++++ test/Configure/cache-ok.py | 118 ++++ test/Configure/config-h.py | 155 +++++ test/Configure/custom-tests.py | 111 ++++ test/Configure/option--Q.py | 46 ++ test/Configure/option--config.py | 122 ++++ test/GetOption/help.py | 54 ++ test/IDL/MIDLCOM.py | 14 +- test/MSVC/multiple-pdb.py | 83 +++ test/MSVC/pdb-BuildDir-path.py | 76 +++ test/MSVS/vs-7.0-files.py | 4 +- test/MSVS/vs-7.1-files.py | 4 +- test/TEX/usepackage.py | 74 +++ test/explain.py | 21 +- test/option--random.py | 59 +- 60 files changed, 2632 insertions(+), 1091 deletions(-) create mode 100644 .svnt/conf create mode 100644 test/AddMethod.py create mode 100644 test/CacheDir/symlink.py create mode 100644 test/Configure/Action-error.py create mode 100644 test/Configure/BuildDir-SConscript.py create mode 100644 test/Configure/BuildDir.py create mode 100644 test/Configure/Builder-call.py delete mode 100644 test/Configure/Configure.py create mode 100644 test/Configure/ConfigureDryRunError.py create mode 100644 test/Configure/SConscript.py create mode 100644 test/Configure/basic.py create mode 100644 test/Configure/cache-not-ok.py create mode 100644 test/Configure/cache-ok.py create mode 100644 test/Configure/config-h.py create mode 100644 test/Configure/custom-tests.py create mode 100644 test/Configure/option--Q.py create mode 100644 test/Configure/option--config.py create mode 100644 test/GetOption/help.py create mode 100644 test/MSVC/multiple-pdb.py create mode 100644 test/MSVC/pdb-BuildDir-path.py create mode 100644 test/TEX/usepackage.py diff --git a/.svnt/conf b/.svnt/conf new file mode 100644 index 0000000..255a4ac --- /dev/null +++ b/.svnt/conf @@ -0,0 +1,18 @@ +import os +import sys + +python = os.environ.get('PYTHON', sys.executable) + +cmd = '"%(python)s" runtest.py -q --noqmtest %%s' % locals() + +test_inputs = [ + 'src/*.py', + 'QMTest/*.py', +] + +tests = ( + ('src/*Tests.py', cmd), + ('test/*.py', cmd), +) + +valid_regression_results = [0, 2] diff --git a/QMTest/TestSCons.py b/QMTest/TestSCons.py index 196c24e..8d820b6 100644 --- a/QMTest/TestSCons.py +++ b/QMTest/TestSCons.py @@ -18,9 +18,21 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import os import os.path +import re import string import sys +import __builtin__ +try: + __builtin__.zip +except AttributeError: + def zip(*lists): + result = [] + for i in xrange(len(lists[0])): + result.append(tuple(map(lambda l, i=i: l[i], lists))) + return result + __builtin__.zip = zip + from TestCommon import * from TestCommon import __all__ @@ -576,6 +588,131 @@ print "self._msvs_versions =", str(env['MSVS']['VERSIONS']) return p return apply(os.path.join, [vs_path] + sub_paths[version][0]) + + NCR = 0 # non-cached rebuild + CR = 1 # cached rebuild (up to date) + NCF = 2 # non-cached build failure + CF = 3 # cached build failure + + if sys.platform == 'win32': + Configure_lib = 'msvcrt' + else: + Configure_lib = 'm' + + # to use cygwin compilers on cmd.exe -> uncomment following line + #Configure_lib = 'm' + + def checkLogAndStdout(self, checks, results, cached, + logfile, sconf_dir, sconstruct, + doCheckLog=1, doCheckStdout=1): + + class NoMatch: + def __init__(self, p): + self.pos = p + + def matchPart(log, logfile, lastEnd): + m = re.match(log, logfile[lastEnd:]) + if not m: + raise NoMatch, lastEnd + return m.end() + lastEnd + try: + #print len(os.linesep) + ls = os.linesep + nols = "(" + for i in range(len(ls)): + nols = nols + "(" + for j in range(i): + nols = nols + ls[j] + nols = nols + "[^" + ls[i] + "])" + if i < len(ls)-1: + nols = nols + "|" + nols = nols + ")" + lastEnd = 0 + logfile = self.read(self.workpath(logfile)) + if (doCheckLog and + string.find( logfile, "scons: warning: The stored build " + "information has an unexpected class." ) >= 0): + self.fail_test() + sconf_dir = sconf_dir + sconstruct = sconstruct + + log = r'file\ \S*%s\,line \d+:' % re.escape(sconstruct) + ls + if doCheckLog: lastEnd = matchPart(log, logfile, lastEnd) + log = "\t" + re.escape("Configure(confdir = %s)" % sconf_dir) + ls + if doCheckLog: lastEnd = matchPart(log, logfile, lastEnd) + rdstr = "" + cnt = 0 + for check,result,cache_desc in zip(checks, results, cached): + log = re.escape("scons: Configure: " + check) + ls + if doCheckLog: lastEnd = matchPart(log, logfile, lastEnd) + log = "" + result_cached = 1 + for bld_desc in cache_desc: # each TryXXX + for ext, flag in bld_desc: # each file in TryBuild + file = os.path.join(sconf_dir,"conftest_%d%s" % (cnt, ext)) + if flag == self.NCR: + # rebuild will pass + if ext in ['.c', '.cpp']: + log=log + re.escape(file + " <-") + ls + log=log + r"( \|" + nols + "*" + ls + ")+?" + else: + log=log + "(" + nols + "*" + ls +")*?" + result_cached = 0 + if flag == self.CR: + # up to date + log=log + \ + re.escape("scons: Configure: \"%s\" is up to date." + % file) + ls + log=log+re.escape("scons: Configure: The original builder " + "output was:") + ls + log=log+r"( \|.*"+ls+")+" + if flag == self.NCF: + # non-cached rebuild failure + log=log + "(" + nols + "*" + ls + ")*?" + result_cached = 0 + if flag == self.CF: + # cached rebuild failure + log=log + \ + re.escape("scons: Configure: Building \"%s\" failed " + "in a previous run and all its sources are" + " up to date." % file) + ls + log=log+re.escape("scons: Configure: The original builder " + "output was:") + ls + log=log+r"( \|.*"+ls+")+" + cnt = cnt + 1 + if result_cached: + result = "(cached) " + result + rdstr = rdstr + re.escape(check) + re.escape(result) + "\n" + log=log + re.escape("scons: Configure: " + result) + ls + ls + if doCheckLog: lastEnd = matchPart(log, logfile, lastEnd) + log = "" + if doCheckLog: lastEnd = matchPart(ls, logfile, lastEnd) + if doCheckLog and lastEnd != len(logfile): + raise NoMatch, lastEnd + + except NoMatch, m: + print "Cannot match log file against log regexp." + print "log file: " + print "------------------------------------------------------" + print logfile[m.pos:] + print "------------------------------------------------------" + print "log regexp: " + print "------------------------------------------------------" + print log + print "------------------------------------------------------" + self.fail_test() + + if doCheckStdout: + exp_stdout = self.wrap_stdout(".*", rdstr) + if not self.match_re_dotall(self.stdout(), exp_stdout): + print "Unexpected stdout: " + print "-----------------------------------------------------" + print repr(self.stdout()) + print "-----------------------------------------------------" + print repr(exp_stdout) + print "-----------------------------------------------------" + self.fail_test() + # 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/doc/man/scons.1 b/doc/man/scons.1 index 73e3df9..c0b91ec 100644 --- a/doc/man/scons.1 +++ b/doc/man/scons.1 @@ -1975,6 +1975,59 @@ until the Action object is actually used. '\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" .TP +.RI AddMethod( object, function ", [" name ]) +.TP +.RI env.AddMethod( function ", [" name ]) +When called with the +.BR AddMethod () +form, +adds the specified +.I function +to the specified +.I object +as the specified method +.IR name . +When called with the +.BR env.AddMethod () +form, +adds the specified +.I function +to the construction environment +.I env +as the specified method +.IR name . +In both cases, if +.I name +is omitted or +.BR None , +the name of the +specified +.I function +itself is used for the method name. + +.ES +# Note that the first argument to the function to +# be attached as a method must be the object through +# which the method will be called; the Python +# convention is to call it 'self'. +def my_method(self, arg): + print "my_method() got", arg + +# Use the global AddMethod() function to add a method +# to the Environment class. This +AddMethod(Environment, my_method) +env = Environment() +env.my_method('arg') + +# Add the function as a method, using the function +# name for the method call. +env = Environment() +env.AddMethod(my_method, 'other_method_name') +env.other_method_name('another arg') +.EE + +'\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +.TP .RI AddPostAction( target ", " action ) .TP .RI env.AddPostAction( target ", " action ) @@ -4048,16 +4101,19 @@ if not env.has_key('FOO'): env['FOO'] = 'foo' This function provides a way to set a select subset of the scons command line options from a SConscript file. The options supported are: .B clean -which corresponds to -c, --clean, and --remove; +which corresponds to -c, --clean and --remove; .B duplicate -which -corresponds to --duplicate; +which corresponds to --duplicate; +.B help +which corresponds to -h and --help; .B implicit_cache which corresponds to --implicit-cache; .B max_drift which corresponds to --max-drift; .B num_jobs which corresponds to -j and --jobs. +.B random +which corresponds to --random. See the documentation for the corresponding command line object for information about each specific option. Example: diff --git a/doc/user/caching.in b/doc/user/caching.in index 015407b..8dfa731 100644 --- a/doc/user/caching.in +++ b/doc/user/caching.in @@ -430,6 +430,31 @@ + + + If you want to make sure dependencies will be built + in a random order without having to specify + the --random on very command line, + you can use the &SetOption; function to + set the random option + within any &SConscript; file: + + + + + + SetOption('random', 1) + Program('prog', + ['f1.c', 'f2.c', 'f3.c', 'f4.c', 'f5.c']) + + f1.c + f2.c + f3.c + f4.c + f5.c + f6.c + +