From 7c651e273c4db37f4babd91aaecf26800c50dd79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Frings-F=C3=BCrst?= Date: Thu, 28 Sep 2017 10:21:20 +0200 Subject: New upstream version 3.0.0 --- engine/SCons/Scanner/C.py | 11 ++-- engine/SCons/Scanner/D.py | 20 +++--- engine/SCons/Scanner/Dir.py | 6 +- engine/SCons/Scanner/Fortran.py | 4 +- engine/SCons/Scanner/IDL.py | 4 +- engine/SCons/Scanner/LaTeX.py | 129 ++++++++++++++++++++++++++------------- engine/SCons/Scanner/Prog.py | 4 +- engine/SCons/Scanner/RC.py | 27 +++++--- engine/SCons/Scanner/SWIG.py | 4 +- engine/SCons/Scanner/__init__.py | 42 +++++++------ 10 files changed, 158 insertions(+), 93 deletions(-) (limited to 'engine/SCons/Scanner') diff --git a/engine/SCons/Scanner/C.py b/engine/SCons/Scanner/C.py index d78bd05..6cdab4a 100644 --- a/engine/SCons/Scanner/C.py +++ b/engine/SCons/Scanner/C.py @@ -5,7 +5,7 @@ This module implements the dependency scanner for C/C++ code. """ # -# Copyright (c) 2001 - 2016 The SCons Foundation +# Copyright (c) 2001 - 2017 The SCons Foundation # # Permission is hereby granted, free of charge, to any person obtaining # a copy of this software and associated documentation files (the @@ -27,7 +27,7 @@ This module implements the dependency scanner for C/C++ code. # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -__revision__ = "src/engine/SCons/Scanner/C.py rel_2.5.1:3735:9dc6cee5c168 2016/11/03 14:02:02 bdbaddog" +__revision__ = "src/engine/SCons/Scanner/C.py rel_3.0.0:4395:8972f6a2f699 2017/09/18 12:59:24 bdbaddog" import SCons.Node.FS import SCons.Scanner @@ -58,12 +58,11 @@ class SConsCPPScanner(SCons.cpp.PreProcessor): return result def read_file(self, file): try: - fp = open(str(file.rfile())) - except EnvironmentError, e: + with open(str(file.rfile())) as fp: + return fp.read() + except EnvironmentError as e: self.missing.append((file, self.current_file)) return '' - else: - return fp.read() def dictify_CPPDEFINES(env): cppdefines = env.get('CPPDEFINES', {}) diff --git a/engine/SCons/Scanner/D.py b/engine/SCons/Scanner/D.py index 0df6406..3b6f2f9 100644 --- a/engine/SCons/Scanner/D.py +++ b/engine/SCons/Scanner/D.py @@ -8,7 +8,7 @@ Coded by Andy Friesen """ # -# Copyright (c) 2001 - 2016 The SCons Foundation +# Copyright (c) 2001 - 2017 The SCons Foundation # # Permission is hereby granted, free of charge, to any person obtaining # a copy of this software and associated documentation files (the @@ -30,9 +30,7 @@ Coded by Andy Friesen # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -__revision__ = "src/engine/SCons/Scanner/D.py rel_2.5.1:3735:9dc6cee5c168 2016/11/03 14:02:02 bdbaddog" - -import re +__revision__ = "src/engine/SCons/Scanner/D.py rel_3.0.0:4395:8972f6a2f699 2017/09/18 12:59:24 bdbaddog" import SCons.Scanner @@ -43,13 +41,13 @@ def DScanner(): class D(SCons.Scanner.Classic): def __init__ (self): - SCons.Scanner.Classic.__init__ (self, + SCons.Scanner.Classic.__init__ ( + self, name = "DScanner", suffixes = '$DSUFFIXES', path_variable = 'DPATH', - regex = 'import\s+(?:[a-zA-Z0-9_.]+)\s*(?:,\s*(?:[a-zA-Z0-9_.]+)\s*)*;') - - self.cre2 = re.compile ('(?:import\s)?\s*([a-zA-Z0-9_.]+)\s*(?:,|;)', re.M) + regex = '(?:import\s+)([\w\s=,.]+)(?:\s*:[\s\w,=]+)?(?:;)' + ) def find_include(self, include, source_dir, path): # translate dots (package separators) to slashes @@ -62,8 +60,10 @@ class D(SCons.Scanner.Classic): def find_include_names(self, node): includes = [] - for i in self.cre.findall(node.get_text_contents()): - includes = includes + self.cre2.findall(i) + for iii in self.cre.findall(node.get_text_contents()): + for jjj in iii.split(','): + kkk = jjj.split('=')[-1] + includes.append(kkk.strip()) return includes # Local Variables: diff --git a/engine/SCons/Scanner/Dir.py b/engine/SCons/Scanner/Dir.py index eefba8b..66d5b6d 100644 --- a/engine/SCons/Scanner/Dir.py +++ b/engine/SCons/Scanner/Dir.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2001 - 2016 The SCons Foundation +# Copyright (c) 2001 - 2017 The SCons Foundation # # Permission is hereby granted, free of charge, to any person obtaining # a copy of this software and associated documentation files (the @@ -20,14 +20,14 @@ # 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__ = "src/engine/SCons/Scanner/Dir.py rel_2.5.1:3735:9dc6cee5c168 2016/11/03 14:02:02 bdbaddog" +__revision__ = "src/engine/SCons/Scanner/Dir.py rel_3.0.0:4395:8972f6a2f699 2017/09/18 12:59:24 bdbaddog" import SCons.Node.FS import SCons.Scanner def only_dirs(nodes): is_Dir = lambda n: isinstance(n.disambiguate(), SCons.Node.FS.Dir) - return list(filter(is_Dir, nodes)) + return [node for node in nodes if is_Dir(node)] def DirScanner(**kw): """Return a prototype Scanner instance for scanning diff --git a/engine/SCons/Scanner/Fortran.py b/engine/SCons/Scanner/Fortran.py index 179c8db..8a8f3eb 100644 --- a/engine/SCons/Scanner/Fortran.py +++ b/engine/SCons/Scanner/Fortran.py @@ -5,7 +5,7 @@ This module implements the dependency scanner for Fortran code. """ # -# Copyright (c) 2001 - 2016 The SCons Foundation +# Copyright (c) 2001 - 2017 The SCons Foundation # # Permission is hereby granted, free of charge, to any person obtaining # a copy of this software and associated documentation files (the @@ -26,7 +26,7 @@ This module implements the dependency scanner for Fortran code. # 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__ = "src/engine/SCons/Scanner/Fortran.py rel_2.5.1:3735:9dc6cee5c168 2016/11/03 14:02:02 bdbaddog" +__revision__ = "src/engine/SCons/Scanner/Fortran.py rel_3.0.0:4395:8972f6a2f699 2017/09/18 12:59:24 bdbaddog" import re diff --git a/engine/SCons/Scanner/IDL.py b/engine/SCons/Scanner/IDL.py index b7b76fd..706ff41 100644 --- a/engine/SCons/Scanner/IDL.py +++ b/engine/SCons/Scanner/IDL.py @@ -6,7 +6,7 @@ Definition Language) files. """ # -# Copyright (c) 2001 - 2016 The SCons Foundation +# Copyright (c) 2001 - 2017 The SCons Foundation # # Permission is hereby granted, free of charge, to any person obtaining # a copy of this software and associated documentation files (the @@ -28,7 +28,7 @@ Definition Language) files. # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -__revision__ = "src/engine/SCons/Scanner/IDL.py rel_2.5.1:3735:9dc6cee5c168 2016/11/03 14:02:02 bdbaddog" +__revision__ = "src/engine/SCons/Scanner/IDL.py rel_3.0.0:4395:8972f6a2f699 2017/09/18 12:59:24 bdbaddog" import SCons.Node.FS import SCons.Scanner diff --git a/engine/SCons/Scanner/LaTeX.py b/engine/SCons/Scanner/LaTeX.py index 0a68b7e..69154bd 100644 --- a/engine/SCons/Scanner/LaTeX.py +++ b/engine/SCons/Scanner/LaTeX.py @@ -5,7 +5,7 @@ This module implements the dependency scanner for LaTeX code. """ # -# Copyright (c) 2001 - 2016 The SCons Foundation +# Copyright (c) 2001 - 2017 The SCons Foundation # # Permission is hereby granted, free of charge, to any person obtaining # a copy of this software and associated documentation files (the @@ -27,7 +27,7 @@ This module implements the dependency scanner for LaTeX code. # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -__revision__ = "src/engine/SCons/Scanner/LaTeX.py rel_2.5.1:3735:9dc6cee5c168 2016/11/03 14:02:02 bdbaddog" +__revision__ = "src/engine/SCons/Scanner/LaTeX.py rel_3.0.0:4395:8972f6a2f699 2017/09/18 12:59:24 bdbaddog" import os.path import re @@ -37,7 +37,9 @@ import SCons.Util # list of graphics file extensions for TeX and LaTeX TexGraphics = ['.eps', '.ps'] -LatexGraphics = ['.pdf', '.png', '.jpg', '.gif', '.tif'] +#LatexGraphics = ['.pdf', '.png', '.jpg', '.gif', '.tif'] +LatexGraphics = [ '.png', '.jpg', '.gif', '.tif'] + # Used as a return value of modify_env_var if the variable is not set. class _Null(object): @@ -76,8 +78,10 @@ def modify_env_var(env, var, abspath): return save class FindENVPathDirs(object): - """A class to bind a specific *PATH variable name to a function that - will return all of the *path directories.""" + """ + A class to bind a specific E{*}PATH variable name to a function that + will return all of the E{*}path directories. + """ def __init__(self, variable): self.variable = variable def __call__(self, env, dir=None, target=None, source=None, argument=None): @@ -94,7 +98,8 @@ class FindENVPathDirs(object): def LaTeXScanner(): - """Return a prototype Scanner instance for scanning LaTeX source files + """ + Return a prototype Scanner instance for scanning LaTeX source files when built with latex. """ ds = LaTeX(name = "LaTeXScanner", @@ -105,7 +110,8 @@ def LaTeXScanner(): return ds def PDFLaTeXScanner(): - """Return a prototype Scanner instance for scanning LaTeX source files + """ + Return a prototype Scanner instance for scanning LaTeX source files when built with pdflatex. """ ds = LaTeX(name = "PDFLaTeXScanner", @@ -116,7 +122,8 @@ def PDFLaTeXScanner(): return ds class LaTeX(SCons.Scanner.Base): - """Class for scanning LaTeX files for included files. + """ + Class for scanning LaTeX files for included files. Unlike most scanners, which use regular expressions that just return the included file name, this returns a tuple consisting @@ -133,10 +140,12 @@ class LaTeX(SCons.Scanner.Base): The actual subset and search order may be altered by DeclareGraphicsExtensions command. This complication is ignored. - The default order corresponds to experimentation with teTeX + The default order corresponds to experimentation with teTeX:: + $ latex --version pdfeTeX 3.141592-1.21a-2.2 (Web2C 7.5.4) kpathsea version 3.5.4 + The order is: ['.eps', '.ps'] for latex ['.png', '.pdf', '.jpg', '.tif']. @@ -148,8 +157,7 @@ class LaTeX(SCons.Scanner.Base): env['TEXINPUTS'] for "lstinputlisting" keyword env['BIBINPUTS'] for "bibliography" keyword env['BSTINPUTS'] for "bibliographystyle" keyword - env['INDEXSTYLE'] for "makeindex" keyword, no scanning support needed - just allows user to set it if needed. + env['INDEXSTYLE'] for "makeindex" keyword, no scanning support needed just allows user to set it if needed. FIXME: also look for the class or style in document[class|style]{} FIXME: also look for the argument of bibliographystyle{} @@ -166,6 +174,9 @@ class LaTeX(SCons.Scanner.Base): 'usepackage': 'TEXINPUTS', 'lstinputlisting': 'TEXINPUTS'} env_variables = SCons.Util.unique(list(keyword_paths.values())) + two_arg_commands = ['import', 'subimport', + 'includefrom', 'subincludefrom', + 'inputfrom', 'subinputfrom'] def __init__(self, name, suffixes, graphics_extensions, *args, **kw): @@ -175,8 +186,29 @@ class LaTeX(SCons.Scanner.Base): # line followed by one or more newline characters (i.e. blank # lines), interfering with a match on the next line. # add option for whitespace before the '[options]' or the '{filename}' - regex = r'^[^%\n]*\\(include|includegraphics(?:\s*\[[^\]]+\])?|lstinputlisting(?:\[[^\]]+\])?|input|bibliography|addbibresource|addglobalbib|addsectionbib|usepackage)\s*{([^}]*)}' - self.cre = re.compile(regex, re.M) + regex = r''' + ^[^%\n]* + \\( + include + | includegraphics(?:\s*\[[^\]]+\])? + | lstinputlisting(?:\[[^\]]+\])? + | input + | import + | subimport + | includefrom + | subincludefrom + | inputfrom + | subinputfrom + | bibliography + | addbibresource + | addglobalbib + | addsectionbib + | usepackage + ) + \s*{([^}]*)} # first arg + (?: \s*{([^}]*)} )? # maybe another arg + ''' + self.cre = re.compile(regex, re.M | re.X) self.comment_re = re.compile(r'^((?:(?:\\%)|[^%\n])*)(.*)$', re.M) self.graphics_extensions = graphics_extensions @@ -236,23 +268,26 @@ class LaTeX(SCons.Scanner.Base): SCons.Scanner.Base.__init__(self, *args, **kw) - def _latex_names(self, include): - filename = include[1] - if include[0] == 'input': + def _latex_names(self, include_type, filename): + if include_type == 'input': + base, ext = os.path.splitext( filename ) + if ext == "": + return [filename + '.tex'] + if include_type in ('include', 'import', 'subimport', + 'includefrom', 'subincludefrom', + 'inputfrom', 'subinputfrom'): base, ext = os.path.splitext( filename ) if ext == "": return [filename + '.tex'] - if (include[0] == 'include'): - return [filename + '.tex'] - if include[0] == 'bibliography': + if include_type == 'bibliography': base, ext = os.path.splitext( filename ) if ext == "": return [filename + '.bib'] - if include[0] == 'usepackage': + if include_type == 'usepackage': base, ext = os.path.splitext( filename ) if ext == "": return [filename + '.sty'] - if include[0] == 'includegraphics': + if include_type == 'includegraphics': base, ext = os.path.splitext( filename ) if ext == "": #return [filename+e for e in self.graphics_extensions + TexGraphics] @@ -267,21 +302,26 @@ class LaTeX(SCons.Scanner.Base): return SCons.Node.FS._my_normcase(str(include)) def find_include(self, include, source_dir, path): + inc_type, inc_subdir, inc_filename = include try: - sub_path = path[include[0]] + sub_paths = path[inc_type] except (IndexError, KeyError): - sub_path = () - try_names = self._latex_names(include) + sub_paths = ((), ()) + try_names = self._latex_names(inc_type, inc_filename) + + # There are three search paths to try: + # 1. current directory "source_dir" + # 2. env[var] + # 3. env['ENV'][var] + search_paths = [(source_dir,)] + list(sub_paths) + for n in try_names: - # see if we find it using the path in env[var] - i = SCons.Node.FS.find_file(n, (source_dir,) + sub_path[0]) - if i: - return i, include - # see if we find it using the path in env['ENV'][var] - i = SCons.Node.FS.find_file(n, (source_dir,) + sub_path[1]) - if i: - return i, include - return i, include + for search_path in search_paths: + paths = tuple([d.Dir(inc_subdir) for d in search_path]) + i = SCons.Node.FS.find_file(n, paths) + if i: + return i, include + return None, include def canonical_text(self, text): """Standardize an input TeX-file contents. @@ -300,7 +340,7 @@ class LaTeX(SCons.Scanner.Base): line_continues_a_comment = len(comment) > 0 return '\n'.join(out).rstrip()+'\n' - def scan(self, node): + def scan(self, node, subdir='.'): # 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. @@ -326,9 +366,14 @@ class LaTeX(SCons.Scanner.Base): split_includes = [] for include in includes: inc_type = noopt_cre.sub('', include[0]) - inc_list = include[1].split(',') + inc_subdir = subdir + if inc_type in self.two_arg_commands: + inc_subdir = os.path.join(subdir, include[1]) + inc_list = include[2].split(',') + else: + inc_list = include[1].split(',') for j in range(len(inc_list)): - split_includes.append( (inc_type, inc_list[j]) ) + split_includes.append( (inc_type, inc_subdir, inc_list[j]) ) # includes = split_includes node.includes = includes @@ -359,11 +404,13 @@ class LaTeX(SCons.Scanner.Base): while queue: include = queue.pop() + inc_type, inc_subdir, inc_filename = include + try: - if seen[include[1]] == 1: + if seen[inc_filename] == 1: continue except KeyError: - seen[include[1]] = 1 + seen[inc_filename] = 1 # # Handle multiple filenames in include[1] @@ -372,14 +419,14 @@ class LaTeX(SCons.Scanner.Base): if n is None: # Do not bother with 'usepackage' warnings, as they most # likely refer to system-level files - if include[0] != 'usepackage': + if inc_type != 'usepackage': 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(n) nodes.append((sortkey, n)) - # recurse down - queue.extend( self.scan(n) ) + # recurse down + queue.extend( self.scan(n, inc_subdir) ) return [pair[1] for pair in sorted(nodes)] diff --git a/engine/SCons/Scanner/Prog.py b/engine/SCons/Scanner/Prog.py index 8e3245e..63d5a38 100644 --- a/engine/SCons/Scanner/Prog.py +++ b/engine/SCons/Scanner/Prog.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2001 - 2016 The SCons Foundation +# Copyright (c) 2001 - 2017 The SCons Foundation # # Permission is hereby granted, free of charge, to any person obtaining # a copy of this software and associated documentation files (the @@ -21,7 +21,7 @@ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -__revision__ = "src/engine/SCons/Scanner/Prog.py rel_2.5.1:3735:9dc6cee5c168 2016/11/03 14:02:02 bdbaddog" +__revision__ = "src/engine/SCons/Scanner/Prog.py rel_3.0.0:4395:8972f6a2f699 2017/09/18 12:59:24 bdbaddog" import SCons.Node import SCons.Node.FS diff --git a/engine/SCons/Scanner/RC.py b/engine/SCons/Scanner/RC.py index 57e9e7f..4202362 100644 --- a/engine/SCons/Scanner/RC.py +++ b/engine/SCons/Scanner/RC.py @@ -6,7 +6,7 @@ Definition Language) files. """ # -# Copyright (c) 2001 - 2016 The SCons Foundation +# Copyright (c) 2001 - 2017 The SCons Foundation # # Permission is hereby granted, free of charge, to any person obtaining # a copy of this software and associated documentation files (the @@ -28,23 +28,34 @@ Definition Language) files. # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -__revision__ = "src/engine/SCons/Scanner/RC.py rel_2.5.1:3735:9dc6cee5c168 2016/11/03 14:02:02 bdbaddog" +__revision__ = "src/engine/SCons/Scanner/RC.py rel_3.0.0:4395:8972f6a2f699 2017/09/18 12:59:24 bdbaddog" + +import re import SCons.Node.FS import SCons.Scanner -import re + + +def no_tlb(nodes): + """ + Filter out .tlb files as they are binary and shouldn't be scanned + """ + # print("Nodes:%s"%[str(n) for n in nodes]) + return [n for n in nodes if str(n)[-4:] != '.tlb'] + def RCScan(): """Return a prototype Scanner instance for scanning RC source files""" - + res_re= r'^(?:\s*#\s*(?:include)|' \ '.*?\s+(?:ICON|BITMAP|CURSOR|HTML|FONT|MESSAGETABLE|TYPELIB|REGISTRY|D3DFX)' \ '\s*.*?)' \ '\s*(<|"| )([^>"\s]+)(?:[>"\s])*$' - resScanner = SCons.Scanner.ClassicCPP( "ResourceScanner", - "$RCSUFFIXES", - "CPPPATH", - res_re ) + resScanner = SCons.Scanner.ClassicCPP("ResourceScanner", + "$RCSUFFIXES", + "CPPPATH", + res_re, + recursive=no_tlb) return resScanner diff --git a/engine/SCons/Scanner/SWIG.py b/engine/SCons/Scanner/SWIG.py index 4114c1f..048574c 100644 --- a/engine/SCons/Scanner/SWIG.py +++ b/engine/SCons/Scanner/SWIG.py @@ -5,7 +5,7 @@ This module implements the dependency scanner for SWIG code. """ # -# Copyright (c) 2001 - 2016 The SCons Foundation +# Copyright (c) 2001 - 2017 The SCons Foundation # # Permission is hereby granted, free of charge, to any person obtaining # a copy of this software and associated documentation files (the @@ -27,7 +27,7 @@ This module implements the dependency scanner for SWIG code. # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -__revision__ = "src/engine/SCons/Scanner/SWIG.py rel_2.5.1:3735:9dc6cee5c168 2016/11/03 14:02:02 bdbaddog" +__revision__ = "src/engine/SCons/Scanner/SWIG.py rel_3.0.0:4395:8972f6a2f699 2017/09/18 12:59:24 bdbaddog" import SCons.Scanner diff --git a/engine/SCons/Scanner/__init__.py b/engine/SCons/Scanner/__init__.py index 81617a4..73e8c09 100644 --- a/engine/SCons/Scanner/__init__.py +++ b/engine/SCons/Scanner/__init__.py @@ -5,7 +5,7 @@ The Scanner package for the SCons software construction utility. """ # -# Copyright (c) 2001 - 2016 The SCons Foundation +# Copyright (c) 2001 - 2017 The SCons Foundation # # Permission is hereby granted, free of charge, to any person obtaining # a copy of this software and associated documentation files (the @@ -27,7 +27,7 @@ The Scanner package for the SCons software construction utility. # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -__revision__ = "src/engine/SCons/Scanner/__init__.py rel_2.5.1:3735:9dc6cee5c168 2016/11/03 14:02:02 bdbaddog" +__revision__ = "src/engine/SCons/Scanner/__init__.py rel_3.0.0:4395:8972f6a2f699 2017/09/18 12:59:24 bdbaddog" import re @@ -62,8 +62,10 @@ def Scanner(function, *args, **kw): class FindPathDirs(object): - """A class to bind a specific *PATH variable name to a function that - will return all of the *path directories.""" + """ + A class to bind a specific E{*}PATH variable name to a function that + will return all of the E{*}path directories. + """ def __init__(self, variable): self.variable = variable def __call__(self, env, dir=None, target=None, source=None, argument=None): @@ -188,12 +190,12 @@ class Base(object): def path(self, env, dir=None, target=None, source=None): if not self.path_function: return () - if not self.argument is _null: + if self.argument is not _null: return self.path_function(env, dir, target, source, self.argument) else: return self.path_function(env, dir, target, source) - def __call__(self, node, env, path = ()): + def __call__(self, node, env, path=()): """ This method scans a single object. 'node' is the node that will be passed to the scanner function, and 'env' is the @@ -206,27 +208,27 @@ class Base(object): self = self.select(node) if not self.argument is _null: - list = self.function(node, env, path, self.argument) + node_list = self.function(node, env, path, self.argument) else: - list = self.function(node, env, path) + node_list = self.function(node, env, path) kw = {} if hasattr(node, 'dir'): kw['directory'] = node.dir node_factory = env.get_factory(self.node_factory) nodes = [] - for l in list: + for l in node_list: if self.node_class and not isinstance(l, self.node_class): l = node_factory(l, **kw) nodes.append(l) return nodes - def __cmp__(self, other): + def __eq__(self, other): try: - return cmp(self.__dict__, other.__dict__) + return self.__dict__ == other.__dict__ except AttributeError: # other probably doesn't have a __dict__ - return cmp(self.__dict__, other) + return self.__dict__ == other def __hash__(self): return id(self) @@ -259,7 +261,7 @@ class Base(object): def _recurse_no_nodes(self, nodes): return [] - recurse_nodes = _recurse_no_nodes + # recurse_nodes = _recurse_no_nodes def add_scanner(self, skey, scanner): self.function[skey] = scanner @@ -283,7 +285,7 @@ class Selector(Base): self.dict = dict self.skeys = list(dict.keys()) - def __call__(self, node, env, path = ()): + def __call__(self, node, env, path=()): return self.select(node)(node, env, path) def select(self, node): @@ -326,7 +328,7 @@ class Classic(Current): self.cre = re.compile(regex, re.M) - def _scan(node, env, path=(), self=self): + def _scan(node, _, path=(), self=self): node = node.rfile() if not node.exists(): return [] @@ -334,7 +336,12 @@ class Classic(Current): kw['function'] = _scan kw['path_function'] = FindPathDirs(path_variable) - kw['recursive'] = 1 + + # Allow recursive to propagate if child class specifies. + # In this case resource scanner needs to specify a filter on which files + # get recursively processed. Previously was hardcoded to 1 instead of + # defaulted to 1. + kw['recursive'] = kw.get('recursive', 1) kw['skeys'] = suffixes kw['name'] = name @@ -356,7 +363,7 @@ class Classic(Current): if node.includes is not None: includes = node.includes else: - includes = self.find_include_names (node) + includes = self.find_include_names(node) # Intern the names of the include files. Saves some memory # if the same header is included many times. node.includes = list(map(SCons.Util.silent_intern, includes)) @@ -393,6 +400,7 @@ class ClassicCPP(Classic): the contained filename in group 1. """ def find_include(self, include, source_dir, path): + include = list(map(SCons.Util.to_str, include)) if include[0] == '"': paths = (source_dir,) + tuple(path) else: -- cgit v1.2.3