summaryrefslogtreecommitdiffstats
path: root/src/engine/SCons/Sig
diff options
context:
space:
mode:
Diffstat (limited to 'src/engine/SCons/Sig')
-rw-r--r--src/engine/SCons/Sig/SigTests.py28
-rw-r--r--src/engine/SCons/Sig/__init__.py61
2 files changed, 70 insertions, 19 deletions
diff --git a/src/engine/SCons/Sig/SigTests.py b/src/engine/SCons/Sig/SigTests.py
index cc39656..1004e6e 100644
--- a/src/engine/SCons/Sig/SigTests.py
+++ b/src/engine/SCons/Sig/SigTests.py
@@ -122,6 +122,9 @@ class DummyNode:
def store_bsig(self):
pass
+
+ def store_timestamp(self):
+ pass
def builder_sig_adapter(self):
class Adapter:
@@ -492,6 +495,30 @@ class SConsignEntryTestCase(unittest.TestCase):
assert e.get_implicit() == ['foo bletch', 'bar']
assert e.render(m) == "123 456 789 foo bletch\0bar"
+class SConsignFileTestCase(unittest.TestCase):
+
+ def runTest(self):
+ class DummyModule:
+ def to_string(self, sig):
+ return str(sig)
+
+ def from_string(self, sig):
+ return int(sig)
+
+ class DummyNode:
+ path = 'not_a_valid_path'
+
+ f = SCons.Sig.SConsignFile(DummyNode(), DummyModule())
+ f.set_bsig('foo', 1)
+ assert f.get('foo') == (None, 1, None)
+ f.set_csig('foo', 2)
+ assert f.get('foo') == (None, 1, 2)
+ f.set_timestamp('foo', 3)
+ assert f.get('foo') == (3, 1, 2)
+ f.set_implicit('foo', ['bar'])
+ assert f.get('foo') == (3, 1, 2)
+ assert f.get_implicit('foo') == ['bar']
+
def suite():
suite = unittest.TestSuite()
@@ -499,6 +526,7 @@ def suite():
suite.addTest(TimeStampTestCase())
suite.addTest(CalcTestCase())
suite.addTest(SConsignEntryTestCase())
+ suite.addTest(SConsignFileTestCase())
return suite
if __name__ == "__main__":
diff --git a/src/engine/SCons/Sig/__init__.py b/src/engine/SCons/Sig/__init__.py
index 193a326..2c8edad 100644
--- a/src/engine/SCons/Sig/__init__.py
+++ b/src/engine/SCons/Sig/__init__.py
@@ -132,35 +132,61 @@ class SConsignFile:
Get the .sconsign entry for a file
filename - the filename whose signature will be returned
- returns - (timestamp, bsig, csig, implicit)
+ returns - (timestamp, bsig, csig)
"""
try:
entry = self.entries[filename]
return (entry.timestamp, entry.bsig, entry.csig)
except KeyError:
return (None, None, None)
-
- def set(self, filename, timestamp, bsig = None, csig = None):
+
+ def create_entry(self, filename):
"""
- Set the .sconsign entry for a file
-
- filename - the filename whose signature will be set
- timestamp - the timestamp
- module - the signature module being used
- bsig - the file's build signature
- csig - the file's content signature
+ Create an entry for the filename and return it, or if one already exists,
+ then return it.
"""
-
try:
entry = self.entries[filename]
except KeyError:
entry = SConsignEntry(self.module)
self.entries[filename] = entry
+
+ return entry
- entry.timestamp = timestamp
- entry.bsig = bsig
+ def set_csig(self, filename, csig):
+ """
+ Set the csig .sconsign entry for a file
+
+ filename - the filename whose signature will be set
+ csig - the file's content signature
+ """
+
+ entry = self.create_entry(filename)
entry.csig = csig
+ self.dirty = 1
+
+ def set_bsig(self, filename, bsig):
+ """
+ Set the csig .sconsign entry for a file
+
+ filename - the filename whose signature will be set
+ bsig - the file's built signature
+ """
+
+ entry = self.create_entry(filename)
+ entry.bsig = bsig
+ self.dirty = 1
+
+ def set_timestamp(self, filename, timestamp):
+ """
+ Set the csig .sconsign entry for a file
+
+ filename - the filename whose signature will be set
+ timestamp - the file's timestamp
+ """
+ entry = self.create_entry(filename)
+ entry.timestamp = timestamp
self.dirty = 1
def get_implicit(self, filename):
@@ -173,13 +199,9 @@ class SConsignFile:
def set_implicit(self, filename, implicit):
"""Cache the implicit dependencies for 'filename'."""
- try:
- entry = self.entries[filename]
- except KeyError:
- entry = SConsignEntry(self.module)
- self.entries[filename] = entry
-
+ entry = self.create_entry(filename)
entry.set_implicit(implicit)
+ self.dirty = 1
def write(self):
"""
@@ -325,6 +347,7 @@ class Calculator:
if self.max_drift >= 0 and (time.time() - mtime) > self.max_drift:
node.store_csig()
+ node.store_timestamp()
return csig