From 700b5fb835f05fe378967177b9ea52ecba09c5a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Harter?= Date: Fri, 3 May 2019 16:14:49 +0200 Subject: [PATCH 1/4] makefiles: Update FEATURES_OPTIONAL meaning Update the FEATURES_OPTIONAL meaning to be more in line since FEATURES_USED is defined. Handle FEATURES_OPTIONAL as a configuration from the BSP/build that should not be changed anymore after. `FEATURES_OPTIONAL` are by definition optional so are not supposed to cause a build to fail. Only the 'REQUIRED' ones that are not 'PROVIDED' are 'MISSING'. * Do not change FEATURES_OPTIONAL to remove REQUIRED features * Prepare for having a different variable for the previous value * Update dependency resolution/info-build as FEATURES_OPTIONAL cannot be missing --- Makefile.dep | 3 --- Makefile.include | 4 ++-- makefiles/info-global.inc.mk | 4 +--- makefiles/info.inc.mk | 14 ++++++++------ 4 files changed, 11 insertions(+), 14 deletions(-) diff --git a/Makefile.dep b/Makefile.dep index adabdabd7c..e99cda1519 100644 --- a/Makefile.dep +++ b/Makefile.dep @@ -865,9 +865,6 @@ FEATURES_OPTIONAL += periph_pm # include package dependencies -include $(USEPKG:%=$(RIOTPKG)/%/Makefile.dep) -# remove required features from optional features -FEATURES_OPTIONAL := $(filter-out $(FEATURES_REQUIRED),$(FEATURES_OPTIONAL)) - # add all optional but provided features to the list of used features FEATURES_USED := $(sort $(FEATURES_REQUIRED) $(filter $(FEATURES_OPTIONAL),$(FEATURES_PROVIDED))) diff --git a/Makefile.include b/Makefile.include index 9e8e8f78f8..8d31e2b880 100644 --- a/Makefile.include +++ b/Makefile.include @@ -622,9 +622,9 @@ ifneq (, $(filter all flash, $(if $(MAKECMDGOALS), $(MAKECMDGOALS), all))) endif # Test if all feature requirements were met by the selected board. - ifneq (, $(filter-out $(FEATURES_PROVIDED) $(FEATURES_OPTIONAL), $(FEATURES_REQUIRED))) + ifneq (,$(filter-out $(FEATURES_PROVIDED), $(FEATURES_REQUIRED))) $(shell $(COLOR_ECHO) "$(COLOR_RED)There are unsatisfied feature requirements:$(COLOR_RESET)"\ - "$(sort $(filter-out $(FEATURES_PROVIDED) $(FEATURES_OPTIONAL), $(FEATURES_REQUIRED)))" 1>&2) + "$(sort $(filter-out $(FEATURES_PROVIDED), $(FEATURES_REQUIRED)))" 1>&2) EXPECT_ERRORS := 1 endif diff --git a/makefiles/info-global.inc.mk b/makefiles/info-global.inc.mk index f6996eddad..9895106c61 100644 --- a/makefiles/info-global.inc.mk +++ b/makefiles/info-global.inc.mk @@ -31,9 +31,7 @@ define board_missing_features FEATURES_MISSING := $$(sort $$(filter-out $$(FEATURES_PROVIDED), $$(FEATURES_REQUIRED))) ifneq (, $$(FEATURES_MISSING)) BOARDS_FEATURES_MISSING += "$(1) $$(FEATURES_MISSING)" - ifneq (, $$(filter-out $$(FEATURES_OPTIONAL), $$(FEATURES_MISSING))) - BOARDS_WITH_MISSING_FEATURES += $(1) - endif + BOARDS_WITH_MISSING_FEATURES += $(1) endif endef diff --git a/makefiles/info.inc.mk b/makefiles/info.inc.mk index 239b819c11..8ccd6cfeb5 100644 --- a/makefiles/info.inc.mk +++ b/makefiles/info.inc.mk @@ -46,16 +46,18 @@ info-build: @echo 'HEXFILE: $(HEXFILE)' @echo 'FLASHFILE: $(FLASHFILE)' @echo '' - @echo 'FEATURES_REQUIRED (excl. optional features):' - @echo ' $(or $(sort $(filter-out $(FEATURES_OPTIONAL), $(FEATURES_REQUIRED))), -none-)' - @echo 'FEATURES_OPTIONAL (strictly "nice to have"):' - @echo ' $(or $(sort $(FEATURES_OPTIONAL)), -none-)' + @echo 'FEATURES_REQUIRED:' + @echo ' $(or $(sort $(FEATURES_REQUIRED)), -none-)' + @echo 'FEATURES_OPTIONAL (optional that are not required, strictly "nice to have"):' + @echo ' $(or $(sort $(filter-out $(FEATURES_REQUIRED),$(FEATURES_OPTIONAL))),-none)' + @echo 'FEATURES_OPTIONAL (unused optional features):' + @echo ' $(or $(sort $(filter-out $(FEATURES_PROVIDED),$(FEATURES_OPTIONAL))), -none-)' @echo 'FEATURES_PROVIDED (by the board or USEMODULE'"'"'d drivers):' @echo ' $(or $(sort $(FEATURES_PROVIDED)), -none-)' @echo 'FEATURES_MISSING (incl. optional features):' + @echo ' $(or $(sort $(filter-out $(FEATURES_PROVIDED), $(FEATURES_REQUIRED) $(FEATURES_OPTIONAL))), -none-)' + @echo 'FEATURES_MISSING (only non optional features):' @echo ' $(or $(sort $(filter-out $(FEATURES_PROVIDED), $(FEATURES_REQUIRED))), -none-)' - @echo 'FEATURES_MISSING (only non-optional features):' - @echo ' $(or $(sort $(filter-out $(FEATURES_OPTIONAL) $(FEATURES_PROVIDED), $(FEATURES_REQUIRED))), -none-)' @echo '' @echo 'FEATURES_CONFLICT: $(FEATURES_CONFLICT)' @echo 'FEATURES_CONFLICT_MSG: $(FEATURES_CONFLICT_MSG)' From e1c60ead36511a00c7db97c7379d6beb3b7bbe8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Harter?= Date: Fri, 3 May 2019 16:19:20 +0200 Subject: [PATCH 2/4] Makefile.features: declare FEATURES_MISSING and make use of it Put the definition of `FEATURES_MISSING` in common and use the variable instead of duplicating code. --- Makefile.features | 8 ++++++++ Makefile.include | 4 ++-- makefiles/info-global.inc.mk | 4 +--- makefiles/info.inc.mk | 4 ++-- 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/Makefile.features b/Makefile.features index 4008a32b7c..b5990e80e4 100644 --- a/Makefile.features +++ b/Makefile.features @@ -1,3 +1,11 @@ # Process FEATURES variables include $(RIOTBOARD)/$(BOARD)/Makefile.features + + +# 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 +# Having features missing may case the build to fail. +FEATURES_MISSING = $(sort $(filter-out $(FEATURES_PROVIDED),$(FEATURES_REQUIRED))) diff --git a/Makefile.include b/Makefile.include index 8d31e2b880..3457cb5549 100644 --- a/Makefile.include +++ b/Makefile.include @@ -622,9 +622,9 @@ ifneq (, $(filter all flash, $(if $(MAKECMDGOALS), $(MAKECMDGOALS), all))) endif # Test if all feature requirements were met by the selected board. - ifneq (,$(filter-out $(FEATURES_PROVIDED), $(FEATURES_REQUIRED))) + ifneq (,$(FEATURES_MISSING)) $(shell $(COLOR_ECHO) "$(COLOR_RED)There are unsatisfied feature requirements:$(COLOR_RESET)"\ - "$(sort $(filter-out $(FEATURES_PROVIDED), $(FEATURES_REQUIRED)))" 1>&2) + "$(FEATURES_MISSING)" 1>&2) EXPECT_ERRORS := 1 endif diff --git a/makefiles/info-global.inc.mk b/makefiles/info-global.inc.mk index 9895106c61..724be08f89 100644 --- a/makefiles/info-global.inc.mk +++ b/makefiles/info-global.inc.mk @@ -14,7 +14,6 @@ define board_missing_features DISABLE_MODULE := $(DISABLE_MODULE_GLOBAL) FEATURES_REQUIRED := $(FEATURES_REQUIRED_GLOBAL) FEATURES_OPTIONAL := $(FEATURES_OPTIONAL_GLOBAL) - FEATURES_MISSING := FEATURES_PROVIDED := include $(RIOTBASE)/Makefile.features @@ -28,8 +27,7 @@ define board_missing_features include $(RIOTBASE)/Makefile.dep - FEATURES_MISSING := $$(sort $$(filter-out $$(FEATURES_PROVIDED), $$(FEATURES_REQUIRED))) - ifneq (, $$(FEATURES_MISSING)) + ifneq (,$$(FEATURES_MISSING)) BOARDS_FEATURES_MISSING += "$(1) $$(FEATURES_MISSING)" BOARDS_WITH_MISSING_FEATURES += $(1) endif diff --git a/makefiles/info.inc.mk b/makefiles/info.inc.mk index 8ccd6cfeb5..5c7ec9440a 100644 --- a/makefiles/info.inc.mk +++ b/makefiles/info.inc.mk @@ -57,7 +57,7 @@ info-build: @echo 'FEATURES_MISSING (incl. optional features):' @echo ' $(or $(sort $(filter-out $(FEATURES_PROVIDED), $(FEATURES_REQUIRED) $(FEATURES_OPTIONAL))), -none-)' @echo 'FEATURES_MISSING (only non optional features):' - @echo ' $(or $(sort $(filter-out $(FEATURES_PROVIDED), $(FEATURES_REQUIRED))), -none-)' + @echo ' $(or $(FEATURES_MISSING), -none-)' @echo '' @echo 'FEATURES_CONFLICT: $(FEATURES_CONFLICT)' @echo 'FEATURES_CONFLICT_MSG: $(FEATURES_CONFLICT_MSG)' @@ -130,7 +130,7 @@ info-features-required: @for i in $(sort $(FEATURES_REQUIRED)); do echo $$i; done info-features-missing: - @for i in $(sort $(filter-out $(FEATURES_PROVIDED), $(FEATURES_REQUIRED))); do echo $$i; done + @for i in $(FEATURES_MISSING); do echo $$i; done info-debug-variable-%: @echo $($*) From 9cccc302622f42bd711383699c3d51c369ca8f8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Harter?= Date: Fri, 3 May 2019 16:19:20 +0200 Subject: [PATCH 3/4] Makefile.features: declare FEATURES_USED and make use of it Put the definition of `FEATURES_USED` in common and use the variable instead of duplicating code. This required defining 'FEATURES_OPTIONAL_ONLY|USED' to not overwrite the value of 'FEATURES_OPTIONAL' as was done before. Also add 'FEATURES_OPTIONAL_MISSING' to list optional features that were not included as not provided. This removes the need to print FEATURES_MISSING with the optional features too. --- Makefile.dep | 3 +-- Makefile.features | 10 ++++++++++ makefiles/info.inc.mk | 16 ++++++++++------ 3 files changed, 21 insertions(+), 8 deletions(-) diff --git a/Makefile.dep b/Makefile.dep index e99cda1519..730b30b732 100644 --- a/Makefile.dep +++ b/Makefile.dep @@ -865,10 +865,9 @@ FEATURES_OPTIONAL += periph_pm # include package dependencies -include $(USEPKG:%=$(RIOTPKG)/%/Makefile.dep) -# add all optional but provided features to the list of used features -FEATURES_USED := $(sort $(FEATURES_REQUIRED) $(filter $(FEATURES_OPTIONAL),$(FEATURES_PROVIDED))) # all periph features correspond to a periph submodule +# FEATURES_USED is defined in Makefile.features USEMODULE += $(filter periph_%,$(FEATURES_USED)) # select cpu_check_address pseudomodule if the corresponding feature is used diff --git a/Makefile.features b/Makefile.features index b5990e80e4..20cc8d9112 100644 --- a/Makefile.features +++ b/Makefile.features @@ -9,3 +9,13 @@ include $(RIOTBOARD)/$(BOARD)/Makefile.features # Features that are required by the application but not provided by the BSP # Having features missing may case the build to fail. FEATURES_MISSING = $(sort $(filter-out $(FEATURES_PROVIDED),$(FEATURES_REQUIRED))) + +# 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. +FEATURES_OPTIONAL_ONLY = $(sort $(filter-out $(FEATURES_REQUIRED),$(FEATURES_OPTIONAL))) +FEATURES_OPTIONAL_USED = $(sort $(filter $(FEATURES_PROVIDED),$(FEATURES_OPTIONAL_ONLY))) +# Optional features that will not be used because they are not provided +FEATURES_OPTIONAL_MISSING = $(sort $(filter-out $(FEATURES_PROVIDED),$(FEATURES_OPTIONAL_ONLY))) + +# Features that are used for an application +FEATURES_USED = $(sort $(FEATURES_REQUIRED) $(FEATURES_OPTIONAL_USED)) diff --git a/makefiles/info.inc.mk b/makefiles/info.inc.mk index 5c7ec9440a..0c71f535f7 100644 --- a/makefiles/info.inc.mk +++ b/makefiles/info.inc.mk @@ -1,6 +1,7 @@ .PHONY: info-objsize info-buildsizes info-build info-boards-supported \ info-features-missing info-modules info-cpu \ info-features-provided info-features-required \ + info-features-used \ info-debug-variable-% info-toolchains-supported \ check-toolchain-supported @@ -46,16 +47,16 @@ info-build: @echo 'HEXFILE: $(HEXFILE)' @echo 'FLASHFILE: $(FLASHFILE)' @echo '' + @echo 'FEATURES_USED:' + @echo ' $(or $(FEATURES_USED), -none-)' @echo 'FEATURES_REQUIRED:' @echo ' $(or $(sort $(FEATURES_REQUIRED)), -none-)' - @echo 'FEATURES_OPTIONAL (optional that are not required, strictly "nice to have"):' - @echo ' $(or $(sort $(filter-out $(FEATURES_REQUIRED),$(FEATURES_OPTIONAL))),-none)' - @echo 'FEATURES_OPTIONAL (unused optional features):' - @echo ' $(or $(sort $(filter-out $(FEATURES_PROVIDED),$(FEATURES_OPTIONAL))), -none-)' + @echo 'FEATURES_OPTIONAL_ONLY (optional that are not required, strictly "nice to have"):' + @echo ' $(or $(FEATURES_OPTIONAL_ONLY), -none-)' + @echo 'FEATURES_OPTIONAL_MISSING (missing optional features):' + @echo ' $(or $(FEATURES_OPTIONAL_MISSING), -none-)' @echo 'FEATURES_PROVIDED (by the board or USEMODULE'"'"'d drivers):' @echo ' $(or $(sort $(FEATURES_PROVIDED)), -none-)' - @echo 'FEATURES_MISSING (incl. optional features):' - @echo ' $(or $(sort $(filter-out $(FEATURES_PROVIDED), $(FEATURES_REQUIRED) $(FEATURES_OPTIONAL))), -none-)' @echo 'FEATURES_MISSING (only non optional features):' @echo ' $(or $(FEATURES_MISSING), -none-)' @echo '' @@ -132,6 +133,9 @@ info-features-required: info-features-missing: @for i in $(FEATURES_MISSING); do echo $$i; done +info-features-used: + @for i in $(FEATURES_USED); do echo $$i; done + info-debug-variable-%: @echo $($*) From 6d7a70b16b32d42df9ecee4fadc20d179b1a341c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Harter?= Date: Fri, 3 May 2019 17:47:42 +0200 Subject: [PATCH 4/4] Makefile.features: declare FEATURES_CONFLICTING and make use of it Define a variable for used features that conflict and use it in `Makefie.include`. It was not used by `info-global.inc.mk` and is still currently not. --- Makefile.features | 12 ++++++++++++ Makefile.include | 5 ++--- makefiles/info.inc.mk | 2 ++ 3 files changed, 16 insertions(+), 3 deletions(-) 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 ''