aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Sulfrian <alexander@sulfrian.net>2010-03-24 07:46:35 +0100
committerAlexander Sulfrian <alexander@sulfrian.net>2013-01-05 17:17:47 +0100
commitce9477398666f1f5c2af5a93664339bc80f52346 (patch)
tree463b2e804b6f58343f359a29ccbc45d335966fd1
parent873a72da1d8d5595b1648ffba2c846023985397b (diff)
downloadusdx-ce9477398666f1f5c2af5a93664339bc80f52346.tar.gz
usdx-ce9477398666f1f5c2af5a93664339bc80f52346.tar.xz
usdx-ce9477398666f1f5c2af5a93664339bc80f52346.zip
Makefile rework
more custizable with variables target for test-with-coverage (build, run, generate html) tests object and coverage files in seperate dir
-rw-r--r--.gitignore3
-rw-r--r--test/.gitignore1
-rw-r--r--test/Makefile83
3 files changed, 66 insertions, 21 deletions
diff --git a/.gitignore b/.gitignore
index f71e7190..daa63a09 100644
--- a/.gitignore
+++ b/.gitignore
@@ -21,5 +21,4 @@ config.status
__history
aclocal.m4
autom4te.cache/
-*.gcno
-*.gcda
+coverage/
diff --git a/test/.gitignore b/test/.gitignore
index d5378e20..f23464ea 100644
--- a/test/.gitignore
+++ b/test/.gitignore
@@ -1,2 +1,3 @@
usdx-tests
+usdx-tests-coverage
test.xml
diff --git a/test/Makefile b/test/Makefile
index d1385732..f77fae8b 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -1,38 +1,83 @@
-CXXFLAGS:=-Wall -Werror -lcppunit -I../src -I../src/base -I../src/menu -I../src/media -I../src/screens -g -fprofile-arcs -ftest-coverage
-LDFLAGS:=-lsqlite3 -lSDL -llog4cxx -lboost_program_options-mt -lboost_filesystem-mt -lSDL_image -coverage
-
PROJECT:=usdx-tests
+TOP:=..
+
+headers:=$(wildcard *.hpp) $(wildcard */*.hpp) $(wildcard $(TOP)/src/*/*/*.hpp) \
+ $(wildcard $(TOP)/src/*/*.hpp) $(wildcard $(TOP)/src/*.hpp)
+
+sources:=$(wildcard *.cpp) $(wildcard */*.cpp) $(wildcard $(TOP)/src/*/*/*.cpp) \
+ $(wildcard $(TOP)/src/*/*.cpp) $(wildcard $(TOP)/src/*.cpp)
+
+deps:=$(sources:.cpp=.d)
+
+CXXFLAGS:=-Wall -Werror -I$(TOP)/src -I$(TOP)/src/base -I$(TOP)/src/menu -I$(TOP)/src/media -I$(TOP)/src/screens -g
+LDFLAGS:=-lsqlite3 -lSDL -llog4cxx -lboost_program_options-mt -lboost_filesystem-mt -lSDL_image -lcppunit
TARGET:=$(PROJECT)
-zip:=$(PROJECT).rar
-headers:=$(wildcard *.hpp) $(wildcard */*.hpp) $(wildcard ../src/*/*/*.hpp) $(wildcard ../src/*/*.hpp) $(wildcard ../src/*.hpp)
-sources:=$(wildcard *.cpp) $(wildcard */*.cpp) $(wildcard ../src/*/*/*.cpp) $(wildcard ../src/*/*.cpp) $(wildcard ../src/*.cpp)
objects:=$(sources:.cpp=.o)
-deps:=$(sources:.cpp=.d)
-all: $(deps) $(TARGET)
+CXXFLAGS-COVERAGE:=-fprofile-arcs -ftest-coverage
+LDFLAGS-COVERAGE:=-coverage
+TARGET-COVERAGE:=$(TARGET)-coverage
+COVERAGE-DIR:=$(TOP)/coverage
+
+objects-coverage:=$(patsubst %,$(COVERAGE-DIR)/obj/test/%,$(sources:.cpp=.o))
+coverage:=$(COVERAGE-DIR)/coverage.info.tmp $(COVERAGE-DIR)/coverage.info \
+ $(objects-coverage:.o=.gcda) $(objects-coverage:.o=.gcno) \
+ $(COVERAGE-DIR)/obj/
+
+##############################################################################
+
+.PHONY: all clean run
+
+all: $(TARGET)
+
+clean:
+ -$(RM) -r $(TARGET) $(TARGET-COVERAGE) $(objects) $(deps) $(coverage)
+
+run: $(TARGET)
+ ./$(TARGET)
ifneq ($(MAKECMDGOALS),clean)
-include $(deps)
endif
-.PHONY: all clean run zip
+##############################################################################
+# normal build
$(TARGET): $(objects) $(deps)
- $(CXX) $(CXXFLAGS) $(LDFLAGS) -o $(TARGET) $(objects)
+ $(CXX) $(LDFLAGS) -o $(TARGET) $(objects)
-%.o: %.cpp
+%.o: %.cpp
$(CXX) $(CXXFLAGS) -MMD -c $< -o $@
-%.d: %.cpp
+%.d: %.cpp
$(CXX) $(CXXFLAGS) -MM -c $< -MF $@
-clean:
- -$(RM) $(TARGET) $(objects) $(deps)
+##############################################################################
+# build and execute tests with code coverage and build nice html pages
-run: $(TARGET)
- ./$(TARGET)
+test-with-coverage: $(COVERAGE-DIR)/html/index.html
+
+$(COVERAGE-DIR)/html/index.html: $(COVERAGE-DIR)/coverage.info
+ genhtml $(COVERAGE-DIR)/coverage.info -o $(COVERAGE-DIR)/html/ -p \
+ "$(shell realpath $(shell pwd)/$(TOP)/src)"
+
+$(COVERAGE-DIR)/coverage.info: $(COVERAGE-DIR)/coverage.info.tmp
+ lcov --extract $(COVERAGE-DIR)/coverage.info.tmp \
+ "$(shell realpath $(shell pwd)/$(TOP))/src/*" \
+ -o $(COVERAGE-DIR)/coverage.info
+
+$(COVERAGE-DIR)/coverage.info.tmp: $(TARGET-COVERAGE)
+ lcov --directory $(TOP) --zerocounters
+ ./$(TARGET-COVERAGE) || true
+ lcov --directory $(TOP) --capture \
+ --output-file $(COVERAGE-DIR)/coverage.info.tmp -b .
+
+$(TARGET-COVERAGE): $(objects-coverage) $(deps)
+ $(CXX) $(LDFLAGS) $(LDFLAGS-COVERAGE) -o $(TARGET-COVERAGE) \
+ $(objects-coverage)
+
+$(COVERAGE-DIR)/obj/test/%.o: %.cpp
+ @[ -d $(dir $@) ] || mkdir -p $(dir $@)
+ $(CXX) $(CXXFLAGS) $(CXXFLAGS-COVERAGE) -MMD -c $< -o $@
-zip:
- -$(RM) $(zip)
- rar a -s -m5 -ap$(PROJECT) $(zip) $(headers) $(sources) Makefile