-
Notifications
You must be signed in to change notification settings - Fork 202
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
Refactor Cargo features #656
Refactor Cargo features #656
Conversation
0beb2ea
to
d8e8c1f
Compare
description = "HAL and Peripheral access API for ATSAMD11, ATSAMD21, ATSAMD51, ATSAME51, ATSAME53 and ATSAME54 microcontrollers" | ||
documentation = "https://docs.rs/crate/atsamd-hal/" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this point to github.io instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My first instinct is no, because the github.io docs are built from master
, which is not on crates.io. But as you said yesterday, we should find a way to make those docs more visible.
I guess the bigger question is which set of docs should new users encounter first? A version tied to a specific crates.io release? Or a version built directly from master
?
))] | ||
compile_error!("The 'usb' feature is enabled, but not a chip with USB support"); | ||
#[cfg(all(feature = "usb", feature = "device", not(feature = "usbp")))] | ||
compile_error!("The 'usb' feature is enabled, but this chip does not support USB"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should have one of these for sdmmc and other stuff too maybe?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, absolutely. I'll see what other instances make sense.
@sajattack had a suggestion on Matrix:
I responded, but I realized that discussion should really stay in the PR, so I'm copying my response here. @sajattack, here was my thought process for feature naming:
Questions for you:
|
I just had a philosophical realization. You say:
Several times recently, both at work and outside of work, people have effectively told me:
While I agree that we should try to make things as intuitive as possible, sometimes things can't be made intuitive, either because the motivation is too complicated & subtle, or because people's intuitions don't match. At some point, I think the solution has to be "Read the documentation". But exactly where that happens is debatable. Where do you think this situation falls? Would adding |
Not really, it seems reasonable enough
Similar to min-samd51g, it conveys that it includes pb00, and everything up to it
Honestly I'm not too fussed about it, it was just an idea that came to me
The -p ones are a little unintuitive as well |
Part of the problem in this instance, is that, in doing a full code review, I see |
Yeah, I'm not a huge fan of it either, but I didn't come up with anything better at the time.
My hesitance comes from the fact that this statement isn't quite accurate. Pins aren't strictly additive. The best example is pin PA28, which I had to make special accommodations for. PA28 is included in the 48 and 64 pin packages for D21 chips, but it's not present in the same packages for D51 chips. While thinking about your responses, I had an idea. What do you think of using a |
Sounds like a good idea.
|
The I'll rename the features and push an update. |
c999aa4
to
1b759d5
Compare
Refactor the Cargo features to provide a better, more fine-grained structure. Separate the features for selecting pins from the features for selecting peripherals. Reorganize and better document the Cargo.toml file.
Add a `has-` prefix to the features for optional pins and peripherals. Remove the `p` suffix to avoid naming collisions, as it is no longer necessary.
The previous update scripts assumed a particular structure of the TOML files. This approach is extremely brittle in the face of formatting or comments. Instead, use the Python package `tomlkit` to parse, modify and dump TOML files while still preserving all formatting and commenting.
6e94fa0
to
d546024
Compare
@sajattack, the scripts I modified were definitely very brittle. They used something that was TOML-aware for reading fields, but they still modified the contents of the file by hand. I'm not quite sure why. My guess is that the Python I guess we'll just see what happens. If we run into errors when trying to release, we can fix things then. |
Summary
NOTE: Reviewers will probably want to read through the entirety of
Cargo.toml
, but the rest of the changes will probably be overwhelming to review. Everything builds, but none of this is tested on hardware, since I don't have any hardware to work with at the moment.Checklist
CHANGELOG.md
for the BSP or HAL updated