1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2024-11-29 07:24:13 +01:00

unittest: build gtest-all and gtest_main directly

Conflicts:
	make/unittest.mk
This commit is contained in:
Stacey Sheldon 2013-01-09 01:09:55 -05:00 committed by Alessio Morale
parent 9b94eeb745
commit ea09a53adc
2 changed files with 25 additions and 14 deletions

View File

@ -751,8 +751,14 @@ $(UT_OUT_DIR):
.PHONY: all_ut
all_ut: $(addsuffix _elf, $(addprefix ut_, $(ALL_UNITTESTS)))
# The all_ut_tap goal is a legacy alias for the all_ut_xml target so that Jenkins
# can still build old branches. This can be deleted in a few months when all
# branches are using the newer targets.
.PHONY: all_ut_tap
all_ut_tap: $(addsuffix _tap, $(addprefix ut_, $(ALL_UNITTESTS)))
all_ut_tap: all_ut_xml
.PHONY: all_ut_xml
all_ut_xml: $(addsuffix _xml, $(addprefix ut_, $(ALL_UNITTESTS)))
.PHONY: all_ut_run
all_ut_run: $(addsuffix _run, $(addprefix ut_, $(ALL_UNITTESTS)))

View File

@ -29,13 +29,6 @@ CPPFLAGS += -I$(GTEST_DIR)/include
# Flags passed to the C++ compiler.
CXXFLAGS += -g -Wall -Wextra -std=gnu++0x
# All Google Test headers.
GTEST_HEADERS = $(GTEST_DIR)/include/gtest/*.h \
$(GTEST_DIR)/include/gtest/internal/*.h
# Google Test libraries
GTEST_LIBS = $(GTEST_DIR)/lib/.libs/libgtest_main.a $(GTEST_DIR)/lib/.libs/libgtest.a
# Google Test needs the pthread library
LDFLAGS += -lpthread
@ -50,19 +43,31 @@ override THUMB :=
EXTRAINCDIRS += .
ALLSRC := $(SRC) $(wildcard ./*.c)
ALLCPPSRC := $(wildcard ./*.cpp)
ALLCPPSRC := $(wildcard ./*.cpp) $(GTEST_DIR)/src/gtest_main.cc
ALLSRCBASE := $(notdir $(basename $(ALLSRC) $(ALLCPPSRC)))
ALLOBJ := $(addprefix $(OUTDIR)/, $(addsuffix .o, $(ALLSRCBASE)))
.PHONY: elf
elf: $(OUTDIR)/$(TARGET).elf
$(foreach src,$(ALLSRC),$(eval $(call COMPILE_C_TEMPLATE,$(src))))
$(foreach src,$(ALLCPPSRC),$(eval $(call COMPILE_CXX_TEMPLATE,$(src))))
$(eval $(call LINK_CXX_TEMPLATE,$(OUTDIR)/$(TARGET).elf,$(ALLOBJ) $(GTEST_LIBS)))
# Specific extensions to CPPFLAGS only for the google test library
$(OUTDIR)/gtest-all.o : CPPFLAGS += -I$(GTEST_DIR)
$(eval $(call COMPILE_CXX_TEMPLATE, $(GTEST_DIR)/src/gtest-all.cc))
$(eval $(call LINK_CXX_TEMPLATE,$(OUTDIR)/$(TARGET).elf,$(ALLOBJ) $(OUTDIR)/gtest-all.o))
.PHONY: elf
elf: $(OUTDIR)/$(TARGET).elf
.PHONY: xml
xml: $(OUTDIR)/$(TARGET).xml
$(OUTDIR)/$(TARGET).xml: $(OUTDIR)/$(TARGET).elf
$(V0) @echo " TEST XML $(MSG_EXTRA) $(call toprel, $@)"
$(V1) $< --gtest_output=xml:$(OUTDIR)/$(TARGET).xml > /dev/null
.PHONY: run
run: $(OUTDIR)/$(TARGET).elf
$(V0) @echo " TAP RUN $(MSG_EXTRA) $(call toprel, $<)"
$(V0) @echo " TEST RUN $(MSG_EXTRA) $(call toprel, $<)"
$(V1) $<