开发者

Determine list of source files (*.[ch]) for a complex build with scons

Suppose you have a complex source tree for a C project, lots of directories with lots of files. The scons build supports multiple targets (i386, sparc, powerpc) and multiple variants (debug, release). There's an sconstruct at the root (referencing various sconscripts) that does the right thing for all of these, when called with arguments specifying target and variant, e.g. scons target=i386 variant=release.

Is there an easy way to determine which source files (*.c and *.h) each of these builds will use (they are all slightly different)? My theory is that scons needs to compute this file set anyway to know which files to compile and when to recompile. Can it provide this information?

What I do not want to do:

  • Log a verbose build and postprocess it (probably wouldn't tell *.h files anyway)
  • find . 开发者_JAVA技巧-name '*.[ch]' also prints unwanted files for unit testing and other cruft and is not target specific

Ideally I would like to do scons target=i386 variant=release printfileset and see the proper list of *.[ch] files. This list could then serve as input for further source file munging tools like doxygen.


There are a few questions all squashed together here:

  • You can prevent SCons from running the compiler using the --dry-run flag
  • You can get a dependency tree from SCons by using --debug=tree, or --tree=all flags, depending on which version you are running
  • Given a list of files, one per line, you can use grep to filter out only the things that are interesting for you.

When you put all of that together you end up with something like:

scons target=i386 variant=release printfileset -n --tree=all | egrep -i '^ .*\.(c|h|cpp|cxx|hpp|inl)$'
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