From ea09a53adc61cf282c6dfa65663db4a63842f511 Mon Sep 17 00:00:00 2001 From: Stacey Sheldon Date: Wed, 9 Jan 2013 01:09:55 -0500 Subject: [PATCH] unittest: build gtest-all and gtest_main directly Conflicts: make/unittest.mk --- Makefile | 8 +++++++- make/unittest.mk | 31 ++++++++++++++++++------------- 2 files changed, 25 insertions(+), 14 deletions(-) diff --git a/Makefile b/Makefile index 94b9d84e0..5f960cadc 100644 --- a/Makefile +++ b/Makefile @@ -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))) diff --git a/make/unittest.mk b/make/unittest.mk index 9654af174..c932d9132 100644 --- a/make/unittest.mk +++ b/make/unittest.mk @@ -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) $<