[Scons-users] Let directory depend on file? (auto generated sources)
Dirk Bächle
tshortik at gmx.de
Thu Nov 27 10:16:50 EST 2014
On 27.11.2014 12:04, Stijn De Ruyck wrote:
> Thanks Dirk. As it looks now, I probably won't get around to writing a
> custom Builder+Emitter. I'll give that a try.
>
You may want to have a look at
http://scons.org/wiki/CorbaTaoBuilder
as a starting point...
> By the way, I just realized, would my original test ever have worked?
> (even if you ignore the Dir target)
>
> autogen = env.Command(Dir('autogen'), 'etc/mst.odl',
> 'tools/build/installModel.sh with some args')
> sources.extend(Glob('autogen/*', strings=True))
> env.Program(some-exe, sources)
>
> If SCons first parses the SConstruct file, it will be filling up the
> sources list with the Glob results, while the Command builder is only
> executed AFTER the parsing phase, correct?
> So the Command, triggering installModel, may generate more or less
> sources, or with different names, than the "old" batch that was still
> in autogen/. So SCons would be using an outdated sources list anyway,
> correct?
>
Yes, you'd always be one step behind...and have to invoke SCons a second
time, just to be sure that all dependencies got updated.
> If I'm wrong, then maybe your earlier suggestion "You have to specify
> one of the resulting files "autogen/x.cc" as target instead, " may
> also work after all, even if I use a dummy file:
>
> autogen = env.Command('autogen/dummy_file.txt', 'etc/mst.odl',
> 'tools/build/installModel.sh with some args')
> sources.extend(Glob('autogen/*', strings=True))
> env.Program(some-exe, sources)
>
> Scons will try to rebuild dummy_file.txt by running installModel only
> if mst.odl has changed and in the process, all the other autogen files
> get created and rebuilt as well.
>
SCons rebuilds "dummy_file.txt" whenever it's not up-to-date, this
includes the case where the output file doesn't exist. So your
installModel.sh would always get called.
Dirk
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://pairlist4.pair.net/pipermail/scons-users/attachments/20141127/b75d425e/attachment.html>
More information about the Scons-users
mailing list