[Scons-users] Let directory depend on file? (auto generated sources)

Stijn De Ruyck Stijn.DeRuyck at onsemi.com
Wed Nov 26 12:11:58 EST 2014


Hi Dirk,

Well, I kind of suspected using Dir('autogen') as target was a bit of wishful thinking :) but SCons has amazed me so far, so I didn't hurt to try :p
I had to leave the office afterwards and won't be back until next week, but I sure would like to come up with a solution by the time I get back...

The problem with what you're suggesting is that I don't really know what files installModel.sh (which calls another binary) will generate in the autogen directory. I know now, but that can change depending on what's declared in mst.odl in the future, and we'd like to keep this automated...

What I could do is have autogen deleted by scons before every build step (someway somehow?), that would trigger it's recreation like you said and make sure builds are started from the most recent set of autogen files, but that's too rough and would run installModel.sh everytime, even when it's not needed.

That's also what we do with Make right now; a brute-force approach: on make, if mst.odl has changed, call make clean, run installModel, then rebuild the entire thing (and provide all the autogen targets manually in the makefile).
We were hoping to do this nicer/faster with SCons...

Best regards,

Stijn

________________________________
Van: Scons-users [scons-users-bounces at scons.org] namens Dirk Bächle [tshortik at gmx.de]
Verzonden: woensdag 26 november 2014 17:46
Aan: scons-users at scons.org
Onderwerp: Re: [Scons-users] Let directory depend on file? (auto generated sources)

Hi Stijn,

On 26.11.2014 12:25, Stijn De Ruyck wrote:
Hi,

Consider following situation:
- directory "autogen" containing .cc files generated by installModel.sh script.
- file "mst.odl" is used by installModel.sh to generate the autogen files.
- contents of autogen can vary depending on mst.odl (in other words, resulting sources in autogen are not known in advance)
- if scons sees a change in mst.odl, it must first call installModel.sh to repopulate the autogen directory, then continue with figuring out dependencies and building what's needed. (Other sources depend largely on the autogen files. So if autogen is modified, scons should automatically trigger a (near) complete rebuild anyway.)

In other words, the autogen directory depends on mst.odl.

this statement is not quite correct. The "contents" of the autogen directory (created .cc files) depend on "etc/mst.odl".

How do I configure this?

What I had was this (not at the office right now, so code not 100% accurate):

SConstruct file:
(...)
autogen = env.Command(Dir('autogen'), 'etc/mst.odl', 'tools/build/installModel.sh with some args')

Using a directory as target will not give you what you're actually trying to achieve. Like every other build system, SCons regards a directory to be up-to-date if it exists. So, after the first invocation your target "autogen" is always up-to-date and your shell script never gets called, until you remove the folder.

You have to specify one of the resulting files "autogen/x.cc" as target instead, even better: specify all the created files as targets by writing a Builder+Emitter for your build step.

Best regards,

Dirk

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://pairlist4.pair.net/pipermail/scons-users/attachments/20141126/7bff25c8/attachment-0001.html>


More information about the Scons-users mailing list