mk: add 'COVERAGE' option
'COVERAGE=yes' in 'target.mk' adds gcov-specific compiler flags and links the program with libgcov. Issue #3048
This commit is contained in:
parent
e74771e047
commit
1f985dec38
|
@ -16,6 +16,13 @@ include $(BASE_DIR)/mk/util.inc
|
||||||
PRG_DIR := $(dir $(TARGET_MK))
|
PRG_DIR := $(dir $(TARGET_MK))
|
||||||
include $(TARGET_MK)
|
include $(TARGET_MK)
|
||||||
|
|
||||||
|
#
|
||||||
|
# Add libgcov if coverage is requested
|
||||||
|
#
|
||||||
|
ifeq ($(COVERAGE),yes)
|
||||||
|
LIBS += libgcov
|
||||||
|
endif
|
||||||
|
|
||||||
#
|
#
|
||||||
# Include lib-import description files
|
# Include lib-import description files
|
||||||
#
|
#
|
||||||
|
|
|
@ -55,6 +55,10 @@ endif
|
||||||
%.o: %.cc
|
%.o: %.cc
|
||||||
$(MSG_COMP)$@
|
$(MSG_COMP)$@
|
||||||
$(VERBOSE)$(CXX) $(CXX_DEF) $(CC_CXX_OPT) $(INCLUDES) -c $< -o $@
|
$(VERBOSE)$(CXX) $(CXX_DEF) $(CC_CXX_OPT) $(INCLUDES) -c $< -o $@
|
||||||
|
ifeq ($(COVERAGE),yes)
|
||||||
|
$(VERBOSE)mkdir -p $(INSTALL_DIR)/gcov_data/$(TARGET)/$(dir $@)
|
||||||
|
$(VERBOSE)ln -sf $(CURDIR)/$(@:.o=.gcno) $(INSTALL_DIR)/gcov_data/$(TARGET)/$(@:.o=.gcno)
|
||||||
|
endif
|
||||||
|
|
||||||
%.o: %.cpp
|
%.o: %.cpp
|
||||||
$(MSG_COMP)$@
|
$(MSG_COMP)$@
|
||||||
|
|
|
@ -103,6 +103,32 @@ ifneq ($(STDLIB),yes)
|
||||||
LD_OPT_NOSTDLIB := -nostdlib -Wl,-nostdlib
|
LD_OPT_NOSTDLIB := -nostdlib -Wl,-nostdlib
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
#
|
||||||
|
# Add coverage options
|
||||||
|
#
|
||||||
|
# The directory for the coverage data (generated at runtime) is derived from
|
||||||
|
# the current build directory and is going to look like
|
||||||
|
#
|
||||||
|
# '/genodelabs/bin/test-log_gcov/2018-11-13/gcov_data/test-log_gcov'
|
||||||
|
#
|
||||||
|
# to match the path where the gcov note files (generated at build time) are
|
||||||
|
# stored in the depot package of the test program.
|
||||||
|
#
|
||||||
|
# If depot packages are not used, the path is going to look like
|
||||||
|
#
|
||||||
|
# '/gcov_data/test-log_gcov'
|
||||||
|
#
|
||||||
|
ifeq ($(COVERAGE),yes)
|
||||||
|
ifneq ($(findstring /depot/,$(CURDIR)),)
|
||||||
|
PROFILE_DIR = $(shell echo $(CURDIR) | \
|
||||||
|
sed -e 's/^.*\/depot\//\//' \
|
||||||
|
-e 's/\.build\/.*//')/gcov_data/$(TARGET)
|
||||||
|
else
|
||||||
|
PROFILE_DIR = /gcov_data/$(TARGET)
|
||||||
|
endif
|
||||||
|
CC_OPT += -fprofile-arcs -ftest-coverage -fprofile-dir=$(PROFILE_DIR)
|
||||||
|
endif
|
||||||
|
|
||||||
#
|
#
|
||||||
# Default optimization and warning levels
|
# Default optimization and warning levels
|
||||||
#
|
#
|
||||||
|
|
Loading…
Reference in New Issue
Block a user