diff options
| author | Steven Knight <knight@baldmt.com> | 2002-04-04 09:07:00 (GMT) |
|---|---|---|
| committer | Steven Knight <knight@baldmt.com> | 2002-04-04 09:07:00 (GMT) |
| commit | 6603cc0d6643e529da45fef6f85fcc1a0fc02ea4 (patch) | |
| tree | 4a27de7c3fd70e5af0f257ccc73aab38e343f156 /src/engine/SCons/Scanner/Prog.py | |
| parent | a7669bc6a02999a3375c7e732a27ded5f9bb9935 (diff) | |
| download | SCons-6603cc0d6643e529da45fef6f85fcc1a0fc02ea4.zip SCons-6603cc0d6643e529da45fef6f85fcc1a0fc02ea4.tar.gz SCons-6603cc0d6643e529da45fef6f85fcc1a0fc02ea4.tar.bz2 | |
Fix --debug=tree for directory targets (Anthony Roach)
Diffstat (limited to 'src/engine/SCons/Scanner/Prog.py')
| -rw-r--r-- | src/engine/SCons/Scanner/Prog.py | 87 |
1 files changed, 31 insertions, 56 deletions
diff --git a/src/engine/SCons/Scanner/Prog.py b/src/engine/SCons/Scanner/Prog.py index 9ecc37b..76567ab 100644 --- a/src/engine/SCons/Scanner/Prog.py +++ b/src/engine/SCons/Scanner/Prog.py @@ -31,74 +31,49 @@ import SCons.Node.FS import SCons.Scanner import SCons.Util -class NullProgScanner: - """A do-nothing ProgScanner for Environments that have no LIBS.""" - def scan(node, env, args = []): - return [] - -null_scanner = NullProgScanner() - def ProgScan(fs = SCons.Node.FS.default_fs): """Return a prototype Scanner instance for scanning executable files for static-lib dependencies""" - ps = ProgScanner(scan, "ProgScan") - ps.fs = fs + ps = SCons.Scanner.Base(scan, "ProgScan", fs) return ps -class ProgScanner(SCons.Scanner.Base): - def __init__(self, *args, **kw): - apply(SCons.Scanner.Base.__init__, (self,) + args, kw) - self.hash = None - self.pathscanners = {} - - def instance(self, env): - """ - Return a unique instance of a Prog scanner object for a - given environment. - """ - try: - libs = env.Dictionary('LIBS') - except KeyError: - # There are no LIBS in this environment, so just return the - # fake "scanner" instance that always returns a null list. - return null_scanner - if SCons.Util.is_String(libs): - libs = string.split(libs) +def scan(node, env, target, fs): + """ + This scanner scans program files for static-library + dependencies. It will search the LIBPATH environment variable + for libraries specified in the LIBS variable, returning any + files it finds as dependencies. + """ - try: - dirs = tuple(SCons.Node.arg2nodes(env.Dictionary('LIBPATH'), - self.fs.Dir)) - except: - dirs = () + # This function caches information in target: + # target.libpath - env['LIBPATH'] converted to nodes + if not hasattr(target, 'libpath'): + def Dir(x, dir=target.cwd, fs=fs): return fs.Dir(x,dir) try: - prefix = env.Dictionary('LIBPREFIX') + target.libpath = tuple(SCons.Node.arg2nodes(env['LIBPATH'],Dir)) except KeyError: - prefix = '' + target.libpath = () + + libpath = target.libpath - try: - suffix = env.Dictionary('LIBSUFFIX') - except KeyError: - suffix = '' + try: + libs = env.Dictionary('LIBS') + except KeyError: + # There are no LIBS in this environment, so just return a null list: + return [] + if SCons.Util.is_String(libs): + libs = string.split(libs) - key = (dirs, tuple(libs), prefix, suffix) - if not self.pathscanners.has_key(key): - clone = copy.copy(self) - clone.hash = key - clone.argument = [self.fs, dirs, libs, prefix, suffix] # XXX reaching into object - self.pathscanners[key] = clone - return self.pathscanners[key] + try: + prefix = env.Dictionary('LIBPREFIX') + except KeyError: + prefix = '' - def __hash__(self): - return hash(self.hash) + try: + suffix = env.Dictionary('LIBSUFFIX') + except KeyError: + suffix = '' -def scan(node, env, args = [SCons.Node.FS.default_fs, (), [], '', '']): - """ - This scanner scans program files for static-library - dependencies. It will search the LIBPATH environment variable - for libraries specified in the LIBS variable, returning any - files it finds as dependencies. - """ - fs, libpath, libs, prefix, suffix = args libs = map(lambda x, s=suffix, p=prefix: p + x + s, libs) return SCons.Node.FS.find_files(libs, libpath, fs.File) |
