@@ -6,10 +6,12 @@ TEST_DIR=$(abspath ./test/src/)
66INSTALL_DIR =/usr/include/fpgen
77INCL_PATH =$(abspath ./inc)
88DOC_DIR =$(abspath ./docs/)
9+ HTMLDIR =$(abspath ./cov/)
10+ BROWSER =firefox
911
1012CC =g++
11- CXXARGS =-I$(abspath ./inc) -g -c -std=c++20 -MMD
12- LDARGS =
13+ CXXARGS =-I$(abspath ./inc) -g -c -std=c++20 -MMD -fprofile-arcs -ftest-coverage
14+ LDARGS =-fprofile-arcs -ftest-coverage
1315
1416all :
1517 @echo " Please choose a target:"
1820 @echo " -> make docs: generates the documentation using doxygen under $( DOC_DIR) "
1921 @echo " -> make test: builds and runs the tests in $( BUILD_DIR) and $( BIN_DIR) from $( TEST_DIR) "
2022 @echo " -> make clean: cleans up test builds and documentation (from $( BUILD_DIR) , $( BIN_DIR) , $( DOC_DIR) )"
23+ @echo " -> make coverage: builds and runs the tests, then generates a coverage report in $( HTMLDIR) and opens it in $( BROWSER) "
2124 @echo " "
2225 @echo " Some targets accept additional arguments in the form of KEY=VALUE pairs:"
23- @echo " -> CC (for test): sets the command for the C++ compiler (g++ by default)"
24- @echo " -> CXXARGS (for test): current arguments to the compiler - not recommended to change"
25- @echo " -> EXTRA_CXX (for test): additional compilation flags/arguments"
26- @echo " -> LDARGS (for test): current arguments to the linker - not recommended to change"
27- @echo " -> EXTRA_LD (for test): additional linker flags/arguments"
28- @echo " -> BUILD_DIR (for test): build directory"
29- @echo " -> BIN_DIR (for test): binary directory"
30- @echo " -> TEST_DIR (for test): test sources directory"
26+ @echo " -> CC (for test and coverage ): sets the command for the C++ compiler (g++ by default)"
27+ @echo " -> CXXARGS (for test and coverage ): current arguments to the compiler - not recommended to change"
28+ @echo " -> EXTRA_CXX (for test and coverage ): additional compilation flags/arguments"
29+ @echo " -> LDARGS (for test and coverage ): current arguments to the linker - not recommended to change"
30+ @echo " -> EXTRA_LD (for test and coverage ): additional linker flags/arguments"
31+ @echo " -> BUILD_DIR (for test and coverage ): build directory"
32+ @echo " -> BIN_DIR (for test and coverage ): binary directory"
33+ @echo " -> TEST_DIR (for test and coverage ): test sources directory"
3134 @echo " -> INSTALL_DIR (for install and uninstall): sets the installation directory"
32- @echo " -> INCL_PATH (for install, docs and test ): the path to the directory with the headers, if you run make from another directory"
35+ @echo " -> INCL_PATH (for install, docs, test and coverage ): the path to the directory with the headers, if you run make from another directory"
3336 @echo " -> DOC_DIR (for docs): the path to the build directory for the documentation"
37+ @echo " -> BROWSER (for coverage): the browser in which to open the coverage report"
38+ @echo " -> HTMLDIR (for coverage): the directory in which to generate the coverage report"
3439 @echo " Current/default arguments: "
3540 @echo " CC=$( CC) CXXARGS=$( CXXARGS) LDARGS=$( LDARGS) EXTRA_CXX=$( EXTRA_CXX) EXTRA_LD=$( EXTRA_LD) "
3641 @echo " BUILD_DIR=$( BUILD_DIR) BIN_DIR=$( BIN_DIR) TEST_DIR=$( TEST_DIR) INSTALL_DIR=$( INSTALL_DIR) INCL_PATH=$( INCL_PATH) DOC_DIR=$( DOC_DIR) "
42+ @echo " BROWSER=$( BROWSER) HTMLDIR=$( HTMLDIR) "
43+ @echo " "
3744
3845install :
3946 ([ ! -d $( INSTALL_DIR) ] && mkdir -p $( INSTALL_DIR) ) || true
@@ -53,4 +60,10 @@ clean:
5360 rm -rf $(DOC_DIR ) /*
5461 cd $(TEST_DIR ) /.. && make clean OBJD=" $( BUILD_DIR) " BIND=" $( BIN_DIR) " SRCD=" $( TEST_DIR) "
5562
56- .PHONY : install uninstall test clean docs
63+ coverage :
64+ make CC=" $( CC) " OBJD=" $( BUILD_DIR) " BIND=" $( BIN_DIR) " SRCD=" $( TEST_DIR) " CXXARGS=" $( CXXARGS) $( EXTRA_CXX) -I$( INCL_PATH) " LDARGS=" $( LDARGS) $( EXTRA_LD) " -C $(TEST_DIR ) /..
65+ lcov --directory " $( BUILD_DIR) " --output-file coverage.info -c --exclude ' *gmock' --exclude ' *gtest*' --exclude ' /usr/*'
66+ genhtml coverage.info --output-directory " $( HTMLDIR) "
67+ $(BROWSER ) $(HTMLDIR ) /index.html
68+
69+ .PHONY : install uninstall test clean docs coverage
0 commit comments