1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

Merge pull request #11492 from cladmi/pr/features/declarative

Makefile.features: add declarative FEATURES_ variables definition
This commit is contained in:
Francisco 2019-06-14 18:03:24 +02:00 committed by GitHub
commit ff317f2221
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 54 additions and 25 deletions

View File

@ -871,13 +871,9 @@ 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)))
# 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

View File

@ -1,3 +1,33 @@
# 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)))
# 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))
# 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)))

View File

@ -633,17 +633,16 @@ 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 (,$(FEATURES_MISSING))
$(shell $(COLOR_ECHO) "$(COLOR_RED)There are unsatisfied feature requirements:$(COLOR_RESET)"\
"$(sort $(filter-out $(FEATURES_PROVIDED) $(FEATURES_OPTIONAL), $(FEATURES_REQUIRED)))" 1>&2)
"$(FEATURES_MISSING)" 1>&2)
EXPECT_ERRORS := 1
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

View File

@ -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,12 +27,9 @@ 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)"
ifneq (, $$(filter-out $$(FEATURES_OPTIONAL), $$(FEATURES_MISSING)))
BOARDS_WITH_MISSING_FEATURES += $(1)
endif
BOARDS_WITH_MISSING_FEATURES += $(1)
endif
endef

View File

@ -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,19 +47,23 @@ 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_USED:'
@echo ' $(or $(FEATURES_USED), -none-)'
@echo 'FEATURES_REQUIRED:'
@echo ' $(or $(sort $(FEATURES_REQUIRED)), -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))), -none-)'
@echo 'FEATURES_MISSING (only non-optional features):'
@echo ' $(or $(sort $(filter-out $(FEATURES_OPTIONAL) $(FEATURES_PROVIDED), $(FEATURES_REQUIRED))), -none-)'
@echo 'FEATURES_MISSING (only non optional features):'
@echo ' $(or $(FEATURES_MISSING), -none-)'
@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 ''
@ -128,7 +133,10 @@ 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-features-used:
@for i in $(FEATURES_USED); do echo $$i; done
info-debug-variable-%:
@echo $($*)