1.1 --- a/common/makefiles/MakeBase.gmk Thu Dec 27 20:15:22 2012 +0100 1.2 +++ b/common/makefiles/MakeBase.gmk Thu Dec 27 20:18:21 2012 +0100 1.3 @@ -391,4 +391,46 @@ 1.4 endef 1.5 endif 1.6 1.7 +# Convenience functions for working around make's limitations with $(filter ). 1.8 +containing = $(foreach v,$2,$(if $(findstring $1,$v),$v)) 1.9 +not-containing = $(foreach v,$2,$(if $(findstring $1,$v),,$v)) 1.10 + 1.11 +################################################################################ 1.12 +# In Cygwin, finds are very costly, both because of expensive forks and because 1.13 +# of bad file system caching. Find is used extensively in $(shell) commands to 1.14 +# find source files. This makes rerunning make with no or few changes rather 1.15 +# expensive. To speed this up, these two macros are used to cache the results 1.16 +# of simple find commands for reuse. 1.17 +# 1.18 +# Runs a find and stores both the directories where it was run and the results. 1.19 +# This macro can be called multiple times to add to the cache. Only finds files 1.20 +# with no filters. 1.21 +# 1.22 +# Needs to be called with $(eval ) 1.23 +# 1.24 +# Param 1 - Dir to find in 1.25 +ifeq ($(OPENJDK_BUILD_OS),windows) 1.26 +define FillCacheFind 1.27 + FIND_CACHE_DIR += $1 1.28 + FIND_CACHE := $$(sort $$(FIND_CACHE) $$(shell $(FIND) $1 -type f -o -type l)) 1.29 +endef 1.30 +else 1.31 +define FillCacheFind 1.32 +endef 1.33 +endif 1.34 + 1.35 +# Mimics find by looking in the cache if all of the directories have been cached. 1.36 +# Otherwise reverts to shell find. This is safe to call on all platforms, even if 1.37 +# cache is deactivated. 1.38 +# 1.39 +# The extra - is needed when FIND_CACHE_DIR is empty but should be harmless. 1.40 +# Param 1 - Dirs to find in 1.41 +define CacheFind 1.42 + $(if $(filter-out $(addsuffix %,- $(FIND_CACHE_DIR)),$1),\ 1.43 + $(shell $(FIND) $1 -type f -o -type l),\ 1.44 + $(filter $(addsuffix %,$1),$(FIND_CACHE))) 1.45 +endef 1.46 + 1.47 +################################################################################ 1.48 + 1.49 endif # _MAKEBASE_GMK