Fallback to timestamp signatures when MD5 is not available. (Anthony Roach)
authorstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Fri, 17 May 2002 14:29:50 +0000 (14:29 +0000)
committerstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Fri, 17 May 2002 14:29:50 +0000 (14:29 +0000)
git-svn-id: http://scons.tigris.org/svn/scons/trunk@376 fdb21ef1-2011-0410-befe-b5e4ea1792b1

src/CHANGES.txt
src/engine/SCons/Node/__init__.py
src/engine/SCons/Sig/__init__.py
test/timestamp-fallback.py [new file with mode: 0644]

index a5551aa256559724a65346cb9a603161d233b5d7..62749910d1a50a9bc113c57024eb9feb75cc282d 100644 (file)
@@ -43,6 +43,9 @@ RELEASE 0.08 -
   - Make the drive letters on Windows always be the same case, so that
     changes in the case of drive letters don't cause a rebuild.
 
+  - Fall back to importing the SCons.TimeStamp module if the SCons.MD5
+    module can't be imported.
+
   From Zed Shaw:
 
   - Add an Append() method to Environments, to append values to
index 8e3ba7eed0ff90174160156dec07c2714794f481..472ec074f82dfc63a593d58f4e26c910308fbc36 100644 (file)
@@ -172,6 +172,8 @@ class Node:
             def get_contents(self):
                 return apply(self.node.builder.get_contents, (),
                              self.node.generate_build_args())
+            def get_timestamp(self):
+                return None
         return Adapter(self)
 
     def get_implicit_deps(self, env, scanner, target):
index 40ee459dfea12017bab91625b1107b2c6fe0d35a..193a3264a66108f484b41e8aecb8216d429893bb 100644 (file)
@@ -244,8 +244,14 @@ class Calculator:
           content signatures. (defaults to 2 days)
         """
         if module is None:
-            import MD5
-            self.module = MD5
+            try:
+                import MD5
+                self.module = MD5
+            except ImportError:
+                # fallback on timestamp signatures if MD5 is not available
+                # XXX add a warning message here
+                import TimeStamp
+                self.module = TimeStamp
         else:
             self.module = module
         self.max_drift = max_drift
diff --git a/test/timestamp-fallback.py b/test/timestamp-fallback.py
new file mode 100644 (file)
index 0000000..bfa4600
--- /dev/null
@@ -0,0 +1,78 @@
+#!/usr/bin/env python
+#
+# Copyright (c) 2001, 2002 Steven Knight
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+
+import os.path
+import os
+import string
+import sys
+import TestSCons
+
+test = TestSCons.TestSCons()
+
+test.write('md5.py', r"""
+raise ImportError
+""")
+
+os.environ['PYTHONPATH'] = test.workpath('.')
+
+test.write('SConstruct', """
+def build(env, target, source):
+    open(str(target[0]), 'wt').write(open(str(source[0]), 'rt').read())
+B = Builder(name = 'B', action = build)
+env = Environment(BUILDERS = [B])
+env.B(target = 'f1.out', source = 'f1.in')
+env.B(target = 'f2.out', source = 'f2.in')
+env.B(target = 'f3.out', source = 'f3.in')
+env.B(target = 'f4.out', source = 'f4.in')
+""")
+
+test.write('f1.in', "f1.in\n")
+test.write('f2.in', "f2.in\n")
+test.write('f3.in', "f3.in\n")
+test.write('f4.in', "f4.in\n")
+
+test.run(arguments = 'f1.out f3.out')
+
+test.run(arguments = 'f1.out f2.out f3.out f4.out', stdout =
+"""scons: "f1.out" is up to date.
+scons: "f3.out" is up to date.
+""")
+
+os.utime(test.workpath('f1.in'), 
+         (os.path.getatime(test.workpath('f1.in')),
+          os.path.getmtime(test.workpath('f1.in'))+10))
+os.utime(test.workpath('f3.in'), 
+         (os.path.getatime(test.workpath('f3.in')),
+          os.path.getmtime(test.workpath('f3.in'))+10))
+
+test.run(arguments = 'f1.out f2.out f3.out f4.out', stdout =
+"""scons: "f2.out" is up to date.
+scons: "f4.out" is up to date.
+""")
+
+
+test.pass_test()
+