Skip to content
Advertisement

When is scons “Depends” useful when compiling c/cpp files?

Any c/cpp files can call functions defined in other module, only linking phase resolve them. These c/cpp files don’t depend on each other for compiling sequence.

So my question is, is there any case that one c/cpp file should depend on another one, so that we need to specify in SConstruct like:

hello=Program("hello.c")
Depends(hello,'other_file')

Thanks!

Advertisement

Answer

It can be useful to force dependencies which SCons may not be aware of. For example you may use

env.Command('a.xyz','b.abc','do_stuff.sh $SOURCES -o $TARGET')

It may be a simple command but you know it depends on a file “templatefile.wxy”.

You can either write a full builder with Scanner (which would probably be overkill in this case). Or use Command + Depends.

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement