From 07f253a52bd76d55c41a36480eb38df44338afb3 Mon Sep 17 00:00:00 2001 From: Steven Knight Date: Fri, 17 May 2002 14:29:50 +0000 Subject: Fallback to timestamp signatures when MD5 is not available. (Anthony Roach) --- src/CHANGES.txt | 3 ++ src/engine/SCons/Node/__init__.py | 2 + src/engine/SCons/Sig/__init__.py | 10 ++++- test/timestamp-fallback.py | 78 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 91 insertions(+), 2 deletions(-) create mode 100644 test/timestamp-fallback.py diff --git a/src/CHANGES.txt b/src/CHANGES.txt index a5551aa..6274991 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -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 diff --git a/src/engine/SCons/Node/__init__.py b/src/engine/SCons/Node/__init__.py index 8e3ba7e..472ec07 100644 --- a/src/engine/SCons/Node/__init__.py +++ b/src/engine/SCons/Node/__init__.py @@ -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): diff --git a/src/engine/SCons/Sig/__init__.py b/src/engine/SCons/Sig/__init__.py index 40ee459..193a326 100644 --- a/src/engine/SCons/Sig/__init__.py +++ b/src/engine/SCons/Sig/__init__.py @@ -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 index 0000000..bfa4600 --- /dev/null +++ b/test/timestamp-fallback.py @@ -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() + -- cgit v0.12