Search code examples
scons

Directory target is always up to date


I'm trying to update the files in a directory with a command like:

env.Command(Dir("./targetdir/"),
            ["./targetdir/file0", "./targetdir/file1", ...],
            "./somescript.sh $TARGET")

Scons keeps telling me that ./targetdir/ is up to date, even though I've modified by hand ./targetdir/file0.

Isn't scons supposed to know that, since one source file has changed, the command should be run? Is there a particularity with the fact that the target is a directory?

I want to run the command ./somescript.sh ./targetdir/ whenever any of the file in ./targetdir/ changes. How can I do it?


Solution

  • The problem here is you have no target. Scons can't store information about dependency without having target and source. So, one of solution use explicit target.

    mycmd = Command('some_target', [], ['script.sh targetdir', Touch('$TARGET')])
    or 
    mycmd = Command('some_target', [], 'script.sh targetdir > $TARGET')
    Depends(mycmd, Glob('targetdir/*'))
    

    Now, scons have target named some_target and known that it depends from files in targetdir. IMHO, best way create special builder/wrapper for it and use variant dirs to store targets there.