Skip to content
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

dist/tools: add build system sanity check script #10179

Merged

Conversation

cladmi
Copy link
Contributor

@cladmi cladmi commented Oct 17, 2018

Contribution description

Split from #10060

Add a script to execute sanity checks on build system files.
It should prevent bad patterns to re-appear after being cleaned.

Currently adds a check for using the content of FEATURES instead of
USEMODULE.

Modules should not check the content of FEATURES_PROVIDED/_REQUIRED/OPTIONAL
Handling specific behaviors/dependencies should by checking the content of:

  • USEMODULE
  • maybe FEATURES_USED if it is not a module (== not a periph_)

The script cannot currently be enabled by default as there are some fixes that are not included:
#10060

Testing procedure

The script correctly passes shellcheck without errors.

You can list the current errors by running:

./dist/tools/buildsystem_sanity_check/check.sh

It finds the current violations on using FEATURES_PROVIDED, FEATURES_OPTIONAL and FEATURES_REQUIRED to configure specific behavior.

./dist/tools/buildsystem_sanity_check/check.sh 
Invalid build system patterns found by dist/tools/buildsystem_sanity_check/check.sh:
boards/hifive1/Makefile.features:ifneq (,$(filter periph_rtc,$(FEATURES_REQUIRED)))
pkg/fatfs/Makefile.dep:ifneq (, $(filter periph_rtc, $(FEATURES_PROVIDED)))
sys/shell/commands/Makefile:ifneq (,$(filter periph_rtc,$(FEATURES_PROVIDED)))

With the fixes to these, it runs silently without errors as done in #10060

Issues/PRs references

Split from #10060 and is part of working on #9913

@cladmi cladmi added Area: tests Area: tests and testing framework Area: build system Area: Build system CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR labels Oct 17, 2018
@cladmi cladmi requested a review from jcarrano October 17, 2018 15:27
@cladmi cladmi added this to the Release 2018.10 milestone Oct 21, 2018
Copy link
Contributor

@jcarrano jcarrano left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fine. I left some suggestions to simplify it a bit.

dist/tools/buildsystem_sanity_check/check.sh Show resolved Hide resolved
dist/tools/buildsystem_sanity_check/check.sh Show resolved Hide resolved
dist/tools/buildsystem_sanity_check/check.sh Show resolved Hide resolved
@cladmi
Copy link
Contributor Author

cladmi commented Oct 30, 2018

The question I still have, is should I change the way of handling errors. I took this one from another script but fear it will not scale correctly when adding other tests.

It would currently make all errors have only one header with Invalid build system patterns found by .

I was thinking about adding a sed that prepends some lines describing the type of errors after the git grep if it returns some text. What do you think ?

@jcarrano
Copy link
Contributor

It is not critical how we present it, as long as it is easy for the user to find and correct them.

This issue and the one with RIOTBASE, SCRIPTPATH, excluding the script file from the grep, etc are shared amongst all check scripts, so it may make more sense at some point to put all of that functionality in a shared file and source that from all the scripts.

@cladmi
Copy link
Contributor Author

cladmi commented Nov 12, 2018

I am not sure SCRIPTPATH is required by other tools as I am using it to not self match myself only.
But the RIOTBASE might indeed be.

Should I still change something with this PR for the moment ?

Add a script to execute sanity checks on build system files.
It should prevent bad patterns to re-appear after being cleaned.

Currently adds a check for using the content of `FEATURES` instead of
`USEMODULE`.

Modules should not check the content of FEATURES_PROVIDED/_REQUIRED/OPTIONAL
Handling specific behaviors/dependencies should by checking the content of:
 * `USEMODULE`
 * maybe `FEATURES_USED` if it is not a module (== not a periph_)
@cladmi cladmi force-pushed the pr/dist/tools/build_system/check branch from ae0bdb3 to 143e393 Compare November 16, 2018 15:40
@MrKevinWeiss
Copy link
Contributor

I tested this PR and got:

./dist/tools/buildsystem_sanity_check/check.sh

Invalid build system patterns found by ./dist/tools/buildsystem_sanity_check/check.sh:
pkg/fatfs/Makefile.dep:ifneq (, $(filter periph_rtc, $(FEATURES_PROVIDED)))
sys/shell/commands/Makefile:ifneq (,$(filter periph_rtc,$(FEATURES_PROVIDED)))

When testing with #10060 it has no errors.

It does make sense to enforce structure in the build system but I cannot say much more than that.

@cladmi
Copy link
Contributor Author

cladmi commented Nov 19, 2018

Thank you for testing, and indeed, since I created the PR, the first error line was fixed!

@MrKevinWeiss What you can answer, is would you like more output if you get this error on a PR.
Or is it enough for you to go in the check.sh script to find the reason.

Copy link
Contributor

@jcarrano jcarrano left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested:

$ ./dist/tools/buildsystem_sanity_check/check.sh 
Invalid build system patterns found by ./dist/tools/buildsystem_sanity_check/check.sh:
pkg/fatfs/Makefile.dep:ifneq (, $(filter periph_rtc, $(FEATURES_PROVIDED)))
sys/shell/commands/Makefile:ifneq (,$(filter periph_rtc,$(FEATURES_PROVIDED)))

@cladmi
Copy link
Contributor Author

cladmi commented Nov 19, 2018

@jcarrano thanks for ACKing, please just wait for @MrKevinWeiss feedback if he would like some changes now before merging.

@MrKevinWeiss
Copy link
Contributor

I think the output is sufficient. If I am editing a makefile and for some reason add a FEATURES_PROVIDED in the wrong section it specifies where it shouldn't be and what exactly it is. I was more stating that I don't understand the details of how this effects the build system and if there are conditions where the violation is warranted. Either way I think it is good and trust your ability so I too will ACK and go!

@MrKevinWeiss MrKevinWeiss merged commit 58500f9 into RIOT-OS:master Nov 19, 2018
@cladmi
Copy link
Contributor Author

cladmi commented Nov 19, 2018

Thank you for reviewing ! 👍

@cladmi cladmi deleted the pr/dist/tools/build_system/check branch November 19, 2018 14:53
@benpicco
Copy link
Contributor

This also makes something like

ifneq (,$(filter ws281x,$(USEMODULE)))
  ifneq (,$(filter arch_avr8,$(FEATURES_PROVIDED)))
    USEMODULE += ws281x_atmega
  else
    $(error No ws281x backend available for the current platform)
  endif
endif

impossible.
I think this PR predates the 'Arch as FEATURES_PROVIDED' concept, so this might not have been the intention of this.

@aabadie
Copy link
Contributor

aabadie commented Nov 17, 2019

@benpicco, replace FEATURES_PROVIDED by FEATURES_USED and it should work.

@benpicco
Copy link
Contributor

@aabadie that doesn't work - arch_avr8 isn't really used anywhere.

@benpicco
Copy link
Contributor

benpicco commented Nov 17, 2019

Well - there is a solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: build system Area: Build system Area: tests Area: tests and testing framework CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants