[Scons-users] Mark existing file as up-to-date

Pedro Inácio pedromiragaia at gmail.com
Thu May 8 17:32:57 EDT 2014


I am using SCons for data processing.
One of the perks is that, unlike traditional compilation projects, each
file in my project might have required several hours to compute.
Re-building existing files is, in general, not acceptable.

Therefore, the problem is simple to state.
While I develop the SCons script, files which have been previously
processed, for one reason or another are flagged by SCons as requiring
re-build.
I would like to tell SCons that the existing files are up-to-date and do
not require being rebuilt.
How can I do that?

This could be easily done with make simply issuing "make --touch", however
this is not straightforward with SCons.
I have tried to use the Touch factory of SCons to mark existing files as
up-to-date, but this does not work.

My approach is as follows.
I added a custom option '--set-uptodate' which call the Touch factory if
the file already exists:
(...)
if GetOption('set-uptodate') and path.isfile(str(OUT)):
# do not recompute the file it already exists
Command(OUT,[],Touch("$TARGET")
else:
# normal build command
Command(OUT,IN,"foo $SOURCE > $TARGET")
(...)

If some files are undesirably flagged as out-of-date, I can issue,

scons --set-uptodate (opts) ...

which works fine and builds everything without recomputing any existing
files.

However, the next time I run scons without this option,

scons --debug=explain

the same files will be flagged as out-of-date with the reason that,

scons: rebuilding OUT because build action changed:
old: Touch("$TARGET")
new: foo $SOURCE > $TARGET


Any ideas?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://four.pairlist.net/pipermail/scons-users/attachments/20140508/81e4d049/attachment.html


More information about the Scons-users mailing list