-
Notifications
You must be signed in to change notification settings - Fork 2.1k
build system: Restructure dependency resolution #13349
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| # Perform a recursive dependency resolution: Include $(RIOTBASE)/Makefile.dep | ||
| # until no new modules, pkgs, or features are pull in order to catch all | ||
| # transient dependencies | ||
|
|
||
| # Back up current state to detect changes | ||
| OLD_STATE := $(USEMODULE) $(USEPKG) $(FEATURES_USED) | ||
|
|
||
| # pull in dependencies of the currently used modules and pkgs | ||
| include $(RIOTBASE)/Makefile.dep | ||
|
|
||
| # check if required features are provided and update $(FEATURES_USED) | ||
| include $(RIOTMAKE)/features_check.inc.mk | ||
|
|
||
| # translate used features into used module, where needed | ||
| include $(RIOTMAKE)/features_modules.inc.mk | ||
|
|
||
| # sort and de-duplicate used modules, pkgs, and features for comparison | ||
| USEMODULE := $(sort $(USEMODULE)) | ||
| USEPKG := $(sort $(USEPKG)) | ||
| FEATURES_USED := $(sort $(FEATURES_USED)) | ||
|
|
||
| NEW_STATE := $(USEMODULE) $(USEPKG) $(FEATURES_USED) | ||
|
|
||
| # If set of used modules, pkgs, and features has changed during last run, run | ||
| # again to recursively catch transitive dependencies | ||
| ifneq ($(OLD_STATE),$(NEW_STATE)) | ||
| include $(RIOTMAKE)/dependency_resolution.inc.mk | ||
| else | ||
| # If module auto_init is not used, silently disable all of its submodules | ||
| ifeq (,$(filter auto_init,$(USEMODULE))) | ||
| DISABLE_MODULE += auto_init_% | ||
| endif | ||
|
|
||
| # add default modules again, as $(DEFAULT_MODULE) might have been extended | ||
| # during dependency processing | ||
| USEMODULE += $(filter-out $(DISABLE_MODULE),$(DEFAULT_MODULE)) | ||
|
|
||
| # Sort and de-duplicate used modules and default modules for readability | ||
| USEMODULE := $(sort $(USEMODULE)) | ||
| DEFAULT_MODULE := $(sort $(DEFAULT_MODULE)) | ||
| endif |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| # Check if all required FEATURES are provided | ||
|
|
||
| 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 without taking "one out of" dependencies into account | ||
| FEATURES_USED_SO_FAR := $(sort $(FEATURES_REQUIRED) $(FEATURES_OPTIONAL_USED)) | ||
|
|
||
| # Features that are provided and not blacklisted | ||
| FEATURES_USABLE := $(filter-out $(FEATURES_BLACKLIST),$(FEATURES_PROVIDED)) | ||
|
|
||
| # Additionally required features due to the "one out of" dependencies | ||
| # Algorithm: | ||
| # - For each list in FEATURES_REQUIRED_ANY as "item": | ||
| # - Store the intersection of FEATURES_USED_SO_FAR and the features in | ||
| # "item" in "tmp" | ||
| # - Append the intersection of FEATURES_USABLE and the features in "item" | ||
| # to "tmp" | ||
| # - Append "item" to "tmp" (with pipes between features, e.g. | ||
| # "periph_spi|periph_i2c") | ||
| # - Append the first element of "tmp" to FEATURES_REQUIRED_ONE_OUT_OF | ||
| # ==> If one (or more) already used features is listed in item, this (or | ||
| # one of these) will be in the front of "tmp" and be taken | ||
| # ==> If one (or more) usable features is listed in item, this will come | ||
| # afterwards. If no no feature in item is used so for, one of the | ||
| # features supported and listed in item will be picked | ||
| # ==> At the end of the list item itself (with pipes between features) is the | ||
| # last item in "tmp". If no feature is item is supported or used, this | ||
| # will be the only item in "tmp" and be picked | ||
| FEATURES_REQUIRED_ONE_OUT_OF := $(foreach item,\ | ||
| $(FEATURES_REQUIRED_ANY),\ | ||
| $(word 1,\ | ||
| $(filter $(subst |, ,$(item)),\ | ||
| $(FEATURES_USED_SO_FAR) \ | ||
| $(FEATURES_USABLE)) \ | ||
| $(item))) | ||
|
|
||
| # 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_REQUIRED_ONE_OUT_OF))) | ||
|
|
||
| # Features that are used for an application | ||
| FEATURES_USED := $(sort $(FEATURES_REQUIRED) \ | ||
| $(FEATURES_REQUIRED_ONE_OUT_OF) \ | ||
| $(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))) | ||
|
|
||
| # Features that are used by the application but blacklisted by the BSP. | ||
| # Having blacklisted features may cause the build to fail. | ||
| FEATURES_USED_BLACKLISTED := $(sort $(filter $(FEATURES_USED), $(FEATURES_BLACKLIST))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| # Add modules implementing used features | ||
| # | ||
| # This is done after the regular dependency resolution in Makefile.dep, as | ||
| # feature resolution depends on the used modules. As these modules however have | ||
| # no dependencies(except for periph_common), no dependency resolution is needed. | ||
|
|
||
| PERIPH_FEATURES := $(filter periph_%,$(FEATURES_USED)) | ||
|
fjmolinas marked this conversation as resolved.
|
||
| # all periph features correspond to a periph submodule | ||
| # FEATURES_USED is defined in Makefile.features | ||
| USEMODULE += $(PERIPH_FEATURES) | ||
|
|
||
| # Add all USED periph_% init modules unless they are blacklisted | ||
| ifneq (,$(filter periph_init, $(USEMODULE))) | ||
| PERIPH_MODULES := $(filter-out periph_init% periph_common,\ | ||
| $(filter periph_%,$(USEMODULE))) | ||
| # Use simple expansion to avoid USEMODULE referencing itself | ||
| PERIPH_INIT_MODULES := $(subst periph_,periph_init_,$(PERIPH_MODULES)) | ||
|
maribu marked this conversation as resolved.
|
||
| DEFAULT_MODULE += $(PERIPH_INIT_MODULES) | ||
| endif | ||
|
|
||
| # select cpu_check_address pseudomodule if the corresponding feature is used | ||
| USEMODULE += $(filter cpu_check_address, $(FEATURES_USED)) | ||
|
|
||
| # include periph_common if any periph_* driver is used | ||
| ifneq (,$(filter periph_%, $(USEMODULE))) | ||
| USEMODULE += periph_common | ||
| endif | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.