Move max_drift from Sig/MD5.py to Node/FS.py.
authorstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Mon, 4 Jul 2005 23:51:28 +0000 (23:51 +0000)
committerstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Mon, 4 Jul 2005 23:51:28 +0000 (23:51 +0000)
git-svn-id: http://scons.tigris.org/svn/scons/trunk@1314 fdb21ef1-2011-0410-befe-b5e4ea1792b1

src/engine/SCons/Node/FS.py
src/engine/SCons/SConf.py
src/engine/SCons/Script/Main.py
src/engine/SCons/Sig/__init__.py
test/sconsign/script.py

index f2eb1aa4ed0727837ace284f6d84b421cc9bd180..ca7bd28236895300be7c95e12e7465d0bc8eb14d 100644 (file)
@@ -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:
index 168add96c3cb5b1861864b205b6efc7c27e5f970..703619bdc251db636037183799464c7625e5f15e 100644 (file)
@@ -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:
index a6b4f88a3b8d04d67956db96c1fc518979341aa2..b53edb22b6a682ceb4486e3a97348301f6879de8 100644 (file)
@@ -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."""
index 00c2b83a1c6a1ae9a32e55d6cfc30af4ed4249b4..cfad3e8230101f2a813885ca9a16bbac224977b7 100644 (file)
@@ -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()
index 24bcc70c649bc97a889a67a0b53cb440cf5c28db..8d2d6a66574c302b14aad3726b79d13863afb594 100644 (file)
@@ -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+