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

Dirk Bächle tshortik at gmx.de
Wed Nov 26 11:46:15 EST 2014


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/ad0fdef3/attachment.html>


More information about the Scons-users mailing list