Makefile: fix reconfigure check passing with prefix substring

Example: Before when you passed "make tests TESTFILTER=Attitude"
and subsequently "make tests TESTFILTER=Atti" it found the string
"TESTFILTER=Atti" in "TESTFILTER=Attitude" and hence the check if
the configuration is already correct passed. The fix checks for
the configuration parameter including the subsequent space separator
and after that strips the space away again such that the list
VERIFIED_CMAKE_OPTIONS doesn't contain trailing spaces.
This commit is contained in:
Matthias Grob 2019-04-23 08:41:21 +01:00
parent 542f61f04b
commit d8e0d641a5
1 changed files with 6 additions and 4 deletions

View File

@ -56,9 +56,12 @@ endif
# directory build/px4_fmu-v2_default and then call make # directory build/px4_fmu-v2_default and then call make
# in that directory with the target upload. # in that directory with the target upload.
# explicity set default build target # explicity set default build target
all: px4_sitl_default all: px4_sitl_default
# define a space character to be able to explicitly find it in strings
space := $(subst ,, )
# Parsing # Parsing
# -------------------------------------------------------------------- # --------------------------------------------------------------------
# assume 1st argument passed is the main target, the # assume 1st argument passed is the main target, the
@ -165,8 +168,8 @@ define cmake-cache-check
@$(eval CACHED_CMAKE_OPTIONS = $(shell cd $(BUILD_DIR) 2>/dev/null && cmake -L 2>/dev/null | sed -n 's/\([^[:blank:]]*\):[^[:blank:]]*\(=[^[:blank:]]*\)/\1\2/gp' )) @$(eval CACHED_CMAKE_OPTIONS = $(shell cd $(BUILD_DIR) 2>/dev/null && cmake -L 2>/dev/null | sed -n 's/\([^[:blank:]]*\):[^[:blank:]]*\(=[^[:blank:]]*\)/\1\2/gp' ))
@# transform the options in CMAKE_ARGS into the OPTION=VALUE format without -D @# transform the options in CMAKE_ARGS into the OPTION=VALUE format without -D
@$(eval DESIRED_CMAKE_OPTIONS = $(shell echo $(CMAKE_ARGS) | sed -n 's/-D\([^[:blank:]]*=[^[:blank:]]*\)/\1/gp' )) @$(eval DESIRED_CMAKE_OPTIONS = $(shell echo $(CMAKE_ARGS) | sed -n 's/-D\([^[:blank:]]*=[^[:blank:]]*\)/\1/gp' ))
@# find each currently desired option in the already cached ones @# find each currently desired option in the already cached ones making sure the complete configured string value is the same
@$(eval VERIFIED_CMAKE_OPTIONS = $(foreach option,$(DESIRED_CMAKE_OPTIONS),$(findstring $(option),$(CACHED_CMAKE_OPTIONS)))) @$(eval VERIFIED_CMAKE_OPTIONS = $(foreach option,$(DESIRED_CMAKE_OPTIONS),$(strip $(findstring $(option)$(space),$(CACHED_CMAKE_OPTIONS)))))
@# if the complete list of desired options is found in the list of verified options we don't need to reconfigure and CMAKE_CACHE_CHECK stays empty @# if the complete list of desired options is found in the list of verified options we don't need to reconfigure and CMAKE_CACHE_CHECK stays empty
@$(eval CMAKE_CACHE_CHECK = $(if $(findstring $(DESIRED_CMAKE_OPTIONS),$(VERIFIED_CMAKE_OPTIONS)),,y)) @$(eval CMAKE_CACHE_CHECK = $(if $(findstring $(DESIRED_CMAKE_OPTIONS),$(VERIFIED_CMAKE_OPTIONS)),,y))
endef endef
@ -474,7 +477,6 @@ distclean: gazeboclean
$(error "$@ cannot be the first argument. Use '$(MAKE) help|list_config_targets' to get a list of all possible [configuration] targets."),@#) $(error "$@ cannot be the first argument. Use '$(MAKE) help|list_config_targets' to get a list of all possible [configuration] targets."),@#)
# Print a list of non-config targets (based on http://stackoverflow.com/a/26339924/1487069) # Print a list of non-config targets (based on http://stackoverflow.com/a/26339924/1487069)
space := $(subst ,, )
help: help:
@echo "Usage: $(MAKE) <target>" @echo "Usage: $(MAKE) <target>"
@echo "Where <target> is one of:" @echo "Where <target> is one of:"