summaryrefslogtreecommitdiffstats
path: root/src/engine/SCons/Sig
diff options
context:
space:
mode:
authorSteven Knight <knight@baldmt.com>2003-11-03 23:29:02 (GMT)
committerSteven Knight <knight@baldmt.com>2003-11-03 23:29:02 (GMT)
commit6c596f1833a9e169e97356721d82a1ccf5fa37cc (patch)
tree387b2d0018114bbc86c7cd916ee8987c77e5a6ee /src/engine/SCons/Sig
parentd64a435c6ad5196230fea4e8637d1ba03959b676 (diff)
downloadSCons-6c596f1833a9e169e97356721d82a1ccf5fa37cc.zip
SCons-6c596f1833a9e169e97356721d82a1ccf5fa37cc.tar.gz
SCons-6c596f1833a9e169e97356721d82a1ccf5fa37cc.tar.bz2
Sync CVS log from master Aegis repository.
Diffstat (limited to 'src/engine/SCons/Sig')
-rw-r--r--src/engine/SCons/Sig/SigTests.py36
-rw-r--r--src/engine/SCons/Sig/__init__.py36
2 files changed, 57 insertions, 15 deletions
diff --git a/src/engine/SCons/Sig/SigTests.py b/src/engine/SCons/Sig/SigTests.py
index c82d2c5..f297464 100644
--- a/src/engine/SCons/Sig/SigTests.py
+++ b/src/engine/SCons/Sig/SigTests.py
@@ -490,6 +490,41 @@ class SConsignDirFileTestCase(unittest.TestCase):
assert f.get('foo') == (3, 1, 2)
assert f.get_implicit('foo') == ['bar']
+class SConsignFileTestCase(unittest.TestCase):
+
+ def runTest(self):
+ test = TestCmd.TestCmd(workdir = '')
+ file = test.workpath('sconsign_file')
+
+ assert SCons.Sig.SConsign_db is None, SCons.Sig.SConsign_db
+
+ SCons.Sig.SConsignFile(file)
+
+ assert not SCons.Sig.SConsign_db is None, SCons.Sig.SConsign_db
+
+ class Fake_DBM:
+ def open(self, name, mode):
+ self.name = name
+ self.mode = mode
+ return self
+
+ fake_dbm = Fake_DBM()
+
+ SCons.Sig.SConsignFile(file, fake_dbm)
+
+ assert not SCons.Sig.SConsign_db is None, SCons.Sig.SConsign_db
+ assert not hasattr(fake_dbm, 'name'), fake_dbm
+ assert not hasattr(fake_dbm, 'mode'), fake_dbm
+
+ SCons.Sig.SConsign_db = None
+
+ SCons.Sig.SConsignFile(file, fake_dbm)
+
+ assert not SCons.Sig.SConsign_db is None, SCons.Sig.SConsign_db
+ assert fake_dbm.name == file, fake_dbm.name
+ assert fake_dbm.mode == "c", fake_dbm.mode
+
+
def suite():
suite = unittest.TestSuite()
@@ -500,6 +535,7 @@ def suite():
suite.addTest(_SConsignTestCase())
suite.addTest(SConsignDBTestCase())
suite.addTest(SConsignDirFileTestCase())
+ 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 298db66..a2ebd5c 100644
--- a/src/engine/SCons/Sig/__init__.py
+++ b/src/engine/SCons/Sig/__init__.py
@@ -51,10 +51,6 @@ sig_files = []
SConsign_db = None
-# 1 means use build signature for derived source files
-# 0 means use content signature for derived source files
-build_signature = 1
-
def write():
global sig_files
for sig_file in sig_files:
@@ -121,7 +117,7 @@ class _SConsign:
"""
try:
return self.entries[filename]
- except:
+ except (KeyError, AttributeError):
return SConsignEntry()
def set_entry(self, filename, entry):
@@ -202,6 +198,8 @@ class SConsignDB(_SConsign):
if type(self.entries) is not type({}):
self.entries = {}
raise TypeError
+ except KeyboardInterrupt:
+ raise
except:
SCons.Warnings.warn(SCons.Warnings.CorruptSConsignWarning,
"Ignoring corrupt sconsign entry : %s"%self.dir.path)
@@ -213,7 +211,11 @@ class SConsignDB(_SConsign):
if self.dirty:
global SConsign_db
SConsign_db[self.dir.path] = cPickle.dumps(self.entries, 1)
- SConsign_db.sync()
+ try:
+ SConsign_db.sync()
+ except AttributeError:
+ # Not all anydbm modules have sync() methods.
+ pass
class SConsignDir(_SConsign):
def __init__(self, fp=None, module=None):
@@ -244,11 +246,13 @@ class SConsignDirFile(SConsignDir):
try:
fp = open(self.sconsign, 'rb')
- except:
+ except IOError:
fp = None
try:
SConsignDir.__init__(self, fp, module)
+ except KeyboardInterrupt:
+ raise
except:
SCons.Warnings.warn(SCons.Warnings.CorruptSConsignWarning,
"Ignoring corrupt .sconsign file: %s"%self.sconsign)
@@ -274,11 +278,11 @@ class SConsignDirFile(SConsignDir):
try:
file = open(temp, 'wb')
fname = temp
- except:
+ except IOError:
try:
file = open(self.sconsign, 'wb')
fname = self.sconsign
- except:
+ except IOError:
return
cPickle.dump(self.entries, file, 1)
file.close()
@@ -287,29 +291,31 @@ class SConsignDirFile(SConsignDir):
mode = os.stat(self.sconsign)[0]
os.chmod(self.sconsign, 0666)
os.unlink(self.sconsign)
- except:
+ except OSError:
pass
try:
os.rename(fname, self.sconsign)
- except:
+ except OSError:
open(self.sconsign, 'wb').write(open(fname, 'rb').read())
os.chmod(self.sconsign, mode)
try:
os.unlink(temp)
- except:
+ except OSError:
pass
SConsignForDirectory = SConsignDirFile
-def SConsignFile(name):
+def SConsignFile(name, dbm_module=None):
"""
Arrange for all signatures to be stored in a global .sconsign.dbm
file.
"""
global SConsign_db
if SConsign_db is None:
- import anydbm
- SConsign_db = anydbm.open(name, "c")
+ if dbm_module is None:
+ import anydbm
+ dbm_module = anydbm
+ SConsign_db = dbm_module.open(name, "c")
global SConsignForDirectory
SConsignForDirectory = SConsignDB