summaryrefslogtreecommitdiffstats
path: root/src/engine
diff options
context:
space:
mode:
authorSteven Knight <knight@baldmt.com>2004-09-25 14:13:21 (GMT)
committerSteven Knight <knight@baldmt.com>2004-09-25 14:13:21 (GMT)
commite3ef329ae4a73b22e19b9c17816162db2c569911 (patch)
tree985c831e543efa75d35407225e01aa91cf512e68 /src/engine
parentf5f2d8ad9d24df1b0f58477006b784adc4bc8a03 (diff)
downloadSCons-e3ef329ae4a73b22e19b9c17816162db2c569911.zip
SCons-e3ef329ae4a73b22e19b9c17816162db2c569911.tar.gz
SCons-e3ef329ae4a73b22e19b9c17816162db2c569911.tar.bz2
Add a --debug=findlibs option. (Gary Oberbrunner)
Diffstat (limited to 'src/engine')
-rw-r--r--src/engine/SCons/Node/FS.py9
-rw-r--r--src/engine/SCons/Node/FSTests.py23
-rw-r--r--src/engine/SCons/Scanner/Prog.py5
-rw-r--r--src/engine/SCons/Script/__init__.py4
4 files changed, 37 insertions, 4 deletions
diff --git a/src/engine/SCons/Node/FS.py b/src/engine/SCons/Node/FS.py
index be4770f..5cdece1 100644
--- a/src/engine/SCons/Node/FS.py
+++ b/src/engine/SCons/Node/FS.py
@@ -1834,8 +1834,7 @@ class File(Base):
default_fs = FS()
-
-def find_file(filename, paths, node_factory = default_fs.File):
+def find_file(filename, paths, node_factory=default_fs.File, verbose=None):
"""
find_file(str, [Dir()]) -> [nodes]
@@ -1850,8 +1849,12 @@ def find_file(filename, paths, node_factory = default_fs.File):
Only the first file found is returned, and none is returned
if no file is found.
"""
+ if verbose and not SCons.Util.is_String(verbose):
+ verbose = "find_file"
retval = None
for dir in paths:
+ if verbose:
+ sys.stdout.write(" %s: looking for '%s' in '%s' ...\n" % (verbose, filename, dir))
try:
node = node_factory(filename, dir)
# Return true if the node exists or is a derived node.
@@ -1859,6 +1862,8 @@ def find_file(filename, paths, node_factory = default_fs.File):
node.is_pseudo_derived() or \
(isinstance(node, SCons.Node.FS.Base) and node.exists()):
retval = node
+ if verbose:
+ sys.stdout.write(" %s: ... FOUND '%s' in '%s'\n" % (verbose, filename, dir))
break
except TypeError:
# If we find a directory instead of a file, we don't care
diff --git a/src/engine/SCons/Node/FSTests.py b/src/engine/SCons/Node/FSTests.py
index 6bee431..4501cf1 100644
--- a/src/engine/SCons/Node/FSTests.py
+++ b/src/engine/SCons/Node/FSTests.py
@@ -1368,6 +1368,29 @@ class find_fileTestCase(unittest.TestCase):
assert os.path.normpath('./bar/baz') in file_names, file_names
assert os.path.normpath('./pseudo') in file_names, file_names
+ import StringIO
+ save_sys_stdout = sys.stdout
+
+ try:
+ sio = StringIO.StringIO()
+ sys.stdout = sio
+ SCons.Node.FS.find_file('foo', paths, fs.File, verbose="xyz")
+ expect = " xyz: looking for 'foo' in '.' ...\n" + \
+ " xyz: ... FOUND 'foo' in '.'\n"
+ c = sio.getvalue()
+ assert c == expect, c
+
+ sio = StringIO.StringIO()
+ sys.stdout = sio
+ SCons.Node.FS.find_file('baz', paths, fs.File, verbose=1)
+ expect = " find_file: looking for 'baz' in '.' ...\n" + \
+ " find_file: looking for 'baz' in 'bar' ...\n" + \
+ " find_file: ... FOUND 'baz' in 'bar'\n"
+ c = sio.getvalue()
+ assert c == expect, c
+ finally:
+ sys.stdout = save_sys_stdout
+
class StringDirTestCase(unittest.TestCase):
def runTest(self):
"""Test using a string as the second argument of
diff --git a/src/engine/SCons/Scanner/Prog.py b/src/engine/SCons/Scanner/Prog.py
index 78b7233..fa36cad 100644
--- a/src/engine/SCons/Scanner/Prog.py
+++ b/src/engine/SCons/Scanner/Prog.py
@@ -30,6 +30,9 @@ import SCons.Node.FS
import SCons.Scanner
import SCons.Util
+# global, set by --debug=findlibs
+print_find_libs = None
+
def ProgScan(fs = SCons.Node.FS.default_fs, **kw):
"""Return a prototype Scanner instance for scanning executable
files for static-lib dependencies"""
@@ -85,7 +88,7 @@ def scan(node, env, libpath = (), fs = SCons.Node.FS.default_fs):
lib = env.subst(lib)
for pref, suf in pairs:
l = adjustixes(lib, pref, suf)
- l = find_file(l, libpath, fs.File)
+ l = find_file(l, libpath, fs.File, verbose=print_find_libs)
if l:
result.append(l)
else:
diff --git a/src/engine/SCons/Script/__init__.py b/src/engine/SCons/Script/__init__.py
index 4832b02..c40f27e 100644
--- a/src/engine/SCons/Script/__init__.py
+++ b/src/engine/SCons/Script/__init__.py
@@ -420,6 +420,8 @@ def _set_globals(options):
print_dtree = 1
elif options.debug == "explain":
print_explanations = 1
+ elif options.debug == "findlibs":
+ SCons.Scanner.Prog.print_find_libs = "findlibs"
elif options.debug == "includes":
print_includes = 1
elif options.debug == "memory":
@@ -526,7 +528,7 @@ class OptParser(OptionParser):
help="Search up directory tree for SConstruct, "
"build all Default() targets.")
- debug_options = ["count", "dtree", "explain",
+ debug_options = ["count", "dtree", "explain", "findlibs",
"includes", "memory", "objects",
"pdb", "presub", "stacktrace",
"time", "tree"]