~kiwec/ke

ee4e4e874e511d437ff0b45fc831fb5f272d656e — Wolf Clément 3 years ago 78c9c27
Add coverage target
3 files changed, 25 insertions(+), 11 deletions(-)

M .gitignore
M Makefile
M README.md
M .gitignore => .gitignore +2 -1
@@ 2,5 2,6 @@
build/
*.o
*.d
.ke.*
ke
tests
ke-tests

M Makefile => Makefile +19 -7
@@ 4,14 4,20 @@ DEP      = $(OBJ:.o=.d)
TESTS    = $(wildcard test/*.cpp)
TOBJ     = $(TESTS:.cpp=.o)
TDEP     = $(TOBJ:.o=.d)
CXX      = zapcc
CXX      = clang
CXXFLAGS = -std=c++1z
LDFLAGS  = -ltermbox -lstdc++ -lm
TARGET   = ke
TESTTGT  = ke-tests

$(TARGET): $(OBJ)
	$(CXX) $(CXXFLAGS) -o $@ $^ $(LDFLAGS)

$(TESTTGT): CXXFLAGS += -g
$(TESTTGT): LDFLAGS += -O0
$(TESTTGT): $(filter-out src/main.o, $(OBJ)) $(TOBJ)
	$(CXX) $(CXXFLAGS) -o $@ $^ $(LDFLAGS)

-include $(DEP)
-include $(TDEP)



@@ 20,18 26,24 @@ $(TARGET): $(OBJ)

.PHONY: clean
clean:
	rm -f $(OBJ) $(DEP) ke
	rm -f $(OBJ) $(DEP) $(TARGET) $(TESTTGT) ".ke.profdata" ".ke.profraw"

.PHONY: coverage
coverage: CXXFLAGS += -fprofile-instr-generate -fcoverage-mapping
coverage: LDFLAGS += -fprofile-instr-generate -fcoverage-mapping
coverage: clean $(TESTTGT)
	LLVM_PROFILE_FILE=".ke.profraw" ./$(TESTTGT)
	llvm-profdata merge -sparse ".ke.profraw" -o ".ke.profdata"
	llvm-cov show $(TESTTGT) -instr-profile=".ke.profdata"

.PHONY: debug
debug: CXXFLAGS += -Wall -Wextra -g
debug: LDFLAGS += -O0
debug: $(TARGET)

.PHONE: tests
tests: CXXFLAGS += -g
tests: LDFLAGS += -O0
tests: $(filter-out src/main.o, $(OBJ)) $(TOBJ)
	$(CXX) $(CXXFLAGS) -o $@ $^ $(LDFLAGS) && ./tests
.PHONY: tests
tests: $(TESTTGT)
	./$(TESTTGT)

.PHONY: install
install: $(TARGET)

M README.md => README.md +4 -3
@@ 22,10 22,11 @@ This is a work in progress. Use at your own risk.
- [termbox](https://github.com/nsf/termbox)
- libclang

For building/debugging :
Optional dependencies :

- tmux
- zapcc
- llvm (required by `make coverage`)
- tmux (required by `debug.sh`)
- zapcc (replace `CXX=clang` by `CXX=zapcc` in `Makefile`)

### TODO