Makefile: Add CPP code coverage
This commit is contained in:
parent
1f2ad36bad
commit
006f9e0760
15
Makefile
15
Makefile
@ -48,11 +48,17 @@ export CXX = $(if $(shell which g++-6),g++-6,$(if $(shell which g++-mp-6),g++-mp
|
||||
endif
|
||||
|
||||
export LDFLAGS= -pthread -lm $(ADD_LDFLAGS) $(DMLC_LDFLAGS) $(PLUGIN_LDFLAGS)
|
||||
export CFLAGS= -std=c++0x -Wall -O3 -msse2 -Wno-unknown-pragmas -funroll-loops -Iinclude $(ADD_CFLAGS) $(PLUGIN_CFLAGS)
|
||||
export CFLAGS= -std=c++0x -Wall -Wno-unknown-pragmas -Iinclude $(ADD_CFLAGS) $(PLUGIN_CFLAGS)
|
||||
CFLAGS += -I$(DMLC_CORE)/include -I$(RABIT)/include
|
||||
#java include path
|
||||
export JAVAINCFLAGS = -I${JAVA_HOME}/include -I./java
|
||||
|
||||
ifeq ($(TEST_COVER), 1)
|
||||
CFLAGS += -g -O0 -fprofile-arcs -ftest-coverage
|
||||
else
|
||||
CFLAGS += -O3 -funroll-loops -msse2
|
||||
endif
|
||||
|
||||
ifndef LINT_LANG
|
||||
LINT_LANG= "all"
|
||||
endif
|
||||
@ -152,9 +158,14 @@ test: $(ALL_TEST)
|
||||
check: test
|
||||
./tests/cpp/xgboost_test
|
||||
|
||||
ifeq ($(TEST_COVER), 1)
|
||||
cover: check
|
||||
gcov -pbcu $(COVER_OBJ)
|
||||
endif
|
||||
|
||||
clean:
|
||||
$(RM) -rf build build_plugin lib bin *~ */*~ */*/*~ */*/*/*~ */*.o */*/*.o */*/*/*.o xgboost
|
||||
$(RM) -rf build_tests tests/cpp/xgboost_test
|
||||
$(RM) -rf build_tests *.gcov tests/cpp/xgboost_test
|
||||
|
||||
clean_all: clean
|
||||
cd $(DMLC_CORE); $(MAKE) clean; cd $(ROOTDIR)
|
||||
|
||||
@ -47,6 +47,11 @@ LIB_RABIT = librabit.a
|
||||
# path to libjvm.so
|
||||
LIBJVM=$(JAVA_HOME)/jre/lib/amd64/server
|
||||
|
||||
# whether to test with coverage measurement or not. (only used for `make cover`)
|
||||
# measured with gcov and html report generated with lcov if it is installed.
|
||||
# this disables optimization to ensure coverage information is correct
|
||||
TEST_COVER = 1
|
||||
|
||||
# path to gtest library (only used when $BUILD_TEST=1)
|
||||
# there should be an include path in $GTEST_PATH/include and library in $GTEST_PATH/lib
|
||||
GTEST_PATH =
|
||||
|
||||
@ -11,6 +11,8 @@ UNITTEST_CFLAGS=$(CFLAGS)
|
||||
UNITTEST_LDFLAGS=$(LDFLAGS) -L$(GTEST_LIB) -lgtest
|
||||
UNITTEST_DEPS=lib/libxgboost.a $(DMLC_CORE)/libdmlc.a $(RABIT)/lib/$(LIB_RABIT)
|
||||
|
||||
COVER_OBJ=$(patsubst %.o, %.gcda, $(ALL_OBJ)) $(patsubst %.o, %.gcda, $(UNITTEST_OBJ))
|
||||
|
||||
$(UTEST_OBJ_ROOT)/%.o: $(UTEST_ROOT)/%.cc
|
||||
@mkdir -p $(@D)
|
||||
$(CXX) $(UNITTEST_CFLAGS) -I$(GTEST_INC) -o $@ -c $<
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user