[Scons-users] Decider which checks md5 checksums unexpectedly detecting changed/invalid ones

Tom Tanner (BLOOMBERG/ LONDON) ttanner2 at bloomberg.net
Fri Sep 20 05:34:52 EDT 2013


I have this as a decider, in order to pick up target files that have been changed in some way - something that is otherwise undetected by scons (e.g. truncating a binary or compiling it manually with different switches...).

def decider(dependency, target, prev_ni):
# If the timestamp is the same, assume the contents are the same.
# YMMV but someone would have to be working really hard to stuff this
# up.
if dependency.changed_timestamp_then_content(target, prev_ni):
return True

if GetOption('implicit_cache'):
return False

# Target doesn't exist - it will get rebuilt!
if not target.exists():
return False

# Check if the target file is dirty. If it is, we need to rebuild it.
# Sadly this check is *slow* so we ignore it with implicit_cache
t = str(target)
if t in dirty:
res = dirty[t]
else:
res = False
try:
csig = target.get_stored_info().ninfo.csig
contents = target.get_contents()
newsig = SCons.Util.MD5signature(contents)
if csig != newsig:
print 'Warning: target', t, 'is dirty'
res = True
except AttributeError:
# This may be a file node which doesn't have a sig yet, in
# which case it will get rebuilt for other reasons (like it
# doesn't exist).
pass
dirty[t] = res
return res

It seems to work fine, but from time to time it decides for no obvious reason a target is dirty (and more often than not just copies it target from the build cache). This seems to be generally as the result of a build that has failed for some reason (interrupt or some other target failed to compile), but sometimes it just happens.

Firstly, I should ask if there's something terribly obviously wrong with the above code. It usually does what is wanted (i.e. if you edit or otherwise blat a target after a build, without changing anything else, it'll get rebuilt), but I'm just a bit worried why it keeps claiming targets are dirty.

Cheers

TT
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://four.pairlist.net/pipermail/scons-users/attachments/20130920/9f90f47d/attachment.html


More information about the Scons-users mailing list