diff --git a/Makefile.features b/Makefile.features index 20cc8d9112..52965f154b 100644 --- a/Makefile.features +++ b/Makefile.features @@ -19,3 +19,15 @@ FEATURES_OPTIONAL_MISSING = $(sort $(filter-out $(FEATURES_PROVIDED),$(FEATURES_ # Features that are used for an application FEATURES_USED = $(sort $(FEATURES_REQUIRED) $(FEATURES_OPTIONAL_USED)) + +# Used features that conflict when used together +FEATURES_CONFLICTING = $(sort $(foreach conflict,$(FEATURES_CONFLICT),$(call _features_conflicting,$(conflict)))) + +# Return conflicting features from the conflict string feature1:feature2 +# $1: feature1:feature2 +# Return the list of conflicting features +_features_conflicting = $(if $(call _features_used_conflicting,$(subst :, ,$1)),$(subst :, ,$1)) +# Check if all features from the list are used +# $1: list of features that conflict together +# Return non empty on error +_features_used_conflicting = $(filter $(words $1),$(words $(filter $(FEATURES_USED),$1))) diff --git a/Makefile.include b/Makefile.include index 3457cb5549..86dbd4ad19 100644 --- a/Makefile.include +++ b/Makefile.include @@ -629,10 +629,9 @@ ifneq (, $(filter all flash, $(if $(MAKECMDGOALS), $(MAKECMDGOALS), all))) endif # Test if any used feature conflict with another one. - CONFLICT := $(foreach var,$(FEATURES_CONFLICT),$(if $(filter $(words $(subst :, ,$(var))),$(words $(filter $(FEATURES_USED),$(subst :, ,$(var))))),$(subst :, ,$(var)))) - ifneq (, $(strip $(CONFLICT))) + ifneq (,$(FEATURES_CONFLICTING)) $(shell $(COLOR_ECHO) "$(COLOR_YELLOW)The following features may conflict:$(COLOR_RESET)"\ - "$(COLOR_GREEN)$(sort $(filter $(FEATURES_USED), $(CONFLICT)))$(COLOR_RESET)" 1>&2) + "$(FEATURES_CONFLICTING)" 1>&2) ifneq (, $(FEATURES_CONFLICT_MSG)) $(shell $(COLOR_ECHO) "$(COLOR_YELLOW)Rationale: $(COLOR_RESET)$(FEATURES_CONFLICT_MSG)" 1>&2) endif diff --git a/makefiles/info.inc.mk b/makefiles/info.inc.mk index 0c71f535f7..da49e850bd 100644 --- a/makefiles/info.inc.mk +++ b/makefiles/info.inc.mk @@ -62,6 +62,8 @@ info-build: @echo '' @echo 'FEATURES_CONFLICT: $(FEATURES_CONFLICT)' @echo 'FEATURES_CONFLICT_MSG: $(FEATURES_CONFLICT_MSG)' + @echo 'FEATURES_CONFLICTING:' + @echo ' $(or $(FEATURES_CONFLICTING), -none-)' @echo '' @echo -e 'INCLUDES:$(patsubst %, \n\t%, $(INCLUDES))' @echo ''