From cc80961b5fb8a4ce6130d16674efe096dcf5c9b8 Mon Sep 17 00:00:00 2001 From: Kaspar Schleiser Date: Fri, 4 May 2018 15:43:41 +0200 Subject: [PATCH] make: allow feature based blacklisting (FEATURES_BLACKLIST) --- Makefile.features | 10 ++++++++-- Makefile.include | 3 +++ makefiles/info-global.inc.mk | 2 ++ makefiles/info.inc.mk | 2 ++ 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/Makefile.features b/Makefile.features index 4cdf39e56e..1e6de19cf7 100644 --- a/Makefile.features +++ b/Makefile.features @@ -22,9 +22,11 @@ endif # Resolve FEATURES_ variables # Their value will only be complete after resolving dependencies -# Features that are required by the application but not provided by the BSP +# Features that are required by the application but not provided by the BSP and +# features that are used but blacklisted (prepended with "!"). # Having features missing may case the build to fail. -FEATURES_MISSING = $(sort $(filter-out $(FEATURES_PROVIDED),$(FEATURES_REQUIRED))) +FEATURES_MISSING = $(sort $(filter-out $(FEATURES_PROVIDED),$(FEATURES_REQUIRED)) \ + $(call _features_used_blacklisted)) # Features that are only optional and not required at the same time. # The policy is to by default use by features if they are provided by the BSP. @@ -47,3 +49,7 @@ _features_conflicting = $(if $(call _features_used_conflicting,$(subst :, ,$1)), # $1: list of features that conflict together # Return non empty on error _features_used_conflicting = $(filter $(words $1),$(words $(filter $(FEATURES_USED),$1))) + +# Return features that are used but blacklisted as +# "!" ("not feature") +_features_used_blacklisted = $(addprefix !,$(sort $(filter $(FEATURES_USED), $(FEATURES_BLACKLIST)))) diff --git a/Makefile.include b/Makefile.include index 4acf053677..da39ecaadf 100644 --- a/Makefile.include +++ b/Makefile.include @@ -732,6 +732,9 @@ ifneq (, $(filter all flash, $(if $(MAKECMDGOALS), $(MAKECMDGOALS), all))) EXPECT_ERRORS := 1 endif + # turn provided but blacklisted features into required "!" + FEATURES_REQUIRED += $(addprefix !,$(sort $(filter $(FEATURES_PROVIDED), $(FEATURES_BLACKLIST)))) + # Test if all feature requirements were met by the selected board. ifneq (,$(FEATURES_MISSING)) $(shell $(COLOR_ECHO) "$(COLOR_RED)There are unsatisfied feature requirements:$(COLOR_RESET)"\ diff --git a/makefiles/info-global.inc.mk b/makefiles/info-global.inc.mk index b3a97394a2..b79475125a 100644 --- a/makefiles/info-global.inc.mk +++ b/makefiles/info-global.inc.mk @@ -9,6 +9,7 @@ FEATURES_CONFLICT_GLOBAL := $(FEATURES_CONFLICT) FEATURES_CONFLICT_MSG_GLOBAL := $(FEATURES_MSG_CONFLICT) DISABLE_MODULE_GLOBAL := $(DISABLE_MODULE) DEFAULT_MODULE_GLOBAL := $(DEFAULT_MODULE) +FEATURES_BLACKLIST_GLOBAL := $(FEATURES_BLACKLIST) define board_missing_features BOARD := $(1) @@ -20,6 +21,7 @@ define board_missing_features FEATURES_OPTIONAL := $(FEATURES_OPTIONAL_GLOBAL) FEATURES_CONFLICT := $(FEATURES_CONFLICT_GLOBAL) FEATURES_CONFLICT_MSG := $(FEATURES_CONFLICT_MSG_GLOBAL) + FEATURES_BLACKLIST:= $(FEATURES_BLACKLIST_GLOBAL) # Remove board specific variables set by Makefile.features/Makefile.dep FEATURES_PROVIDED := diff --git a/makefiles/info.inc.mk b/makefiles/info.inc.mk index 47f0cc7744..0ec6d69624 100644 --- a/makefiles/info.inc.mk +++ b/makefiles/info.inc.mk @@ -60,6 +60,8 @@ info-build: @echo ' $(or $(sort $(FEATURES_PROVIDED)), -none-)' @echo 'FEATURES_MISSING (only non optional features):' @echo ' $(or $(FEATURES_MISSING), -none-)' + @echo 'FEATURES_BLACKLIST (blacklisted features):' + @echo ' $(or $(sort $(FEATURES_BLACKLIST)), -none-)' @echo '' @echo 'FEATURES_CONFLICT: $(FEATURES_CONFLICT)' @echo 'FEATURES_CONFLICT_MSG: $(FEATURES_CONFLICT_MSG)'