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

make: add possibility to provide board specific application dependencies in a separate Makefile #12755

Merged
merged 7 commits into from
Dec 9, 2019

Conversation

aabadie
Copy link
Contributor

@aabadie aabadie commented Nov 20, 2019

Contribution description

This PR adds a way for providing complex (for example board related) application dependencies in a separate Makefile.dep in the application directory.

There is a direct consequence on the behaviour of the info-boards-supported target: when the Makefile.dep is provided, the result of this target the same one as the expected one returned by the build system. In short, this PR allows for fixing a weak point of info-boards-supported.

This was the cleanest solution to solve build/ci issues in #12724 and #12304 (in fact these PRs include the commit provided here).

Testing procedure

  • A green Murdock
  • make info-boards-supported is unchanged in the modified test applications.

Issues/PRs references

Required by #12304 and #12724

@aabadie aabadie added Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation 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 Nov 20, 2019
@aabadie aabadie requested review from miri64 and fjmolinas November 20, 2019 14:48
@fjmolinas
Copy link
Contributor

Testing procedure.

git checkout pr-12755 -f; for app in tests/gnrc_sock_dns tests/gnrc_tcp tests/gnrc_rpl_srh tests/gnrc_ipv6_ext_frag tests/gnrc_ipv6_ext; do make --no-print-directory -C ${app} info-boards-supported; done > pr.txt; git checkout upstream/master; for app in tests/gnrc_sock_dns tests/gnrc_tcp tests/gnrc_rpl_srh tests/gnrc_ipv6_ext_frag tests/gnrc_ipv6_ext; do make --no-print-directory -C ${app} info-boards-supported; done > master.txt; diff pr.txt master.txt

NOTE: the only reason why there is no change is because netdev_tap is not a FEATURE and stdio_ethos only require periph_uart which is already supported by all whitelisted boards. So the weak point is not exposed here.

@fjmolinas
Copy link
Contributor

This looks good to me, Its something that had already been mentioned in the past and that I had though of doing as well. @miri64 you had concerns in #12724 regarding your workflow, this does not do it so I assume you are OK with this.

@fjmolinas
Copy link
Contributor

fjmolinas commented Nov 20, 2019

@aabadie maybe add a static check so no

ifeq (native,$(BOARD))
  USEMODULE += ...
  DISABLE_MODULE += ...
  FEATURES_% += ...
  ...
endif

happens in examples/Makefile or tests/Makefile.

@miri64
Copy link
Member

miri64 commented Nov 20, 2019

Why does moving them to a separate Makefile make make info-boards-supported possible with keeping native the default board while it doesn't work when it is in the main Makefile? What difference does it make if I say USEMODULE for a certain board in the Makefile of the application directly vs. collecting it in the dependency collection phase (except for making it more complicated)? This should work without any of these special handlings. Or am I not understanding our build system at all... :-/?

@miri64
Copy link
Member

miri64 commented Nov 20, 2019

Don't get me wrong, I really appreciate that you guys try to get rid of BOARD_BLACKLIST, but don't forget the main goal here: this should make it easier for the user. At the moment this more looks like another heap of patchwork to me.

@kaspar030
Copy link
Contributor

Why does moving them to a separate Makefile make make info-boards-supported possible with keeping native the default board while it doesn't work when it is in the main Makefile? What difference does it make if I say USEMODULE for a certain board in the Makefile of the application directly vs. collecting it in the dependency collection phase (except for making it more complicated)?

The "info-boards-supported" machinery is executed after the application makefile. Thus any logic within the application logic has been applied. That includes any conditionals based on the (default) board.

E.g., if the application makefile has BOARD ?= native; if BOARD==native: FEATURES_REQUIRED+=foobar, foobar is required for all boards from the perspective of info-boards-supported, as FEATURES_REQUIRED+=foobar has been evaluated before including the corresponding makefiles/info-global.inc.mk. (that is btw the file I use in presentations about why make sucks for logic 😉).

@miri64
Copy link
Member

