Skip to content

[RFC] make: introduce driver specific Makefiles for .dep and .include#6923

Closed
smlng wants to merge 2 commits intoRIOT-OS:masterfrom
smlng:make/rfc/driver_deps
Closed

[RFC] make: introduce driver specific Makefiles for .dep and .include#6923
smlng wants to merge 2 commits intoRIOT-OS:masterfrom
smlng:make/rfc/driver_deps

Conversation

@smlng
Copy link
Copy Markdown
Member

@smlng smlng commented Apr 18, 2017

This PR introduces driver specific Makefiles for dependencies and includes, as an example its implemented for drivers/hd44780.

The motivation behind this is to have self-contained driver modules without editing several global Makefiles (like drivers/Makefile.dep and drivers/Makefile.include). Further, this would also make drivers/include obsolete; and, if we could introduce something like RIOTDRV path variable -which allows for multiple dirs like system env variable PATH- this would also make the addition of external driver modules (not in RIOT code base) very simple, as not edits of other files is required anymore.

I'm not a Makefile expert, so this is more proof of concept than best implementation: @kaspar030 and @gebart I rely on your expertise here.

@smlng smlng added Area: drivers Area: Device drivers Area: build system Area: Build system Type: new feature The issue requests / The PR implemements a new feature for RIOT Discussion: RFC The issue/PR is used as a discussion starting point about the item of the issue/PR labels Apr 18, 2017
@aabadie
Copy link
Copy Markdown
Contributor

aabadie commented Apr 18, 2017

I'm not a Makefile expert either but the general idea here sounds very interesting.

@smlng
Copy link
Copy Markdown
Member Author

smlng commented Apr 18, 2017

I think it would be somewhat easier if we would distinguish between drivers modules and other (system/feature) modules. For instance by introducing a DRIVER (and USEDRIVER) similar to packages. Currently this PR uses USEMODULE to search for Makefile.dep/.include, but this will not match for all non-driver modules.

@miri64
Copy link
Copy Markdown
Member

miri64 commented Apr 18, 2017

I'm not a Makefile expert either but the general idea here sounds very interesting.

Yes, would be great, if we could make this possible for any module ;-).

@miri64
Copy link
Copy Markdown
Member

miri64 commented Apr 18, 2017

(not just drivers.)

@smlng smlng mentioned this pull request Jun 14, 2017
@cladmi
Copy link
Copy Markdown
Contributor

cladmi commented Sep 24, 2017

As you are only including files based on USEMODULE, the ifneq (,$(filter hd44780,$(USEMODULE))) protections are not necessary anymore.

@cladmi
Copy link
Copy Markdown
Contributor

cladmi commented Sep 24, 2017

For modules, I think it would require having definitions of MODULE_DIR_module_name = sys/path/to/module somewhere before. I am thinking about adding this for #1242.

@smlng smlng removed this from the Release 2018.01 milestone Jan 15, 2018
@tcschmidt
Copy link
Copy Markdown
Member

@cladmi can you align this to a future-proof build?

@tcschmidt
Copy link
Copy Markdown
Member

@cladmi what to do here: elaborate or close?

Copy link
Copy Markdown
Contributor

@cladmi cladmi left a comment

Choose a reason for hiding this comment

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

I go back on my previous remark of removing the ifneq protections.
With more background on how it is done in other places, they should be kept and ensured to be mandatory (within a static-test).

And all files should be processed all the time, not like packages.

This proposal changes the include directory. It is somehow an other change and could be done before or after alone, but also makes sense to migrate at the same time. It would prevent seeing headers when a module is not used.
However I would want feedback from the drivers maintainers about this.

I would not support any RIOTMODULESTREES right now, there are still issues in the "dependencies" definition order (and even more issues) so would advertise a feature with a lot of side effects. Changing the "definitions" order for lwip modules changes the behavior. There is now EXTERNAL_MODULE_DIRS that allows this too but forces the user to provide the parsing order.

It is in my plans to address it but only after dependencies are resolved in a separate step before parsing board/Makefile.include (#9913).

include $(RIOTBASE)/drivers/Makefile.dep

# pull dependencies from drivers
-include $(USEMODULE:%=$(RIOTBASE)/drivers/%/Makefile.dep)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This should always process all files with a $(sort $(wildcard)).

There are already weird cases with at86rf2xx that implements multiple drivers and would break with a pattern like this.

It looks like there is not reasons to have issues with the processing order with the current definitions.

$(RIOTBASE)/drivers/%/Makefile.include::
$(Q)"$(MAKE)" -C $(RIOTBASE)/drivers/$* Makefile.include

.PHONY: $(USEMODULE:%=$(RIOTBASE)/drivers/%/Makefile.include)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is a remaining mistake from packages that should be removed.
I just did not find an opportunity to remove it without only saying "it's bad".

We should never generate files in the source directory and Makefile.include should be BOARD/build configuration independent so not have any reasons to be generated at compile time.

$(Q)"$(MAKE)" -C $(RIOTBASE)/drivers/$* Makefile.include

.PHONY: $(USEMODULE:%=$(RIOTBASE)/drivers/%/Makefile.include)
-include $(USEMODULE:%=$(RIOTBASE)/drivers/%/Makefile.include)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Same here, using a wildcard.

@@ -0,0 +1,3 @@
ifneq (,$(filter hd44780,$(USEMODULE)))
USEMODULE_INCLUDES += $(RIOTBASE)/drivers/hd44780/include
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This changes the include directory and should get specific feedback from people maintaining this.

If the directory is modified like this, I would also like a static test that the include is in this directory, it would prevent issues when people copy paste or rename in the middle of a PR.

@tcschmidt
Copy link
Copy Markdown
Member

Any progress here or shall we close?

@stale
Copy link
Copy Markdown

stale bot commented Dec 15, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you want me to ignore this issue, please mark it with the "State: don't stale" label. Thank you for your contributions.

@stale stale bot added the State: stale State: The issue / PR has no activity for >185 days label Dec 15, 2019
@stale stale bot closed this Jan 15, 2020
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: drivers Area: Device drivers Discussion: RFC The issue/PR is used as a discussion starting point about the item of the issue/PR State: stale State: The issue / PR has no activity for >185 days Type: new feature The issue requests / The PR implemements a new feature for RIOT

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants