CXXFLAGS=-g -O0 include ../common.mk ifeq ($(CXXTYPE),clang++) CXXFLAGS+=-fprofile-instr-generate -fcoverage-mapping LDFLAGS+=-fprofile-instr-generate -fcoverage-mapping else # GCC CXXFLAGS+=--coverage LDFLAGS+=--coverage endif UNITS=storage.cpp config.cpp file.cpp compiledsql.cpp qrcode.cpp whiteboard.cpp UNITTESTS=test-config.cpp \ test-storage.cpp CXXFLAGS+=\ -I/usr/src/googletest/googletest/include \ -I/usr/src/googletest/googlemock/include \ -I/usr/src/googletest/googletest \ -I/usr/src/googletest/googlemock \ -I.. test: unittests # https://clang.llvm.org/docs/SourceBasedCodeCoverage.html ifeq ($(CXXTYPE),clang++) LLVM_PROFILE_FILE="unittests.profraw" ./unittests $(LLVMPROFDATA) merge -sparse unittests.profraw -o unittests.profdata $(LLVMCOV) report --ignore-filename-regex='google' --ignore-filename-regex='test-' --show-region-summary=0 -instr-profile unittests.profdata unittests else ./unittests #gcov-12 storage.o gcovr -r .. endif coverage: $(LLVMCOV) show -instr-profile unittests.profdata $(UNITS:.cpp=.o) unittests: libgmock.a $(UNITTESTS:.cpp=.o) $(UNITS:.cpp=.o) $(CXX) $(LDFLAGS) $^ $(LDLIBS) $(LIBS) -o $@ %.o: %.cpp $(CXX) $(CXXFLAGS) -o $@ -c $< config.o: ../config.cpp $(CXX) $(CXXFLAGS) -o $@ -c $< file.o: ../file.cpp $(CXX) $(CXXFLAGS) -o $@ -c $< storage.o: ../storage.cpp $(CXX) $(CXXFLAGS) -o $@ -c $< compiledsql.o: ../compiledsql.cpp $(CXX) $(CXXFLAGS) -o $@ -c $< whiteboard.o: ../whiteboard.cpp $(CXX) $(CXXFLAGS) -o $@ -c $< qrcode.o: ../qrcode.cpp $(CXX) $(CXXFLAGS) -o $@ -c $< libgmock.a: $(CXX) $(CXXFLAGS) -c /usr/src/googletest/googletest/src/gtest-all.cc $(CXX) $(CXXFLAGS) -c /usr/src/googletest/googlemock/src/gmock-all.cc $(CXX) $(CXXFLAGS) -c /usr/src/googletest/googlemock/src/gmock_main.cc ar -rv libgmock.a gmock-all.o gtest-all.o gmock_main.o clean: -rm -f *.o *.a unittests *.gcda *.gcno *.profraw *.profdata *.gcov