summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteven Knight <knight@baldmt.com>2005-07-04 23:51:28 (GMT)
committerSteven Knight <knight@baldmt.com>2005-07-04 23:51:28 (GMT)
commite0a7426d7aff19eb1b7af396086ccebb692a48d3 (patch)
treed121a6443f3a5bb998c67b507170cff8537ae015
parent01878e78547c411543d8afb3bd150d090f07447d (diff)
downloadSCons-e0a7426d7aff19eb1b7af396086ccebb692a48d3.zip
SCons-e0a7426d7aff19eb1b7af396086ccebb692a48d3.tar.gz
SCons-e0a7426d7aff19eb1b7af396086ccebb692a48d3.tar.bz2
Move max_drift from Sig/MD5.py to Node/FS.py.
-rw-r--r--src/engine/SCons/Node/FS.py16
-rw-r--r--src/engine/SCons/SConf.py4
-rw-r--r--src/engine/SCons/Script/Main.py5
-rw-r--r--src/engine/SCons/Sig/__init__.py10
-rw-r--r--test/sconsign/script.py12
5 files changed, 23 insertions, 24 deletions
diff --git a/src/engine/SCons/Node/FS.py b/src/engine/SCons/Node/FS.py
index f2eb1aa..ca7bd28 100644
--- a/src/engine/SCons/Node/FS.py
+++ b/src/engine/SCons/Node/FS.py
@@ -52,6 +52,10 @@ import SCons.Sig.MD5
import SCons.Util
import SCons.Warnings
+# The max_drift value: by default, use a cached signature value for
+# any file that's been untouched for more than two days.
+default_max_drift = 2*24*60*60
+
#
# We stringify these file system Nodes a lot. Turning a file system Node
# into a string is non-trivial, because the final string representation
@@ -827,6 +831,7 @@ class FS(LocalFS):
self.CachePath = None
self.cache_force = None
self.cache_show = None
+ self.max_drift = default_max_drift
if path is None:
self.pathTop = os.getcwd()
@@ -845,6 +850,12 @@ class FS(LocalFS):
def set_SConstruct_dir(self, dir):
self.SConstruct_dir = dir
+ def get_max_drift(self):
+ return self.max_drift
+
+ def set_max_drift(self, max_drift):
+ self.max_drift = max_drift
+
def getcwd(self):
return self._cwd
@@ -1866,10 +1877,9 @@ class File(Base):
if calc is None:
calc = self.calculator()
+ max_drift = self.fs.max_drift
mtime = self.get_timestamp()
-
- use_stored = calc.max_drift >= 0 and \
- (time.time() - mtime) > calc.max_drift
+ use_stored = max_drift >= 0 and (time.time() - mtime) > max_drift
csig = None
if use_stored:
diff --git a/src/engine/SCons/SConf.py b/src/engine/SCons/SConf.py
index 168add9..703619b 100644
--- a/src/engine/SCons/SConf.py
+++ b/src/engine/SCons/SConf.py
@@ -400,7 +400,8 @@ class SConf:
try:
# ToDo: use user options for calc
- self.calc = SCons.Sig.Calculator(max_drift=0)
+ save_max_drift = SConfFS.get_max_drift()
+ SConfFS.set_max_drift(0)
tm = SCons.Taskmaster.Taskmaster(nodes, SConfBuildTask)
# we don't want to build tests in parallel
jobs = SCons.Job.Jobs(1, tm )
@@ -412,6 +413,7 @@ class SConf:
# the node could not be built. we return 0 in this case
ret = 0
finally:
+ SConfFS.set_max_drift(save_max_drift)
os.chdir(old_os_dir)
SConfFS.chdir(old_fs_dir, change_os_dir=0)
if self.logstream != None:
diff --git a/src/engine/SCons/Script/Main.py b/src/engine/SCons/Script/Main.py
index a6b4f88..b53edb2 100644
--- a/src/engine/SCons/Script/Main.py
+++ b/src/engine/SCons/Script/Main.py
@@ -830,7 +830,7 @@ class SConscriptSettableOptions:
# settable options, as well as indicating which options
# are SConscript settable.
self.settable = {'num_jobs':1,
- 'max_drift':SCons.Sig.default_max_drift,
+ 'max_drift':SCons.Node.FS.default_max_drift,
'implicit_cache':0,
'clean':0,
'duplicate':'hard-soft-copy',
@@ -1074,6 +1074,7 @@ def _main(args, parser):
# that are SConscript settable:
SCons.Node.implicit_cache = ssoptions.get('implicit_cache')
SCons.Node.FS.set_duplicate(ssoptions.get('duplicate'))
+ fs.set_max_drift(ssoptions.get('max_drift'))
lookup_top = None
if targets:
@@ -1167,8 +1168,6 @@ def _main(args, parser):
except AttributeError:
pass
- SCons.Environment.CalculatorArgs['max_drift'] = ssoptions.get('max_drift')
-
if options.random:
def order(dependencies):
"""Randomize the dependencies."""
diff --git a/src/engine/SCons/Sig/__init__.py b/src/engine/SCons/Sig/__init__.py
index 00c2b83..cfad3e8 100644
--- a/src/engine/SCons/Sig/__init__.py
+++ b/src/engine/SCons/Sig/__init__.py
@@ -36,26 +36,18 @@ except ImportError:
import TimeStamp
default_module = TimeStamp
-# XXX We should move max_drift into Node/FS.py,
-# since it's really something about files.
-default_max_drift = 2*24*60*60
-
class Calculator:
"""
Encapsulates signature calculations and .sconsign file generating
for the build engine.
"""
- def __init__(self, module=default_module, max_drift=default_max_drift):
+ def __init__(self, module=default_module):
"""
Initialize the calculator.
module - the signature module to use for signature calculations
- max_drift - the maximum system clock drift used to determine when to
- cache content signatures. A negative value means to never cache
- content signatures. (defaults to 2 days)
"""
self.module = module
- self.max_drift = max_drift
default_calc = Calculator()
diff --git a/test/sconsign/script.py b/test/sconsign/script.py
index 24bcc70..8d2d6a6 100644
--- a/test/sconsign/script.py
+++ b/test/sconsign/script.py
@@ -519,40 +519,36 @@ hello.obj: \d+ None \d+ \d+
hello.c: \S+
""")
-test.run_sconsign(arguments = "-e hello.c -e hello.exe -e hello.obj -d sub1 -f dblite work2/my_sconsign",
+test.run_sconsign(arguments = "-e hello.exe -e hello.obj -d sub1 -f dblite work2/my_sconsign",
stdout = """\
=== sub1:
-hello.c: None \d+ \d+ \d+
hello.exe: \d+ None \d+ \d+
hello.obj: \d+
hello.obj: \d+ None \d+ \d+
hello.c: \d+
""")
-test.run_sconsign(arguments = "-e hello.c -e hello.exe -e hello.obj -d sub1 -f dblite work2/my_sconsign.dblite",
+test.run_sconsign(arguments = "-e hello.exe -e hello.obj -d sub1 -f dblite work2/my_sconsign.dblite",
stdout = """\
=== sub1:
-hello.c: None \d+ \d+ \d+
hello.exe: \S+ None \d+ \d+
hello.obj: \d+
hello.obj: \S+ None \d+ \d+
hello.c: \d+
""")
-test.run_sconsign(arguments = "-e hello.c -e hello.exe -e hello.obj -r -d sub1 -f dblite work2/my_sconsign",
+test.run_sconsign(arguments = "-e hello.exe -e hello.obj -r -d sub1 -f dblite work2/my_sconsign",
stdout = """\
=== sub1:
-hello.c: None \d+ '\S+ \S+ [ \d]\d \d\d:\d\d:\d\d \d\d\d\d' \d+
hello.exe: \d+ None '\S+ \S+ [ \d]\d \d\d:\d\d:\d\d \d\d\d\d' \d+
hello.obj: \d+
hello.obj: \d+ None '\S+ \S+ [ \d]\d \d\d:\d\d:\d\d \d\d\d\d' \d+
hello.c: \d+
""")
-test.run_sconsign(arguments = "-e hello.c -e hello.exe -e hello.obj -r -d sub1 -f dblite work2/my_sconsign.dblite",
+test.run_sconsign(arguments = "-e hello.exe -e hello.obj -r -d sub1 -f dblite work2/my_sconsign.dblite",
stdout = """\
=== sub1:
-hello.c: None \d+ '\S+ \S+ [ \d]\d \d\d:\d\d:\d\d \d\d\d\d' \d+
hello.exe: \d+ None '\S+ \S+ [ \d]\d \d\d:\d\d:\d\d \d\d\d\d' \d+
hello.obj: \d+
hello.obj: \d+ None '\S+ \S+ [ \d]\d \d\d:\d\d:\d\d \d\d\d\d' \d+