-
Notifications
You must be signed in to change notification settings - Fork 225
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
Hot take: the way avr-hal uses features is frustrating #602
Comments
On Sun, Nov 17, 2024 at 02:02:09PM -0800, Iris Artin wrote:
Thoughts?
Patches welcome
|
@stappersg I have started this work in #603 That PR only changes the feature-specific My current overall plan is:
After I am done with that we can figure out what the plan is for if/when to fully remove the I am structuring this as a PR stack, of which the PR above is the first. The full PR stack is linked in #603 if you want to peek ahead to where I am going with this and offer early feedback, but you can also ignore it for now if you prefer 🙂 If there is some other structure you'd prefer for this work, let me know. |
On Wed, Nov 20, 2024 at 05:53:21PM -0800, Iris Artin wrote:
@stappersg I have started this work in #603
Yep. Due "Notify all" I saw it already.
Please don't wait for me
and above all: Explore what you want to explore.
Groeten
Geert Stappers
--
Silence is hard to parse
|
Alrighty, I have a coherent plan and will soon be sending along some PRs that put this into place.
|
As I am sure you know, the recommended way to use features is to make them additive, and to avoid mutually exclusive features. However,
avr-hal
relies heavily on non-additive mutually exclusive features. I find this to be a pain.This setup works great as long as you are building a crate that generates one executable for one board. It doesn't work great if you are
avr-hal
, because it forces the library into the same disrecommended mutually-exclusive feature behavior.The core issue — as I see it — is not that
avr-hal
is using features, it's the way it's using them. Specifically,avr-hal
has some symbols whose implementation is selected mutually-exclusively using a feature — for example,Pins
inatmega-hal
. The fact thatatmega-hal
supports multiple MCUs, but can only ever export onePins
symbol, is at the root of the conflict.IMO a better way to manage this would be to use features as they are intended: a feature flag selects whether a piece of functionality is included in the library, but allows multiple features to be selected. For example, I should be able to select both
atmega32u4
andatmega328
features — and if I do, instead of them fighting over who gets to control the globalPins
symbol, I should get bothatmega32u4::Pins
andatmega328::Pins
symbols.Taking this all the way up to the board level, what this would mean is that I would be able to use
arduino-hal.features = ["atmega32u4", "atmega328"]
when importingarduino-hal
— which would indicate that I wantarduino-hal
to include support for both of those MCUs (using features additively, as they were intended) — and then in mymain.rs
I would writeI think this would completely eliminate all the shenanigans with mutually-exclusive features, and simplify the experience for anyone trying to use
avr-hal
in a non-trivial way.Thoughts?
The text was updated successfully, but these errors were encountered: