From 43781c3fbacfed54bbf9396dc8588a46f76c5ef4 Mon Sep 17 00:00:00 2001 From: Marian Buschsieweke Date: Mon, 15 Feb 2021 13:40:50 +0100 Subject: [PATCH] build_system: don't optionally use conflicting features If adding a provided but optional feature would result in a feature conflict, don't use it. --- makefiles/features_check.inc.mk | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/makefiles/features_check.inc.mk b/makefiles/features_check.inc.mk index b10ac34aab..9f010b36ce 100644 --- a/makefiles/features_check.inc.mk +++ b/makefiles/features_check.inc.mk @@ -1,7 +1,23 @@ # Check if all required FEATURES are provided -# Features that are provided and not blacklisted -FEATURES_USABLE := $(filter-out $(FEATURES_BLACKLIST),$(FEATURES_PROVIDED)) +# Features that are used without taking "one out of" dependencies into account +FEATURES_USED_SO_FAR := $(sort $(FEATURES_REQUIRED) $(FEATURES_OPTIONAL_USED)) + +# Get features which inclusion would cause a conflict +# Parameter 1: Features currently used +# Parameter 2: A set of features that would conflict (separated by spaces) +# Algorithm: If interaction of the two lists is empty, return an empty set. Otherwise return +# the set of conflicting features without the feature in it that is already used +_features_would_conflict = $(if $(filter $1,$2),$(filter-out $1,$2)) +# Adding any of the following features would result in a feature conflict with the already used +# features: +FEATURES_WOULD_CONFLICT := $(foreach conflict,$(FEATURES_CONFLICT),\ + $(call _features_would_conflict,\ + $(FEATURES_USED_SO_FAR),$(subst :, ,$(conflict)))) + +# Features that are provided, not blacklisted, and do not conflict with any used feature +FEATURES_USABLE := $(filter-out $(FEATURES_BLACKLIST) $(FEATURES_WOULD_CONFLICT),\ + $(FEATURES_PROVIDED)) # Features that may be used, if provided. FEATURES_OPTIONAL_ONLY := $(sort $(filter-out $(FEATURES_REQUIRED),$(FEATURES_OPTIONAL))) @@ -12,7 +28,7 @@ FEATURES_OPTIONAL_USED := $(sort $(filter $(FEATURES_USABLE),$(FEATURES_OPTIONAL # Optional features that will not be used because they are not provided or blacklisted FEATURES_OPTIONAL_MISSING := $(sort $(filter-out $(FEATURES_USABLE),$(FEATURES_OPTIONAL_ONLY))) -# Features that are used without taking "one out of" dependencies into account +# Update to account for change in FEATURES_OPTIONAL_USED FEATURES_USED_SO_FAR := $(sort $(FEATURES_REQUIRED) $(FEATURES_OPTIONAL_USED)) # Additionally required features due to the "one out of" dependencies