Define a list of source files (*. [Ch]) for complex builds using scons

Suppose you have a complex source tree for a C project, lots of directories with lots of files. The scons assembly supports several targets (i386, sparc, powerpc) and several options (debugging, release). At the root there are sconstruct (referring to various sconscripts ) that do everything correctly when called with arguments indicating the purpose and option, for example. scons target=i386 variant=release .

Is there an easy way to determine which source files (* .c and * .h) each of these collections will use (they are all slightly different)? My theory is that scons should still compute this file in order to know which files to compile and when to recompile. Can he provide this information?

What I do not want to do:

  • Perform a logical assembly and postprocess (perhaps it will not indicate * .h files anyway)
  • find . -name '*.[ch]' find . -name '*.[ch]' also prints unwanted files for unit testing and other creeps and is not targeted.

Ideally, I would like to make scons target=i386 variant=release printfileset and see the correct list of files *. [ch]. This list can then serve as input to additional source code file search tools such as doxygen.

+6
source share
1 answer

There are a few questions here:

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

When you put all this together, you will get something like:

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

Source: https://habr.com/ru/post/896490/


All Articles