summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteven Knight <knight@baldmt.com>2004-10-23 13:20:11 (GMT)
committerSteven Knight <knight@baldmt.com>2004-10-23 13:20:11 (GMT)
commit01018a94b70c997110057fe752d7135489a28f39 (patch)
tree8ec36b957e6f5f83e70c358d8751800a90dec2bc
parent3a9ac1951af770bda262a192a76fa427e291678a (diff)
downloadSCons-01018a94b70c997110057fe752d7135489a28f39.zip
SCons-01018a94b70c997110057fe752d7135489a28f39.tar.gz
SCons-01018a94b70c997110057fe752d7135489a28f39.tar.bz2
Smarter sync'ing of the .sconsign file when it's written out at the end. (Stephen Kennedy)
-rw-r--r--src/CHANGES.txt5
-rw-r--r--src/engine/SCons/SConsign.py26
-rw-r--r--src/engine/SCons/SConsignTests.py55
3 files changed, 64 insertions, 22 deletions
diff --git a/src/CHANGES.txt b/src/CHANGES.txt
index 4cfc71c..69519f1 100644
--- a/src/CHANGES.txt
+++ b/src/CHANGES.txt
@@ -41,6 +41,11 @@ RELEASE 0.97 - XXX
check for the build engine in the parent directory of the Python
library directory (/usr/lib64 instead of /usr/lib).
+ From Stephen Kennedy:
+
+ - Speed up writing the .sconsign file at the end of a run by only
+ calling sync() once at the end, not after every entry.
+
From Steven Knight:
- When compiling with Microsoft Visual Studio, don't include the ATL and
diff --git a/src/engine/SCons/SConsign.py b/src/engine/SCons/SConsign.py
index b7b06fe..6610eaf 100644
--- a/src/engine/SCons/SConsign.py
+++ b/src/engine/SCons/SConsign.py
@@ -46,7 +46,14 @@ database = None
def write():
global sig_files
for sig_file in sig_files:
- sig_file.write()
+ sig_file.write(sync=0)
+ if database:
+ try:
+ syncmethod = database.sync
+ except AttributeError:
+ pass # Not all anydbm modules have sync() methods.
+ else:
+ syncmethod()
class Base:
"""
@@ -109,15 +116,18 @@ class DB(Base):
global sig_files
sig_files.append(self)
- def write(self):
+ def write(self, sync=1):
if self.dirty:
global database
database[self.dir.path] = cPickle.dumps(self.entries, 1)
- try:
- database.sync()
- except AttributeError:
- # Not all anydbm modules have sync() methods.
- pass
+ if sync:
+ try:
+ syncmethod = database.sync
+ except AttributeError:
+ # Not all anydbm modules have sync() methods.
+ pass
+ else:
+ syncmethod()
class Dir(Base):
def __init__(self, fp=None, module=None):
@@ -162,7 +172,7 @@ class DirFile(Dir):
global sig_files
sig_files.append(self)
- def write(self):
+ def write(self, sync=1):
"""
Write the .sconsign file to disk.
diff --git a/src/engine/SCons/SConsignTests.py b/src/engine/SCons/SConsignTests.py
index 16ef816..c2c05ac 100644
--- a/src/engine/SCons/SConsignTests.py
+++ b/src/engine/SCons/SConsignTests.py
@@ -32,16 +32,16 @@ class BuildInfo:
def __init__(self, name):
self.name = name
+class DummyModule:
+ def to_string(self, sig):
+ return str(sig)
+
+ def from_string(self, sig):
+ return int(sig)
+
class BaseTestCase(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'
@@ -124,13 +124,6 @@ class SConsignDBTestCase(unittest.TestCase):
class SConsignDirFileTestCase(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'
@@ -193,6 +186,39 @@ class SConsignFileTestCase(unittest.TestCase):
assert fake_dbm.mode == "c", fake_dbm.mode
+class writeTestCase(unittest.TestCase):
+
+ def runTest(self):
+
+ class DummyNode:
+ path = 'not_a_valid_path'
+
+ test = TestCmd.TestCmd(workdir = '')
+ file = test.workpath('sconsign_file')
+
+ class Fake_DBM:
+ def __setitem__(self, key, value):
+ pass
+ def open(self, name, mode):
+ self.sync_count = 0
+ return self
+ def sync(self):
+ self.sync_count = self.sync_count + 1
+
+ fake_dbm = Fake_DBM()
+
+ SCons.SConsign.database = None
+ SCons.SConsign.File(file, fake_dbm)
+
+ f = SCons.SConsign.DirFile(DummyNode(), DummyModule())
+
+ f.set_entry('foo', BuildInfo('foo'))
+ f.set_entry('bar', BuildInfo('bar'))
+
+ SCons.SConsign.write()
+
+ assert fake_dbm.sync_count == 1, fake_dbm.sync_count
+
def suite():
suite = unittest.TestSuite()
@@ -200,6 +226,7 @@ def suite():
suite.addTest(SConsignDBTestCase())
suite.addTest(SConsignDirFileTestCase())
suite.addTest(SConsignFileTestCase())
+ suite.addTest(writeTestCase())
return suite
if __name__ == "__main__":