diff options
author | Steven Knight <knight@baldmt.com> | 2001-10-29 05:33:03 (GMT) |
---|---|---|
committer | Steven Knight <knight@baldmt.com> | 2001-10-29 05:33:03 (GMT) |
commit | 15928490b955a3d4ea4966102dc915ed0fdb8526 (patch) | |
tree | 4b7b65dd605a53881ad0ee1977cea88db9f31885 /src/engine | |
parent | 3bce8a9e6e70d61723e4824bd7ba84a7b9547456 (diff) | |
download | SCons-15928490b955a3d4ea4966102dc915ed0fdb8526.zip SCons-15928490b955a3d4ea4966102dc915ed0fdb8526.tar.gz SCons-15928490b955a3d4ea4966102dc915ed0fdb8526.tar.bz2 |
Handle SConscript files in subdirectories.
Diffstat (limited to 'src/engine')
-rw-r--r-- | src/engine/SCons/Node/FS.py | 9 | ||||
-rw-r--r-- | src/engine/SCons/Node/FSTests.py | 8 | ||||
-rw-r--r-- | src/engine/SCons/Sig/MD5.py | 6 | ||||
-rw-r--r-- | src/engine/SCons/Sig/MD5Tests.py | 7 |
4 files changed, 28 insertions, 2 deletions
diff --git a/src/engine/SCons/Node/FS.py b/src/engine/SCons/Node/FS.py index c3566a6..860f46b 100644 --- a/src/engine/SCons/Node/FS.py +++ b/src/engine/SCons/Node/FS.py @@ -120,6 +120,7 @@ class FS: self.Top = self.__doLookup(Dir, path) self.Top.path = '.' self.Top.path_ = './' + self.cwd = self.Top def __doLookup(self, fsclass, name, directory=None): """This method differs from the File and Dir factory methods in @@ -188,9 +189,15 @@ class FS: directory = self.Top name = os.path.join(os.path.normpath('./'), name[1:]) elif not directory: - directory = self.Top + directory = self.cwd return (name, directory) + def chdir(self, dir): + """Change the current working directory for lookups. + """ + if not dir is None: + self.cwd = dir + def Entry(self, name, directory = None): """Lookup or create a generic Entry node with the specified name. If the name is a relative path (begins with ./, ../, or a file diff --git a/src/engine/SCons/Node/FSTests.py b/src/engine/SCons/Node/FSTests.py index 360132a..430d4b4 100644 --- a/src/engine/SCons/Node/FSTests.py +++ b/src/engine/SCons/Node/FSTests.py @@ -278,6 +278,14 @@ class FSTestCase(unittest.TestCase): assert d10.get_bsig() is None, d10.get_bsig() assert d10.get_csig() is None, d10.get_csig() + fs.chdir(fs.Dir('subdir')) + f11 = fs.File("f11") + assert f11.path == "subdir/f11" + d12 = fs.Dir("d12") + assert d12.path_ == "subdir/d12/" + e13 = fs.Entry("subdir/e13") + assert e13.path == "subdir/subdir/e13" + #XXX test exists() #XXX test current() for directories diff --git a/src/engine/SCons/Sig/MD5.py b/src/engine/SCons/Sig/MD5.py index 11ba961..e13669e 100644 --- a/src/engine/SCons/Sig/MD5.py +++ b/src/engine/SCons/Sig/MD5.py @@ -78,7 +78,11 @@ def collect(signatures): def signature(obj): """Generate a signature for an object """ - return hexdigest(md5.new(obj.get_contents()).digest()) + try: + contents = obj.get_contents() + except AttributeError: + raise AttributeError, "unable to fetch contents of '%s'" % str(obj) + return hexdigest(md5.new(contents).digest()) def to_string(signature): """Convert a signature to a string""" diff --git a/src/engine/SCons/Sig/MD5Tests.py b/src/engine/SCons/Sig/MD5Tests.py index 641dcb0..f9cf61f 100644 --- a/src/engine/SCons/Sig/MD5Tests.py +++ b/src/engine/SCons/Sig/MD5Tests.py @@ -75,6 +75,13 @@ class MD5TestCase(unittest.TestCase): o1 = my_obj(value = '111') assert '698d51a19d8a121ce581499d7b701668' == signature(o1) + try: + signature('string') + except AttributeError, e: + assert str(e) == "unable to fetch contents of 'string'" + else: + raise AttributeError, "unexpected get_contents() attribute" + def test_to_string(self): assert '698d51a19d8a121ce581499d7b701668' == to_string('698d51a19d8a121ce581499d7b701668') |