miri64 commented Nov 20, 2019

The "info-boards-supported" machinery is executed after the application makefile. Thus any logic within the application logic has been applied. That includes any conditionals based on the (default) board.

E.g., if the application makefile has BOARD ?= native; if BOARD==native: FEATURES_REQUIRED+=foobar, foobar is required for all boards from the perspective of info-boards-supported, as FEATURES_REQUIRED+=foobar has been evaluated before including the corresponding makefiles/info-global.inc.mk. (that is btw the file I use in presentations about why make sucks for logic wink).

And how does adding this to a separate Makefile.dep change that? info-boards-supported would still be executed after the dependencies are resolved, right?

@kaspar030
Copy link
Contributor

And how does adding this to a separate Makefile.dep change that? info-boards-supported would still be executed after the dependencies are resolved, right?

No, the separate Makefile.dep is be included from the main Makefile.dep, which is in turn evaluated from info-boards-supported, which sets the correct BOARD value in each iteration.

@miri64
Copy link
Member

miri64 commented Nov 20, 2019

I think I slowly start to understand...

@miri64
Copy link
Member

miri64 commented Nov 20, 2019

Ok, I'm fine with the changes, but don't have the time to test this right now. There should however be some doc somewhere, clarifying when a Makefile.dep for the application is needed and when not. I can imagine a newcomer reading tests/gnrc_ipv6_ext (because I want to write support for a new extension header e.g.) would get the impression that Makefile.dep is where the modules are defined in. However, this isn't always the case so this needs to be explained properly somewhere.

@kaspar030
Copy link
Contributor

There should however be some doc somewhere, clarifying when a Makefile.dep for the application is needed and when not.

+1. IMO, rule of thumb should be, only use Makefile.dep for the necessary rules.

@miri64
Copy link
Member

miri64 commented Nov 20, 2019

+1. IMO, rule of thumb should be, only use Makefile.dep for the necessary rules.

Yepp, but it is very important to state what those "necessary rules" are ;-)

@aabadie aabadie force-pushed the pr/application_dep branch from 6082949 to 894b506 Compare December 6, 2019 15:14
@aabadie
Copy link
Contributor Author

aabadie commented Dec 6, 2019

rule of thumb should be, only use Makefile.dep for the necessary rules.

Ok, I think that this PR is now following this rule. In each application Makefile.dep, I added a comment that explain what should be added there.

@aabadie
Copy link
Contributor Author

aabadie commented Dec 6, 2019

Let me know if/when I can squash ;)

@miri64
Copy link
Member

miri64 commented Dec 6, 2019

Still don't have any confirmation what those "necassary rules" are. Also, as there is a clear distinction between the Makefile.dep we use elsewhere (all dependencies in this scope) and those application Makefile.dep (only special dependencies in this scope), I think we should use different name, to avoid confusion (not sure what, as I don't know chat the rules for that files are).

@miri64
Copy link
Member

miri64 commented Dec 6, 2019

