[Scons-users] Creation of an archive of source files with Node.all_children()

Dirk Bächle tshortik at gmx.de
Fri Jan 16 12:31:00 EST 2015


Paul,

On 16.01.2015 10:03, Paul Grégoire wrote:
> Hi Dirk,
>
> Thank you for your answer, your solution works fine, and it works even
> if I remove the line "env.Append('CPPPATH=['.']).
> The result is : tar -c -f sub/all_sources.tar sub/SConscript
> sub/main.cpp sub/define.inc    => exactly what I expected.
>
> But, if I remove the generation of the file define.h from define.inc,
> and the subdirectory to simplified, the archive does not contain
> define.h anymore.

unfortunately the FindSourceFiles() method can't detect implicit dependencies to existing files, like the "define.h" in your case. 
The problem is that at the time of calling FindSourceFiles(), no scanning has been done yet (we're still in the parsing phase). So 
SCons simply doesn't know that the file node exists yet.
This is different from the former setup, where the 'define.h' got created from 'define.inc' via a Builder. In that case, the file 
nodes for the target and the source are already created in what I call the VFS (virtual file system, an internal data structure that 
keeps track of which files/dirs should/will exist), so the FindSourceFiles() can find them.

One workaround is to create a file node for the header file, before calling FindSourceFiles():

     env = Environment()

     env.Append(CPPPATH=['.'])
     env.File('define.h')
     foo = env.Program('foo', 'main.cpp')

     env.Tar('foo', FindSourceFiles())

An env.File(Glob('*.h')) should work fine in general...

Regards,

Dirk



More information about the Scons-users mailing list