diff options
| author | Steven Knight <knight@baldmt.com> | 2006-12-16 01:43:01 (GMT) |
|---|---|---|
| committer | Steven Knight <knight@baldmt.com> | 2006-12-16 01:43:01 (GMT) |
| commit | c4d04b3b45e7b71a1b28053b90084bcf2fdf9c0e (patch) | |
| tree | 8a0d07c078ac21bf1ab689eacf06577069bb9231 /src/engine/SCons/Scanner | |
| parent | b32cd624a5ad9526d28584b8e6c4a7958f436424 (diff) | |
| download | SCons-c4d04b3b45e7b71a1b28053b90084bcf2fdf9c0e.zip SCons-c4d04b3b45e7b71a1b28053b90084bcf2fdf9c0e.tar.gz SCons-c4d04b3b45e7b71a1b28053b90084bcf2fdf9c0e.tar.bz2 | |
Merged revisions 1675-1736 via svnmerge from
http://scons.tigris.org/svn/scons/branches/core
........
r1689 | stevenknight | 2006-11-06 20:56:29 -0600 (Mon, 06 Nov 2006) | 1 line
0.96.D483 - Merge changes for 0.96.93 packaging from the subsidiary branch.
........
r1690 | stevenknight | 2006-11-06 20:59:30 -0600 (Mon, 06 Nov 2006) | 1 line
0.96.D484 - Update HOWTO for releases. Fix name type in src/CHANGES.txt.
........
r1691 | stevenknight | 2006-11-08 13:55:36 -0600 (Wed, 08 Nov 2006) | 1 line
0.96.D485 - Fix MergeFlags() handling of None values. (John Pye)
........
r1692 | stevenknight | 2006-11-08 17:15:05 -0600 (Wed, 08 Nov 2006) | 1 line
0.96.D486 - Directly execute commands on Windows when possible. (Jay Kint)
........
r1693 | stevenknight | 2006-11-08 18:54:49 -0600 (Wed, 08 Nov 2006) | 1 line
0.96.D487 - Remove the semi-colon from the list of characters that determine when we use cmd
........
r1694 | stevenknight | 2006-11-09 01:34:06 -0600 (Thu, 09 Nov 2006) | 1 line
0.96.D488 - Pick up latex/bibtex 'Rerun to get citations correct' messages. (Dmitry Mikhin)
........
r1695 | stevenknight | 2006-11-11 08:36:33 -0600 (Sat, 11 Nov 2006) | 1 line
0.96.D489 - Back out the direct-execution-on-Windows change until we solve a corner case.
........
r1696 | stevenknight | 2006-11-15 10:33:10 -0600 (Wed, 15 Nov 2006) | 1 line
0.96.D490 - Fix the sconsign script when the .sconsign.dblite file is specified with its suf
........
r1697 | stevenknight | 2006-11-18 10:45:50 -0600 (Sat, 18 Nov 2006) | 4 lines
Complete move of test/sconsign/script.py to underneath test/sconsign/script/.
(This got left out of the previous checkin due to an error in the
script that resubmits Aegis changes to Subversion.)
........
r1698 | stevenknight | 2006-11-18 11:05:26 -0600 (Sat, 18 Nov 2006) | 1 line
0.96.D491 - Allow an Options converter to take the construction environment as a parameter.
........
r1699 | stevenknight | 2006-11-30 15:34:37 -0600 (Thu, 30 Nov 2006) | 1 line
0.96.D492 - Reverse the order in which we try the arguments Options converters, first a sing
........
r1700 | stevenknight | 2006-11-30 16:03:09 -0600 (Thu, 30 Nov 2006) | 1 line
0.96.D493 - Speed up rel_path() by avoiding recomputation of intermediate directory relative
........
r1701 | stevenknight | 2006-11-30 16:14:16 -0600 (Thu, 30 Nov 2006) | 1 line
0.96.D494 - More efficient get_suffix(): compute it once when we set the name.
........
r1702 | stevenknight | 2006-11-30 16:22:55 -0600 (Thu, 30 Nov 2006) | 1 line
0.96.D495 - Fix missing XML end tags.
........
r1703 | stevenknight | 2006-11-30 17:15:25 -0600 (Thu, 30 Nov 2006) | 1 line
0.96.D496 - Turn Memoizer into a simple counter for --debug=memoizer, not something that doe
........
r1704 | stevenknight | 2006-11-30 20:30:50 -0600 (Thu, 30 Nov 2006) | 1 line
0.96.D497 - Add the scons-time script, with doc and tests.
........
r1705 | stevenknight | 2006-11-30 23:28:20 -0600 (Thu, 30 Nov 2006) | 1 line
0.96.D498 - Update the copyright years string.
........
r1706 | stevenknight | 2006-12-01 11:54:22 -0600 (Fri, 01 Dec 2006) | 1 line
0.96.D499 - Fix _do_Lookup => _doLookup value-caching misspellings. (Ben Leslie)
........
r1707 | stevenknight | 2006-12-01 12:03:46 -0600 (Fri, 01 Dec 2006) | 1 line
0.96.D500 - Fix copyright test against debian build. (Walter Franzini)
........
r1708 | stevenknight | 2006-12-01 14:23:29 -0600 (Fri, 01 Dec 2006) | 1 line
0.96.D501 - Add #include lines for test portability. (Gary Oberbrunner)
........
r1709 | stevenknight | 2006-12-01 14:51:12 -0600 (Fri, 01 Dec 2006) | 1 line
0.96.D502 - Fix tests under Python versions with no profiler (pstats module).
........
r1710 | stevenknight | 2006-12-01 20:04:49 -0600 (Fri, 01 Dec 2006) | 1 line
0.96.D503 - Remove unnecessary os.path.normpath() calls. (Gary Oberbrunner)
........
r1711 | stevenknight | 2006-12-01 20:34:31 -0600 (Fri, 01 Dec 2006) | 1 line
0.96.D504 - Accomodate arbitray white space after a SWIG %module keyword. (Anonymous)
........
r1712 | stevenknight | 2006-12-05 14:49:54 -0600 (Tue, 05 Dec 2006) | 1 line
0.96.D506 - Cache substitutions of of Builder source suffixes. Use a new PathList module, and a refactor Node.FS.Rfindalldirs() method, to cache calculations of values like CPPPATH.
........
r1713 | stevenknight | 2006-12-05 18:43:36 -0600 (Tue, 05 Dec 2006) | 1 line
0.96.D507 - Use cached stat() values in diskchecks.
........
r1714 | stevenknight | 2006-12-05 21:11:24 -0600 (Tue, 05 Dec 2006) | 1 line
0.96.D508 - Fix Memoizer hit counts for methods memoizing simple values. Clean up the code for memoizing return values in a dictionary. Fix comments.
........
r1715 | stevenknight | 2006-12-06 07:23:18 -0600 (Wed, 06 Dec 2006) | 1 line
0.96.D369 - More efficient Node.FS.Dir.current() check. Fix some Windows test portability issues.
........
r1716 | stevenknight | 2006-12-06 12:24:32 -0600 (Wed, 06 Dec 2006) | 2 lines
Undo previous checkin (distributed incorrect Aegis change number).
........
r1717 | stevenknight | 2006-12-06 12:34:53 -0600 (Wed, 06 Dec 2006) | 1 line
0.96.D505 - Update ae-{cvs,svn}-ci for newer versions of aetar, and to not truncate descriptions.
........
r1718 | stevenknight | 2006-12-07 23:01:41 -0600 (Thu, 07 Dec 2006) | 1 line
0.96.D509 - Only look for mslink on Windows systems. (Sohail Somani)
........
r1719 | stevenknight | 2006-12-07 23:18:33 -0600 (Thu, 07 Dec 2006) | 1 line
0.96.D510 - Have the D compiler Tool use the same logic for shared libraries, too. (Paolo Invernizzi)
........
r1720 | stevenknight | 2006-12-07 23:29:47 -0600 (Thu, 07 Dec 2006) | 1 line
0.96.D511 - Generalize a JobTests.py test so it doesn't assume a specific order in which the operating system executes the threads.
........
r1721 | stevenknight | 2006-12-07 23:39:37 -0600 (Thu, 07 Dec 2006) | 1 line
0.96.D512 - Back out the Tool/dmd.py change; it breaks shared library linking for other lanuages beside D in the construction environment.
........
r1722 | stevenknight | 2006-12-07 23:47:11 -0600 (Thu, 07 Dec 2006) | 1 line
0.96.D513 - Test fixes: Windows portability, handle changes to Python 2.5 messages.
........
r1723 | stevenknight | 2006-12-08 00:00:13 -0600 (Fri, 08 Dec 2006) | 1 line
0.96.D514 - Change how the 'as' Tool is imported to accomodate the Python 2.6 'as' keyword.
........
r1724 | stevenknight | 2006-12-08 11:19:27 -0600 (Fri, 08 Dec 2006) | 1 line
0.96.D515 - Cache both Node.FS.find_file() and Node.FS.Dri.srcdir_find_file().
........
r1725 | stevenknight | 2006-12-08 17:27:35 -0600 (Fri, 08 Dec 2006) | 1 line
0.96.D516 - Better error when we try to fetch contents from an Entry that doesn't exist. (Tom Parker)
........
r1726 | stevenknight | 2006-12-08 23:28:55 -0600 (Fri, 08 Dec 2006) | 1 line
0.96.D517 - Make sure we pick up the scons-local directory regardless of where we chdir internally.
........
r1727 | stevenknight | 2006-12-11 16:25:53 -0600 (Mon, 11 Dec 2006) | 1 line
0.96.D518 - Cache results of Executor.get_unignored_sources() and Executor.process_sources(). Eliminate some map() and disambiguate() calls when scanning for implicit dependencies.
........
r1728 | stevenknight | 2006-12-12 14:32:22 -0600 (Tue, 12 Dec 2006) | 1 line
0.96.D519 - Fix SideEffect() when -j is used.
........
r1729 | stevenknight | 2006-12-12 16:58:15 -0600 (Tue, 12 Dec 2006) | 1 line
0.96.D520 - Add a srcdir keyword to Builder calls.
........
r1730 | stevenknight | 2006-12-12 21:40:59 -0600 (Tue, 12 Dec 2006) | 1 line
0.96.D521 - TeX/LaTeX updates, including handling files in subdirectories. (Joel B. Mohler, Rob Managan, Dmitry Mikhin)
........
r1731 | stevenknight | 2006-12-14 15:01:02 -0600 (Thu, 14 Dec 2006) | 1 line
0.96.D522 - Propogate TypeErrors during variable substitution for display to the user.
........
r1732 | stevenknight | 2006-12-14 20:01:49 -0600 (Thu, 14 Dec 2006) | 1 line
0.96.D523 - Fix the os.path.join() calls in EnvironmentTests.py.
........
r1733 | stevenknight | 2006-12-15 07:48:22 -0600 (Fri, 15 Dec 2006) | 1 line
0.96.D524 - Fix source directories as dependencies of an Alias (0.96.93 problem found by LilyPond).
........
r1735 | stevenknight | 2006-12-15 12:43:45 -0600 (Fri, 15 Dec 2006) | 1 line
0.96.D525 - Allow printing Debug.caller() output (or other end-of-run debugging info) when using -h.
........
r1736 | stevenknight | 2006-12-15 16:30:08 -0600 (Fri, 15 Dec 2006) | 1 line
0.96.D526 - Add an option to debug IndexError and NameError exceptions during variable substitution.
........
Diffstat (limited to 'src/engine/SCons/Scanner')
| -rw-r--r-- | src/engine/SCons/Scanner/CTests.py | 15 | ||||
| -rw-r--r-- | src/engine/SCons/Scanner/D.py | 1 | ||||
| -rw-r--r-- | src/engine/SCons/Scanner/Fortran.py | 3 | ||||
| -rw-r--r-- | src/engine/SCons/Scanner/FortranTests.py | 13 | ||||
| -rw-r--r-- | src/engine/SCons/Scanner/IDLTests.py | 13 | ||||
| -rw-r--r-- | src/engine/SCons/Scanner/LaTeX.py | 72 | ||||
| -rw-r--r-- | src/engine/SCons/Scanner/LaTeXTests.py | 6 | ||||
| -rw-r--r-- | src/engine/SCons/Scanner/Prog.py | 5 | ||||
| -rw-r--r-- | src/engine/SCons/Scanner/ProgTests.py | 10 | ||||
| -rw-r--r-- | src/engine/SCons/Scanner/ScannerTests.py | 29 | ||||
| -rw-r--r-- | src/engine/SCons/Scanner/__init__.py | 54 |
11 files changed, 126 insertions, 95 deletions
diff --git a/src/engine/SCons/Scanner/CTests.py b/src/engine/SCons/Scanner/CTests.py index 2ca522b..5d6765d 100644 --- a/src/engine/SCons/Scanner/CTests.py +++ b/src/engine/SCons/Scanner/CTests.py @@ -179,17 +179,17 @@ class DummyEnvironment(UserDict.UserDict): def Dictionary(self, *args): return self.data - def subst(self, strSubst): + def subst(self, strSubst, target=None, source=None, conv=None): if strSubst[0] == '$': return self.data[strSubst[1:]] return strSubst - def subst_list(self, strSubst): + def subst_list(self, strSubst, target=None, source=None, conv=None): if strSubst[0] == '$': return [self.data[strSubst[1:]]] return [[strSubst]] - def subst_path(self, path, target=None, source=None): + def subst_path(self, path, target=None, source=None, conv=None): if type(path) != type([]): path = [path] return map(self.subst, path) @@ -401,9 +401,12 @@ class CScannerTestCase13(unittest.TestCase): def runTest(self): """Find files in directories named in a substituted environment variable""" class SubstEnvironment(DummyEnvironment): - def subst(self, arg, test=test): - return test.workpath("d1") - env = SubstEnvironment(CPPPATH=["blah"]) + def subst(self, arg, target=None, source=None, conv=None, test=test): + if arg == "$blah": + return test.workpath("d1") + else: + return arg + env = SubstEnvironment(CPPPATH=["$blah"]) s = SCons.Scanner.C.CScanner() path = s.path(env) deps = s(env.File('f1.cpp'), env, path) diff --git a/src/engine/SCons/Scanner/D.py b/src/engine/SCons/Scanner/D.py index 2ea2614..5a0b383 100644 --- a/src/engine/SCons/Scanner/D.py +++ b/src/engine/SCons/Scanner/D.py @@ -46,7 +46,6 @@ def DScanner(): class D(SCons.Scanner.Classic): def find_include(self, include, source_dir, path): - if callable(path): path=path() # translate dots (package separators) to slashes inc = string.replace(include, '.', '/') diff --git a/src/engine/SCons/Scanner/Fortran.py b/src/engine/SCons/Scanner/Fortran.py index 8f7a6ce..31a1e16 100644 --- a/src/engine/SCons/Scanner/Fortran.py +++ b/src/engine/SCons/Scanner/Fortran.py @@ -78,7 +78,6 @@ class F90Scanner(SCons.Scanner.Classic): apply(SCons.Scanner.Current.__init__, (self,) + args, kw) def scan(self, node, env, path=()): - "__cacheable__" # cache the includes list in node so we only scan it once: if node.includes != None: @@ -112,6 +111,8 @@ class F90Scanner(SCons.Scanner.Classic): # is actually found in a Repository or locally. nodes = [] source_dir = node.get_dir() + if callable(path): + path = path() for dep in mods_and_includes: n, i = self.find_include(dep, source_dir, path) diff --git a/src/engine/SCons/Scanner/FortranTests.py b/src/engine/SCons/Scanner/FortranTests.py index da4a023..82db694 100644 --- a/src/engine/SCons/Scanner/FortranTests.py +++ b/src/engine/SCons/Scanner/FortranTests.py @@ -232,12 +232,12 @@ class DummyEnvironment: def __delitem__(self,key): del self.Dictionary()[key] - def subst(self, arg): + def subst(self, arg, target=None, source=None, conv=None): if arg[0] == '$': return self[arg[1:]] return arg - def subst_path(self, path, target=None, source=None): + def subst_path(self, path, target=None, source=None, conv=None): if type(path) != type([]): path = [path] return map(self.subst, path) @@ -461,10 +461,13 @@ class FortranScannerTestCase14(unittest.TestCase): class FortranScannerTestCase15(unittest.TestCase): def runTest(self): class SubstEnvironment(DummyEnvironment): - def subst(self, arg, test=test): - return test.workpath("d1") + def subst(self, arg, target=None, source=None, conv=None, test=test): + if arg == "$junk": + return test.workpath("d1") + else: + return arg test.write(['d1', 'f2.f'], " INCLUDE 'fi.f'\n") - env = SubstEnvironment(["junk"]) + env = SubstEnvironment(["$junk"]) s = SCons.Scanner.Fortran.FortranScan() path = s.path(env) deps = s(env.File('fff1.f'), env, path) diff --git a/src/engine/SCons/Scanner/IDLTests.py b/src/engine/SCons/Scanner/IDLTests.py index 153951d..2332a57 100644 --- a/src/engine/SCons/Scanner/IDLTests.py +++ b/src/engine/SCons/Scanner/IDLTests.py @@ -199,10 +199,10 @@ class DummyEnvironment: else: raise KeyError, "Dummy environment only has CPPPATH attribute." - def subst(self, arg): + def subst(self, arg, target=None, source=None, conv=None): return arg - def subst_path(self, path, target=None, source=None): + def subst_path(self, path, target=None, source=None, conv=None): if type(path) != type([]): path = [path] return map(self.subst, path) @@ -411,9 +411,12 @@ class IDLScannerTestCase11(unittest.TestCase): class IDLScannerTestCase12(unittest.TestCase): def runTest(self): class SubstEnvironment(DummyEnvironment): - def subst(self, arg, test=test): - return test.workpath("d1") - env = SubstEnvironment(["blah"]) + def subst(self, arg, target=None, source=None, conv=None, test=test): + if arg == "$blah": + return test.workpath("d1") + else: + return arg + env = SubstEnvironment(["$blah"]) s = SCons.Scanner.IDL.IDLScan() path = s.path(env) deps = s(env.File('t1.idl'), env, path) diff --git a/src/engine/SCons/Scanner/LaTeX.py b/src/engine/SCons/Scanner/LaTeX.py index 6451a58..d875e6e 100644 --- a/src/engine/SCons/Scanner/LaTeX.py +++ b/src/engine/SCons/Scanner/LaTeX.py @@ -31,13 +31,15 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import SCons.Scanner +import string +import os.path def LaTeXScanner(fs = SCons.Node.FS.default_fs): """Return a prototype Scanner instance for scanning LaTeX source files""" ds = LaTeX(name = "LaTeXScanner", suffixes = '$LATEXSUFFIXES', path_variable = 'TEXINPUTS', - regex = '\\\\(include|includegraphics(?:\[[^\]]+\])?|input){([^}]*)}', + regex = '\\\\(include|includegraphics(?:\[[^\]]+\])?|input|bibliography){([^}]*)}', recursive = 0) return ds @@ -46,21 +48,75 @@ class LaTeX(SCons.Scanner.Classic): Unlike most scanners, which use regular expressions that just return the included file name, this returns a tuple consisting - of the keyword for the inclusion ("include", "includegraphics" or - "input"), and then the file name itself. Base on a quick look at - LaTeX documentation, it seems that we need a should append .tex - suffix for "include" and "input" keywords, but leave the file name - untouched for "includegraphics." + of the keyword for the inclusion ("include", "includegraphics", + "input", or "bibliography"), and then the file name itself. + Based on a quick look at LaTeX documentation, it seems that we + need a should append .tex suffix for the "include" keywords, + append .tex if there is no extension for the "input" keyword, + but leave the file name untouched for "includegraphics." For + the "bibliography" keyword we need to add .bib if there is + no extension. (This need to be revisited since if there + is no extension for an :includegraphics" keyword latex will + append .ps or .eps to find the file; while pdftex will use + other extensions.) """ def latex_name(self, include): filename = include[1] - if include[0][:15] != 'includegraphics': + if include[0] == 'input': + base, ext = os.path.splitext( filename ) + if ext == "": + filename = filename + '.tex' + if (include[0] == 'include'): filename = filename + '.tex' + if include[0] == 'bibliography': + base, ext = os.path.splitext( filename ) + if ext == "": + filename = filename + '.bib' return filename def sort_key(self, include): return SCons.Node.FS._my_normcase(self.latex_name(include)) def find_include(self, include, source_dir, path): - if callable(path): path=path() i = SCons.Node.FS.find_file(self.latex_name(include), (source_dir,) + path) return i, include + + def scan(self, node, path=()): + # + # Modify the default scan function to allow for the regular + # expression to return a comma separated list of file names + # as can be the case with the bibliography keyword. + # + # cache the includes list in node so we only scan it once: + if node.includes != None: + includes = node.includes + else: + includes = self.cre.findall(node.get_contents()) + node.includes = includes + + # This is a hand-coded DSU (decorate-sort-undecorate, or + # Schwartzian transform) pattern. The sort key is the raw name + # of the file as specifed on the #include line (including the + # " or <, since that may affect what file is found), which lets + # us keep the sort order constant regardless of whether the file + # is actually found in a Repository or locally. + nodes = [] + source_dir = node.get_dir() + for include in includes: + # + # Handle multiple filenames in include[1] + # + inc_list = string.split(include[1],',') + for j in range(len(inc_list)): + include_local = [include[0],inc_list[j]] + n, i = self.find_include(include_local, source_dir, path) + + if n is None: + SCons.Warnings.warn(SCons.Warnings.DependencyWarning, + "No dependency generated for file: %s (included from: %s) -- file not found" % (i, node)) + else: + sortkey = self.sort_key(include) + nodes.append((sortkey, n)) + + nodes.sort() + nodes = map(lambda pair: pair[1], nodes) + return nodes diff --git a/src/engine/SCons/Scanner/LaTeXTests.py b/src/engine/SCons/Scanner/LaTeXTests.py index 45a387a..9cfe3ca 100644 --- a/src/engine/SCons/Scanner/LaTeXTests.py +++ b/src/engine/SCons/Scanner/LaTeXTests.py @@ -70,17 +70,17 @@ class DummyEnvironment(UserDict.UserDict): def Dictionary(self, *args): return self.data - def subst(self, strSubst): + def subst(self, strSubst, target=None, source=None, conv=None): if strSubst[0] == '$': return self.data[strSubst[1:]] return strSubst - def subst_list(self, strSubst): + def subst_list(self, strSubst, target=None, source=None, conv=None): if strSubst[0] == '$': return [self.data[strSubst[1:]]] return [[strSubst]] - def subst_path(self, path, target=None, source=None): + def subst_path(self, path, target=None, source=None, conv=None): if type(path) != type([]): path = [path] return map(self.subst, path) diff --git a/src/engine/SCons/Scanner/Prog.py b/src/engine/SCons/Scanner/Prog.py index 54db9a8..e8d1669 100644 --- a/src/engine/SCons/Scanner/Prog.py +++ b/src/engine/SCons/Scanner/Prog.py @@ -80,8 +80,9 @@ def scan(node, env, libpath = ()): result = [] - if callable(libpath): libpath = libpath() - + if callable(libpath): + libpath = libpath() + find_file = SCons.Node.FS.find_file adjustixes = SCons.Util.adjustixes for lib in libs: diff --git a/src/engine/SCons/Scanner/ProgTests.py b/src/engine/SCons/Scanner/ProgTests.py index bac10b7..47d4afd 100644 --- a/src/engine/SCons/Scanner/ProgTests.py +++ b/src/engine/SCons/Scanner/ProgTests.py @@ -71,7 +71,7 @@ class DummyEnvironment: def __delitem__(self,key): del self.Dictionary()[key] - def subst(self, s): + def subst(self, s, target=None, source=None, conv=None): try: if s[0] == '$': return self._dict[s[1:]] @@ -79,7 +79,7 @@ class DummyEnvironment: return '' return s - def subst_path(self, path, target=None, source=None): + def subst_path(self, path, target=None, source=None, conv=None): if type(path) != type([]): path = [path] return map(self.subst, path) @@ -165,12 +165,12 @@ class ProgramScannerTestCase3(unittest.TestCase): class ProgramScannerTestCase5(unittest.TestCase): def runTest(self): class SubstEnvironment(DummyEnvironment): - def subst(self, arg, path=test.workpath("d1")): - if arg == "blah": + def subst(self, arg, target=None, source=None, conv=None, path=test.workpath("d1")): + if arg == "$blah": return test.workpath("d1") else: return arg - env = SubstEnvironment(LIBPATH=[ "blah" ], + env = SubstEnvironment(LIBPATH=[ "$blah" ], LIBS=string.split('l2 l3')) s = SCons.Scanner.Prog.ProgramScanner() path = s.path(env) diff --git a/src/engine/SCons/Scanner/ScannerTests.py b/src/engine/SCons/Scanner/ScannerTests.py index 29ca063..bd8546f 100644 --- a/src/engine/SCons/Scanner/ScannerTests.py +++ b/src/engine/SCons/Scanner/ScannerTests.py @@ -31,27 +31,23 @@ import SCons.Sig import SCons.Scanner class DummyFS: - def __init__(self, search_result=[]): - self.search_result = search_result def File(self, name): return DummyNode(name) - def Rfindalldirs(self, pathlist, cwd): - return self.search_result + pathlist class DummyEnvironment(UserDict.UserDict): def __init__(self, dict=None, **kw): UserDict.UserDict.__init__(self, dict) self.data.update(kw) self.fs = DummyFS() - def subst(self, strSubst): + def subst(self, strSubst, target=None, source=None, conv=None): if strSubst[0] == '$': return self.data[strSubst[1:]] return strSubst - def subst_list(self, strSubst): + def subst_list(self, strSubst, target=None, source=None, conv=None): if strSubst[0] == '$': return [self.data[strSubst[1:]]] return [[strSubst]] - def subst_path(self, path, target=None, source=None): + def subst_path(self, path, target=None, source=None, conv=None): if type(path) != type([]): path = [path] return map(self.subst, path) @@ -61,20 +57,24 @@ class DummyEnvironment(UserDict.UserDict): return factory or self.fs.File class DummyNode: - def __init__(self, name): + def __init__(self, name, search_result=()): self.name = name + self.search_result = tuple(search_result) def rexists(self): return 1 def __str__(self): return self.name + def Rfindalldirs(self, pathlist): + return self.search_result + pathlist class FindPathDirsTestCase(unittest.TestCase): def test_FindPathDirs(self): """Test the FindPathDirs callable class""" env = DummyEnvironment(LIBPATH = [ 'foo' ]) - env.fs = DummyFS(['xxx']) + env.fs = DummyFS() + dir = DummyNode('dir', ['xxx']) fpd = SCons.Scanner.FindPathDirs('LIBPATH') result = fpd(env, dir) assert str(result) == "('xxx', 'foo')", result @@ -473,10 +473,11 @@ class ClassicTestCase(unittest.TestCase): ret = s.function(n, env, ('foo3',)) assert ret == ['def'], ret - # Verify that overall scan results are cached even if individual - # results are de-cached - ret = s.function(n, env, ('foo2',)) - assert ret == ['abc'], 'caching inactive; got: %s'%ret + # We no longer cache overall scan results, which would be returned + # if individual results are de-cached. If we ever restore that + # functionality, this test goes back here. + #ret = s.function(n, env, ('foo2',)) + #assert ret == ['abc'], 'caching inactive; got: %s'%ret # Verify that it sorts what it finds. n.includes = ['xyz', 'uvw'] @@ -501,8 +502,6 @@ class ClassicCPPTestCase(unittest.TestCase): s = SCons.Scanner.ClassicCPP("Test", [], None, "") def _find_file(filename, paths): - if callable(paths): - paths = paths() return paths[0]+'/'+filename save = SCons.Node.FS.find_file diff --git a/src/engine/SCons/Scanner/__init__.py b/src/engine/SCons/Scanner/__init__.py index 1fd77e5..679efca 100644 --- a/src/engine/SCons/Scanner/__init__.py +++ b/src/engine/SCons/Scanner/__init__.py @@ -54,25 +54,6 @@ def Scanner(function, *args, **kw): return apply(Base, (function,) + args, kw) -class _Binder: - def __init__(self, bindval): - self._val = bindval - def __call__(self): - return self._val - def __str__(self): - return str(self._val) - #debug: return 'B<%s>'%str(self._val) - -BinderDict = {} - -def Binder(path): - try: - return BinderDict[path] - except KeyError: - b = _Binder(path) - BinderDict[path] = b - return b - class FindPathDirs: """A class to bind a specific *PATH variable name to a function that @@ -80,16 +61,17 @@ class FindPathDirs: def __init__(self, variable): self.variable = variable def __call__(self, env, dir, target=None, source=None, argument=None): - # The goal is that we've made caching this unnecessary - # because the caching takes place at higher layers. + import SCons.PathList try: path = env[self.variable] except KeyError: return () - path = env.subst_path(path, target=target, source=source) - path_tuple = tuple(env.fs.Rfindalldirs(path, dir)) - return Binder(path_tuple) + dir = dir or env.fs._cwd + path = SCons.PathList.PathList(path).subst_path(env, target, source) + return tuple(dir.Rfindalldirs(path)) + + class Base: """ @@ -97,9 +79,6 @@ class Base: straightforward, single-pass scanning of a single file. """ - if SCons.Memoize.use_memoizer: - __metaclass__ = SCons.Memoize.Memoized_Metaclass - def __init__(self, function, name = "NONE", @@ -257,14 +236,6 @@ class Base: recurse_nodes = _recurse_no_nodes -if SCons.Memoize.use_old_memoization(): - _Base = Base - class Base(SCons.Memoize.Memoizer, _Base): - "Cache-backed version of Scanner Base" - def __init__(self, *args, **kw): - apply(_Base.__init__, (self,)+args, kw) - SCons.Memoize.Memoizer.__init__(self) - class Selector(Base): """ @@ -333,8 +304,6 @@ class Classic(Current): apply(Current.__init__, (self,) + args, kw) def find_include(self, include, source_dir, path): - "__cacheable__" - if callable(path): path = path() n = SCons.Node.FS.find_file(include, (source_dir,) + tuple(path)) return n, include @@ -342,7 +311,6 @@ class Classic(Current): return SCons.Node.FS._my_normcase(include) def scan(self, node, path=()): - "__cacheable__" # cache the includes list in node so we only scan it once: if node.includes != None: @@ -359,6 +327,8 @@ class Classic(Current): # is actually found in a Repository or locally. nodes = [] source_dir = node.get_dir() + if callable(path): + path = path() for include in includes: n, i = self.find_include(include, source_dir, path) @@ -384,14 +354,10 @@ class ClassicCPP(Classic): the contained filename in group 1. """ def find_include(self, include, source_dir, path): - "__cacheable__" - if callable(path): - path = path() #kwq: extend callable to find_file... - if include[0] == '"': - paths = Binder( (source_dir,) + tuple(path) ) + paths = (source_dir,) + tuple(path) else: - paths = Binder( tuple(path) + (source_dir,) ) + paths = tuple(path) + (source_dir,) n = SCons.Node.FS.find_file(include[1], paths) |