[…] (not sure what, as I don't know chat the rules for that files are).

Maybe Makefile.board_dep (if this goes into the direction I think it is going).

@aabadie aabadie force-pushed the pr/application_dep branch from e29aecd to 526d2d1 Compare December 6, 2019 16:17
@aabadie
Copy link
Contributor Author

aabadie commented Dec 6, 2019

what those "necassary rules" are

As I understood @kaspar030,'s comment, these are only the rules that are board specific and defined in the application Makefile.
Remember that Makefile.dep in the application directory is only there to ensure board dependent dependencies defined at application level are also taken into account by the info-board-supported target (because the $(APPDIR)/Makefile.dep is parsed).
In the current state (e.g. in master), the application Makefile is not parsed by the info-board-supported target: any board specific dependency that has hardware requirements (for example ethos here) is not evaluated.
The new Makefile.dep is not different than other Makefile.dep, it's just filling a hole to make info-board-supported target consistent with the "normal" dependency resolution mechanism.

@miri64
Copy link
Member

miri64 commented Dec 6, 2019

The new Makefile.dep is not different than other Makefile.dep, it's just filling a hole to make info-board-supported target consistent with the "normal" dependency resolution mechanism.

If that were true, all USEMODULE of an application should go there. But you just made clear, that this isn't the case. And I'm also sure that we don't want that.

@aabadie
Copy link
Contributor Author

aabadie commented Dec 6, 2019

But you just made clear, that this isn't the case

It seems to me that you are misunderstanding how make info-board-supported works. You should have a look at the code, that would help.

Of course, the application Makefile is parsed, so all USEMODULE, FEATURES_REQUIRED are parsed but not the ones that are dependent on a board (e.g. inside an ifeq ($(BOARD), <board>) block) that is not the default board.

We need to handle that board specific logic in a an extra file that is parsed by the normal build and by info-board-supported.

@miri64
Copy link
Member

miri64 commented Dec 6, 2019

But you just made clear, that this isn't the case

It seems to me that you are misunderstanding how make info-board-supported works. You should have a look at the code, that would help.

Of course, the application Makefile is parsed, so all USEMODULE, FEATURES_REQUIRED are parsed but not the ones that are dependent on a board (e.g. inside an ifeq ($(BOARD), <board>) block) that is not the default board.

We need to handle that board specific logic in a an extra file that is parsed by the normal build and by info-board-supported.

I think there is a misunderstanding, yes, but not about functional things. I'm arguing that the name Makefile.dep is misleading, as it could imply to a user, that all dependencies of an application are supposed to be in that file. Which isn't the case, as there are also USEMODULE and USEPKG assignments in the main Makefile. So my argument is completely non-functional.

@miri64
Copy link
Member

miri64 commented Dec 6, 2019

(and my point is: we should rename Makefile.dep to something else, as they are obviously more special [from a purely non-functional view] as normal Makefile.dep files)

Makefile.dep Outdated Show resolved Hide resolved
@aabadie aabadie force-pushed the pr/application_dep branch from 526d2d1 to b184007 Compare December 6, 2019 17:40
@aabadie aabadie changed the title make: add possibility to provide application dependencies in a separate Makefile make: add possibility to provide board specific application dependencies in a separate Makefile Dec 6, 2019
@aabadie
Copy link
Contributor Author

aabadie commented Dec 6, 2019

@miri64, ok to squash ?

@miri64
Copy link
Member

miri64 commented Dec 6, 2019

For my part, yes.

@aabadie aabadie force-pushed the pr/application_dep branch from 0a0678d to f6e0756 Compare December 6, 2019 20:02
@aabadie
Copy link
Contributor Author

aabadie commented Dec 6, 2019

For my part, yes.

Thanks, then I squashed.

@aabadie aabadie force-pushed the pr/application_dep branch from f6e0756 to 75751e5 Compare December 6, 2019 20:07
@aabadie aabadie force-pushed the pr/application_dep branch from 75751e5 to 6d5f64b Compare December 6, 2019 20:21
@aabadie
Copy link
Contributor Author

aabadie commented Dec 7, 2019

This PR could also be considered as an improvement for #9913

Copy link
Contributor

@fjmolinas fjmolinas left a comment

Choose a reason for hiding this comment

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

No changes in dependencies. ACK!

git checkout pr-12755 -f; for app in tests/gnrc_sock_dns tests/gnrc_tcp tests/gnrc_rpl_srh tests/gnrc_ipv6_ext_frag tests/gnrc_ipv6_ext; do make --no-print-directory -C ${app} info-boards-supported; done > pr.txt; git checkout upstream/master; for app in tests/gnrc_sock_dns tests/gnrc_tcp tests/gnrc_rpl_srh tests/gnrc_ipv6_ext_frag tests/gnrc_ipv6_ext; do make --no-print-directory -C ${app} info-boards-supported; done > master.txt; diff pr.txt master.txt
#no diff

@fjmolinas
Copy link
Contributor

GO!

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 Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants