How to prevent Waf from renaming object files?

I use Waf to create a C project and gcov to have test code coverage. However, Waf calls gcc method that creates foo.c.1.o from the source file foo.c , which confuses gcov when looking for the generated files:

 $ gcov foo.c $ foo.gcno:cannot open graph file 

Fortunately, gcov has the -o option with which you can specify the appropriate object file. However, this is not convenient, and lcov is still not executing. So my questions are:

  • Why is Waf renaming object files?
  • How to disable this behavior or ...
  • How can I get around this gcov / lcov ?
+6
source share
2 answers

You can use gcovr instead of running gcov .

gcovr does not rely on file name magic, but parses gcov coverage files.
Then it calls gcov with the appropriate parameters.
This works great with renaming Waf object files.

You can run gcovr from the Waf build subdirectory:

 cd build gcovr --root=$(pwd) --keep lcov --capture --directory $(pwd) --base-directory $(pwd) --output-file coverage.info genhtml coverage.info --output-directory out 

The --root removes the current directory prefix
The --keep option stores temporary gcov files used by lcov / genhtml .

You can also use the gcovr --xml option to output Cobertura -compatible xml.
It can then be used by various formatter (I use it with Jenkins Cobertura Plugin )

+6
source

Have you tried modifying the Waf configuration with

 bld.program( obj_ext = '.o', source = 'test.c', target = 'test1') 
0
source

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


All Articles