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

Stijn De Ruyck Stijn.DeRuyck at onsemi.com
Wed Dec 3 05:39:10 EST 2014


Got it, everything works as expected now!

This is what I have:

import os
import fnmatch
import glob

def autogen_emitter(target, source, env):
        #TODO: replace with egrep/awk on "namespace" in mst.odl and fetch stdout
        target = ['source1.c','source2.c'] #don't include the original dummy target
        return target, source

env = Environment()
env.CacheDir(".sconsCache")

sources = ['hello.c']

autogenBuilder = Builder(
        #TODO: replace with call to installModel.sh
        action = 'cp tmp.c.in source1.c; cp tmp2.c.in source2.c;',
        emitter = autogen_emitter
)
env.Append(BUILDERS = {'Autogen' : autogenBuilder})

autogenTargets = env.Autogen('autogenDummyTarget', 'mst.odl')
sources.extend(autogenTargets)
prog = env.Program(sources)

Any remarks?
In any case, thanks a lot for your help.


From: Scons-users [mailto:scons-users-bounces at scons.org] On Behalf Of Dirk Bächle
Sent: Tuesday, December 02, 2014 6:21 PM
To: SCons users mailing list
Subject: Re: [Scons-users] Let directory depend on file? (auto generated sources)

On 02.12.2014 17:01, Stijn De Ruyck wrote:
Sorry, I can't get this to work.

That's not suprising, since you're using the wrong approach. ;)


I have a dumbed down example below:

[...]


Problem is of course that after a clean, source1.c and source2.c are not discovered during the modify_targets emitter and not compiled... Only on the second scons invocation they are seen and added to the sources and built.
Also, modifying mst.odl triggers the builder and recreates all files, but the source1.c/2.c files aren't recompiled...
You can't rely on a standard glob() in your Emitter, because the files that you're trying to return (generated C files) may not exist yet.



So I don't know where to go from here...

You have to parse "msl.odt" ($SOURCE) in your Emitter, and return the names of files that it *will* create, once the build action is run. That's the key...to all your current problems.

Best regards,

Dirk
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://pairlist4.pair.net/pipermail/scons-users/attachments/20141203/f7fde03c/attachment.html>


More information about the Scons-users mailing list