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
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()
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
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:
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 )
# 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:
# 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',
# 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:
except AttributeError:
pass
- SCons.Environment.CalculatorArgs['max_drift'] = ssoptions.get('max_drift')
-
if options.random:
def order(dependencies):
"""Randomize the dependencies."""
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()
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+