diff --git a/.gitignore b/.gitignore index b664c409bf7..da8415ae292 100644 --- a/.gitignore +++ b/.gitignore @@ -27,6 +27,7 @@ *.o-* *.exe *.a +*.gch # /doc/ /doc/api diff --git a/make/tests b/make/tests index 1828daa5362..a324a1ba53c 100644 --- a/make/tests +++ b/make/tests @@ -9,20 +9,16 @@ GTEST_CXXFLAGS += -isystem $(GTEST)/include -isystem $(GTEST) -O$O ## # Build the google test library. ## -$(GTEST)/src/gtest-all.o: CXXFLAGS += $(GTEST_CXXFLAGS) - -test/%$(EXE) : CXXFLAGS += $(GTEST_CXXFLAGS) -test/%$(EXE) : test/%.o $(GTEST_MAIN) $(GTEST)/src/gtest-all.o - $(LINK.cpp) -o $@ $^ - - +$(GTEST)/src/gtest-all.o: $(GTEST)/src/gtest-all.cc + $(COMPILE.cpp) -o $@ $< +$(GTEST)/%.cc: ; ## # Rule for generating dependencies. ## -.PRECIOUS: test/%.d -test/%.d : test/%.cpp +.PRECIOUS: %.d +%.d : %.cpp @mkdir -p $(dir $@) @set -e; \ rm -f $@; \ @@ -30,6 +26,15 @@ test/%.d : test/%.cpp sed -e 's,\($(*F)\)\.o[ :]*,$(@D)/\1.o $@ : ,g' < $@.$$$$ > $@; \ rm -f $@.$$$$ +%.d : %.hpp + @mkdir -p $(dir $@) + @set -e; \ + rm -f $@; \ + $(COMPILE.cpp) -MM $< > $@.$$$$; \ + sed -e 's,\($(*F)\)\.o[ :]*,$(@D)/\1.hpp.gch $@ : ,g' < $@.$$$$ > $@; \ + rm -f $@.$$$$ + $(eval include $$@) + ## # Adding a test for multiple translation units. If this fails, # a new function is probably missing an inline @@ -43,6 +48,7 @@ test/unit/libmultiple.so : test/unit/multiple_translation_units1.o test/unit/mul test/unit/multiple_translation_units_test.cpp : test/unit/libmultiple.so + ############################################################ # # CVODES tests @@ -76,6 +82,89 @@ test/dummy.cpp: .PHONY: test-headers test-headers: $(HEADER_TESTS) +test/unit/math_include_test.o: test/unit/math_include_test.cpp + $(COMPILE.cpp) $< -o $@ + +############################################################ +# +# General make targets for tests +# (necessary now that implicit SUFFIX rules are actually turned off) +# + +test/%$(EXE) : CXXFLAGS += $(GTEST_CXXFLAGS) +test/%$(EXE) : test/%.o $(GTEST_MAIN) $(GTEST)/src/gtest-all.o + $(LINK.cpp) -o $@ $^ + +# We need these explicit targets here because we turned off suffixes. We can't +# make a more general pattern rule like test/%.o because we want to force make +# to generate the pre-compiled headers (below) when applicable. +test/unit/math_c11_test.o: test/unit/math_c11_test.cpp + $(COMPILE.cpp) $< -o $@ + +test/unit/math/memory/%.o: test/unit/math/memory/%.cpp + $(COMPILE.cpp) $< -o $@ + +############################################################ +# +# Targets to include proper pre-compiled header files (.hpp.gch) for unit tests +# and distribution tests +## + +.PRECIOUS: %.hpp.gch test/%.o + +%.hpp.gch: %.hpp %.d + $(COMPILE.cpp) -o $@ $(@:.gch=) + +test/prob/%.o : stan/math/mix/mat.hpp.gch test/prob/%.cpp + $(COMPILE.cpp) $(if $(filter $(CC_TYPE),clang++),-include-pch $<) -o $@ $(@:.o=.cpp) + +test/unit/math/prim/scal/%.o : stan/math/prim/scal.hpp.gch test/unit/math/prim/scal/%.cpp + $(COMPILE.cpp) $(if $(filter $(CC_TYPE),clang++),-include-pch $<) -o $@ $(@:.o=.cpp) + +test/unit/math/prim/arr/%.o : stan/math/prim/arr.hpp.gch test/unit/math/prim/arr/%.cpp + $(COMPILE.cpp) $(if $(filter $(CC_TYPE),clang++),-include-pch $<) -o $@ $(@:.o=.cpp) + +test/unit/math/prim/mat/%.o : stan/math/prim/mat.hpp.gch test/unit/math/prim/mat/%.cpp + $(COMPILE.cpp) $(if $(filter $(CC_TYPE),clang++),-include-pch $<) -o $@ $(@:.o=.cpp) + +test/unit/math/rev/core/%.o : stan/math/rev/core.hpp.gch test/unit/math/rev/core/%.cpp + $(COMPILE.cpp) $(if $(filter $(CC_TYPE),clang++),-include-pch $<) -o $@ $(@:.o=.cpp) + +test/unit/math/rev/scal/%.o : stan/math/rev/scal.hpp.gch test/unit/math/rev/scal/%.cpp + $(COMPILE.cpp) $(if $(filter $(CC_TYPE),clang++),-include-pch $<) -o $@ $(@:.o=.cpp) + +test/unit/math/rev/arr/%.o : stan/math/rev/arr.hpp.gch test/unit/math/rev/arr/%.cpp + $(COMPILE.cpp) $(if $(filter $(CC_TYPE),clang++),-include-pch $<) -o $@ $(@:.o=.cpp) + +test/unit/math/rev/mat/%.o : stan/math/rev/mat.hpp.gch test/unit/math/rev/mat/%.cpp + $(COMPILE.cpp) $(if $(filter $(CC_TYPE),clang++),-include-pch $<) -o $@ $(@:.o=.cpp) + +test/unit/math/fwd/core/%.o : stan/math/fwd/core.hpp.gch test/unit/math/fwd/core/%.cpp + $(COMPILE.cpp) $(if $(filter $(CC_TYPE),clang++),-include-pch $<) -o $@ $(@:.o=.cpp) + +test/unit/math/fwd/scal/%.o : stan/math/fwd/scal.hpp.gch test/unit/math/fwd/scal/%.cpp + $(COMPILE.cpp) $(if $(filter $(CC_TYPE),clang++),-include-pch $<) -o $@ $(@:.o=.cpp) + +test/unit/math/fwd/arr/%.o : stan/math/fwd/arr.hpp.gch test/unit/math/fwd/arr/%.cpp + $(COMPILE.cpp) $(if $(filter $(CC_TYPE),clang++),-include-pch $<) -o $@ $(@:.o=.cpp) + +test/unit/math/fwd/mat/%.o : stan/math/fwd/mat.hpp.gch test/unit/math/fwd/mat/%.cpp + $(COMPILE.cpp) $(if $(filter $(CC_TYPE),clang++),-include-pch $<) -o $@ $(@:.o=.cpp) + +test/unit/math/mix/scal/%.o : stan/math/mix/scal.hpp.gch test/unit/math/mix/scal/%.cpp + $(COMPILE.cpp) $(if $(filter $(CC_TYPE),clang++),-include-pch $<) -o $@ $(@:.o=.cpp) + +test/unit/math/mix/arr/%.o : stan/math/mix/arr.hpp.gch test/unit/math/mix/arr/%.cpp + $(COMPILE.cpp) $(if $(filter $(CC_TYPE),clang++),-include-pch $<) -o $@ $(@:.o=.cpp) + +test/unit/math/mix/mat/%.o : stan/math/mix/mat.hpp.gch test/unit/math/mix/mat/%.cpp + $(COMPILE.cpp) $(if $(filter $(CC_TYPE),clang++),-include-pch $<) -o $@ $(@:.o=.cpp) + +# No stan/math/mix/core.hpp exists +test/unit/math/mix/core/%.o : test/unit/math/mix/core/%.cpp + $(COMPILE.cpp) -o $@ $(@:.o=.cpp) + + ############################################################ ## # Test generator for distribution tests diff --git a/makefile b/makefile index 1e88f7b5ee9..1592289b682 100644 --- a/makefile +++ b/makefile @@ -1,12 +1,11 @@ # Makefile for Stan. ## +.SUFFIXES: + # The default target of this Makefile is... help: -## Disable implicit rules. -SUFIXES: - include make/default_compiler_options ## @@ -46,6 +45,7 @@ include make/cpplint # cpplint ## ifneq (,$(filter-out test-headers generate-tests clean% %-test %.d,$(MAKECMDGOALS))) -include $(addsuffix .d,$(subst $(EXE),,$(MAKECMDGOALS))) + -include $(shell find stan -name *.d) endif @@ -121,11 +121,11 @@ doxygen: clean: @echo ' removing test executables' $(shell find test -type f -name "*_test$(EXE)" -exec rm {} +) - $(shell find test -type f -name "*_test.d" -exec rm {} +) $(shell find test -type f -name "*_test.d.*" -exec rm {} +) $(shell find test -type f -name "*_test.xml" -exec rm {} +) $(shell find test -type f -name "*.o" -exec rm {} +) $(shell find test -type f -name "lib*.so" -exec rm {} +) + $(shell find test stan -type f -name "*.d" -or -name "*.hpp.gch" -exec rm {} +) clean-doxygen: $(RM) -r doc/api diff --git a/runTests.py b/runTests.py index 368ea8849ce..b72da3cf653 100755 --- a/runTests.py +++ b/runTests.py @@ -17,7 +17,7 @@ winsfx = ".exe" testsfx = "_test.cpp" -batchSize = 25 +batchSize = 32 def processCLIArgs():