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

Stijn De Ruyck Stijn.DeRuyck at onsemi.com
Thu Nov 27 06:04:32 EST 2014


Thanks Dirk. As it looks now, I probably won't get around to writing a custom Builder+Emitter. I'll give that a try.

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?

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.

(Sorry for all the emails. I'm just brainstorming, I'm ill at home right now, not much else I can do :))

________________________________
Van: Dirk Bächle [tshortik at gmx.de]
Verzonden: woensdag 26 november 2014 18:59
Aan: Stijn De Ruyck; SCons users mailing list
Onderwerp: Re: [Scons-users] Let directory depend on file? (auto generated sources)

On 26.11.2014 18:11, Stijn De Ruyck wrote:
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

If you have no idea, how is SCons supposed to know? ;)

At some point you have to feed information into the system, about how new files get generated from your ".odl" source. In SCons this is done via an Emitter that parses the source file and returns the list of files to expect. If you'd like to work this, I can help you with it...and it's not that difficult at all (check http://scons.org/wiki/ToolsForFools ).

Dirk

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


More information about the Scons-users mailing list