make gcov does not work when I only have C source files

431 views
Skip to first unread message

lindelof

unread,
Nov 11, 2011, 2:45:37 PM11/11/11
to cpputest
I have a project with only C files in it. When I run

make gcov

This is what I get in gcov_output.txt:

File 'optimize.c'
No executable lines
optimize.c:creating 'optimize.c.gcov'

and so on for each source file.

Eventually I found out that it's due to the following line in
Makefileworker.mk:

gcov --object-directory $(CPPUTEST_OBJS_DIR)/$$d $$d/*.c $$d/*.cpp
>> $(GCOV_OUTPUT) 2>>$(GCOV_ERROR) ; \

This line is passed to the shell, and if there are no CPP files then
gcov is given the literal './*.cpp' as the last sourcefile. And that
prevents it from working properly.

My workaround is to split this line in two:

gcov --object-directory $(CPPUTEST_OBJS_DIR)/$$d $$d/*.c >> $
(GCOV_OUTPUT) 2>>$(GCOV_ERROR) ; \
gcov --object-directory $(CPPUTEST_OBJS_DIR)/$$d $$d/*.cpp >> $
(GCOV_OUTPUT) 2>>$(GCOV_ERROR) ; \

It still yields errors on the second line but at least the C files are
processed right. I cannot use constructs such as $$d/*.{c,cpp} because
that line is passed to the default shell, which is /bin/sh and which
does not recognize that kind of expansion. (It's a bash construct.)

Hope someone finds this useful,

David

Bas Vodde

unread,
Nov 13, 2011, 2:42:29 AM11/13/11
to cppu...@googlegroups.com

Thanks!

Let me look into this today..

Bas

Reply all
Reply to author
Forward
0 new messages