From 4cb6931ac06e4da77f4fccbba4f7515274bae065 Mon Sep 17 00:00:00 2001 From: Rok Date: Mon, 30 Dec 2019 20:38:45 +0100 Subject: [PATCH 1/4] fix use of find on windows --- make/compiler_flags | 11 +++++++++++ make/libraries | 4 ++-- make/tests | 10 ++++++---- makefile | 26 +++++++++++++++----------- 4 files changed, 34 insertions(+), 17 deletions(-) diff --git a/make/compiler_flags b/make/compiler_flags index 60ede66b68c..48716bbe0b5 100644 --- a/make/compiler_flags +++ b/make/compiler_flags @@ -1,3 +1,14 @@ +## Find files subroutine for different operating system +ifeq ($(OS),Windows_NT) +findfiles=$(shell cmd.exe /C "dir /b /s $(subst /,\,$1)\$2 2>NUL") +else +findfiles=$(shell find $1 -type f -name $2) +endif + +ifneq ($(OS),Windows_NT) +GENERATE_DISTRIBUTION_TESTS=true +endif + # Detect operating system, set default compiler, and detect compiler type # The defaults are configured for the compilers we test: # https://github.com/stan-dev/stan/wiki/Supported-C---Compilers-and-Language-Features diff --git a/make/libraries b/make/libraries index 5f38b06a20a..c50b9793dcb 100644 --- a/make/libraries +++ b/make/libraries @@ -74,7 +74,7 @@ $(SUNDIALS)/lib/libsundials_nvecserial.a: $(SUNDIALS_NVECSERIAL) LIBSUNDIALS := $(SUNDIALS)/lib/libsundials_nvecserial.a $(SUNDIALS)/lib/libsundials_cvodes.a $(SUNDIALS)/lib/libsundials_idas.a $(SUNDIALS)/lib/libsundials_kinsol.a -STAN_SUNDIALS_HEADERS := $(shell find $(MATH)stan -name *cvodes*.hpp) $(shell find $(MATH)stan -name *idas*.hpp) $(shell find $(MATH)stan -name *kinsol*.hpp) +STAN_SUNDIALS_HEADERS := $(call findfiles,$(MATH)stan,*cvodes*.hpp) $(call findfiles,$(MATH)stan,*idas*.hpp) $(call findfiles,$(MATH)stan,*kinsol*.hpp) $(STAN_SUNDIALS_HEADERS) : $(LIBSUNDIALS) clean-sundials: @@ -196,7 +196,7 @@ $(BOOST)/stage/lib/libboost_mpi.dylib: $(BOOST)/stage/lib/mpi.so $(BOOST)/stage/ install_name_tool -change libboost_serialization.dylib @rpath/libboost_serialization.dylib "$(BOOST)/stage/lib/libboost_mpi.dylib" install_name_tool -id @rpath/libboost_mpi.dylib "$(BOOST)/stage/lib/libboost_mpi.dylib" -MPI_TEMPLATE_INSTANTIATION_CPP := $(shell find $(MATH)stan -type f -name 'mpi_*_inst.cpp') $(shell find $(MATH)stan -type f -name 'mpi_*_def.cpp') +MPI_TEMPLATE_INSTANTIATION_CPP := $(call findfiles,$(MATH)stan,mpi_*_inst.cpp) $(call findfiles,$(MATH)stan,mpi_*_def.cpp) MPI_TEMPLATE_INSTANTIATION := $(MPI_TEMPLATE_INSTANTIATION_CPP:%.cpp=%.o) $(MPI_TEMPLATE_INSTANTIATION) : CXXFLAGS += -fPIC diff --git a/make/tests b/make/tests index 0b0095ebf68..b4a64bbcd5f 100644 --- a/make/tests +++ b/make/tests @@ -40,7 +40,7 @@ test/unit/multiple_translation_units_test$(EXE): test/unit/libmultiple.so # CVODES tests ## -CVODES_TESTS := $(subst .cpp,$(EXE),$(shell find test -name *cvodes*_test.cpp) $(shell find test -name *_bdf_*_test.cpp) $(shell find test -name *_adams_*_test.cpp)) +CVODES_TESTS := $(subst .cpp,$(EXE),$(call findfiles,test,*cvodes*_test.cpp) $(call findfiles,test,*_bdf_*_test.cpp) $(call findfiles,test,*_adams_*_test.cpp)) $(CVODES_TESTS) : $(LIBSUNDIALS) @@ -49,7 +49,7 @@ $(CVODES_TESTS) : $(LIBSUNDIALS) # IDAS tests ## -IDAS_TESTS := $(subst .cpp,$(EXE),$(shell find test -name *idas*_test.cpp) $(shell find test -name *_dae*_test.cpp)) +IDAS_TESTS := $(subst .cpp,$(EXE),$(call findfiles,test,*idas*_test.cpp) $(call findfiles,test,*_dae*_test.cpp)) $(IDAS_TESTS) : $(LIBSUNDIALS) @@ -58,7 +58,7 @@ $(IDAS_TESTS) : $(LIBSUNDIALS) # KINSOL tests ## -ALGEBRA_SOLVER_TESTS := $(subst .cpp,$(EXE),$(shell find test -name *algebra_solver*_test.cpp)) +ALGEBRA_SOLVER_TESTS := $(subst .cpp,$(EXE),$(call findfiles,test,*algebra_solver*_test.cpp)) $(ALGEBRA_SOLVER_TESTS) : $(LIBSUNDIALS) @@ -67,7 +67,7 @@ $(ALGEBRA_SOLVER_TESTS) : $(LIBSUNDIALS) # Target to verify header files within Stan has # enough include calls ## -HEADER_TESTS := $(addsuffix -test,$(shell find stan -name '*.hpp' -type f)) +HEADER_TESTS := $(addsuffix -test,$(call findfiles,stan,*.hpp)) ifeq ($(OS),Windows_NT) DEV_NULL = nul @@ -86,6 +86,7 @@ test/dummy.cpp: .PHONY: test-headers test-headers: $(HEADER_TESTS) +ifdef GENERATE_DISTRIBUTION_TESTS ############################################################ ## # Test generator for distribution tests @@ -108,3 +109,4 @@ LIST_OF_GENERATED_TESTS := $(shell find test/prob -type f -name '*_test.hpp' | s .PHONY: generate-tests generate-tests: $(LIST_OF_GENERATED_TESTS) +endif \ No newline at end of file diff --git a/makefile b/makefile index 96d19852704..cba287ce86e 100644 --- a/makefile +++ b/makefile @@ -98,15 +98,15 @@ doxygen: .PHONY: clean clean-doxygen clean-deps clean-all 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 {} +) - $(RM) $(wildcard $(GTEST)/src/gtest-all.o) + @$(RM) $(call findfiles,test,*_test$(EXE)) + @$(RM) $(call findfiles,test,*_test.d) + @$(RM) $(call findfiles,test,*_test.d.*) + @$(RM) $(call findfiles,test,*_test.xml) + @$(RM) $(call findfiles,test,*.o) + @$(RM) $(wildcard $(GTEST)/src/gtest-all.o) @echo ' removing generated test files' - $(RM) $(wildcard test/prob/generate_tests$(EXE)) - $(shell find test/prob -name '*_generated_*_test.cpp' -type f -exec rm {} +) + @$(RM) $(wildcard test/prob/generate_tests$(EXE)) + @$(RM) $(call findfiles,test/prob,*_generated_*_test.cpp) clean-doxygen: @echo ' removing doxygen' @@ -114,9 +114,13 @@ clean-doxygen: clean-deps: @echo ' removing dependency files' - $(shell find stan test lib -type f -name '*.d' -exec rm {} +) - $(shell find stan test lib -type f -name '*.d.*' -exec rm {} +) - $(shell find stan -type f -name '*.dSYM' -exec rm {} +) + @$(RM) $(call findfiles,stan,*.d) + @$(RM) $(call findfiles,test,*.d) + @$(RM) $(call findfiles,lib,*.d) + @$(RM) $(call findfiles,stan,*.d.*) + @$(RM) $(call findfiles,test,*.d.*) + @$(RM) $(call findfiles,lib,*.d.*) + @$(RM) $(call findfiles,stan,*.dSYM) clean-all: clean clean-doxygen clean-deps clean-libraries From 9497bb9244f656d313fec698e842553b770561b5 Mon Sep 17 00:00:00 2001 From: Rok Date: Mon, 30 Dec 2019 20:54:35 +0100 Subject: [PATCH 2/4] add newline --- make/tests | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/make/tests b/make/tests index b4a64bbcd5f..25344579189 100644 --- a/make/tests +++ b/make/tests @@ -109,4 +109,4 @@ LIST_OF_GENERATED_TESTS := $(shell find test/prob -type f -name '*_test.hpp' | s .PHONY: generate-tests generate-tests: $(LIST_OF_GENERATED_TESTS) -endif \ No newline at end of file +endif From 19df5ad067851452848af22bca01d7bbbfc18612 Mon Sep 17 00:00:00 2001 From: Rok Date: Tue, 31 Dec 2019 14:54:26 +0100 Subject: [PATCH 3/4] replace the separate function with a recursive wildcard --- make/compiler_flags | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/make/compiler_flags b/make/compiler_flags index 48716bbe0b5..9c5133f3557 100644 --- a/make/compiler_flags +++ b/make/compiler_flags @@ -1,9 +1,6 @@ -## Find files subroutine for different operating system -ifeq ($(OS),Windows_NT) -findfiles=$(shell cmd.exe /C "dir /b /s $(subst /,\,$1)\$2 2>NUL") -else -findfiles=$(shell find $1 -type f -name $2) -endif +# Find files subroutine for different operating system +# This is recursive version of the makefiles wildcard function +findfiles=$(foreach d,$(wildcard $(addsuffix *,$(1))),$(call findfiles,$(d)/,$(2)) $(filter $(subst *,%,$(2)),$(d))) ifneq ($(OS),Windows_NT) GENERATE_DISTRIBUTION_TESTS=true From fb7224b0f4462cbb09e8939c6e41a3d496d7c8e0 Mon Sep 17 00:00:00 2001 From: Rok Date: Tue, 31 Dec 2019 19:26:41 +0100 Subject: [PATCH 4/4] fix the recursive call --- make/compiler_flags | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/make/compiler_flags b/make/compiler_flags index 9c5133f3557..929647ee77d 100644 --- a/make/compiler_flags +++ b/make/compiler_flags @@ -1,6 +1,6 @@ # Find files subroutine for different operating system # This is recursive version of the makefiles wildcard function -findfiles=$(foreach d,$(wildcard $(addsuffix *,$(1))),$(call findfiles,$(d)/,$(2)) $(filter $(subst *,%,$(2)),$(d))) +findfiles = $(foreach d,$(wildcard $(addsuffix *,$(1))),$(call findfiles,$(d)/,$(2)) $(wildcard $(d)/$(2))) ifneq ($(OS),Windows_NT) GENERATE_DISTRIBUTION_TESTS=true