tags:

views:

316

answers:

4

scons uses MD5 hashes rather than file mod times to determine if a dependency needs to be built.

I want this to be the default behavior. But is there any way to force it to assume a particular file is out of date (the equivalent of "touch"), besides editing the file to make it different?

edit: use case:

binary file F is used to create another file G using a tool X. For some reason file G has changed (it got corrupted, or I edited it) or tool X has changed, and I want to recreate file G and everything downstream of it.

edit: This is for occasional use only. I do not want this to happen always, only those few times when I ask for it. Also I may not know the particular file ahead of time. For this reason I do not want to modify the SConscript/SConstruct files to build a particular file. What I would like is to do this at a command prompt:

scons {something to specify file foobar.h}

and that would force scons to build all files depending on foobar.h, whereas just typing scons would do the regular build using MD5 hashes for dependency checking. I don't mind editing the SConscript/SConstruct files ahead of time to allow this (custom Decider, I guess), if there's a way to do so that doesn't significantly increase the build times.

A: 

I don't think there is a way to directly do that. If the source file in question has one obvious output, such as test.o created from test.c, then removing test.o would force a recompile of the source file.

If instead you want to touch test.h which is included from multiple different source files, you may be better off doing a clean of your whole project to ensure that everything gets rebuilt.

Having said that, you may want to read about the Decider() function which lets you choose how file dependencies will be treated. You can even choose a custom decider function for particular files in your project, so if you have some global header file that you'd like to be able to touch and rebuild, you can do that.

Update: To answer your latest question, simply delete the file G. Scons will recreate it from F by running X the next time you build.

Greg Hewgill
A: 

I create a dummy target file with a full date all the way to the hour minute and second. Then I have the other steps depend on this dummy target file. This will change the md5 value every time the build step recompiles and cause the subsequent steps to recompile. Alternatively you can remove the dummy target and that too will cascade a re-compile.

Personally, I find this very useful because I can't predict all the output from every single step in my EDA build flow. Nor do I want to try to predict all output of every build step because of the maintenance cost.

I'm sure the Decider() function, as Greg has mentioned, is more scons-like, but I personally like to have the timestamp files.

Ross Rogers
A: 

In your SConstruct file extract the Node that represents your file. After this you should be able to use the Node.always_build(true) to make sure that it is built, I think this will force its dependents to be rebuilt also.

daramarak
thanks, but I don't want to do this always (it's a rare but badly needed task), and I don't want to modify the SConstruct/SConscript files, I just want a way of doing a one-time rebuild to force a particular file or files and its dependents to be rebuilt.
Jason S
+2  A: 

Have you had a a look at the --interactive option of Scons, there you can clean and build specific targets.

man page describing this.

daramarak
huh, I never knew about --interactive, that's going to save me some time w/ repeated builds. Thanks! I think I can use it for what I wanted too.
Jason S