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

Split nb and can traits to separate crates. #394

Merged
merged 8 commits into from
Sep 26, 2022

Conversation

Dirbaio
Copy link
Member

@Dirbaio Dirbaio commented Jul 26, 2022

Following up from #177 (comment), this PR splits nb and can traits to separate crates.

I propose keeping these crates (and embedded-hal-async) separate forever. (instead of merging EHA into EH when stable as we originally planned when we created EHA).

Reasons for splitting nb:

  • its future is unclear. Some people who would like to see nb deprecated. By splitting, if we do deprecate it, we won't get stuck with it in the main embedded-hal crate forever.
  • It makes the module paths in the main crate cleaner.
  • Traits tied to a particular "execution model" in their own crates, which make the overall structure easier to understand IMO.

Reasons for splitting can:

TODO:

  • Name it embedded-can, not embedded-hal-can.
  • Move/remove docs/examples from the main crate that mention nb.
  • Mention the subcrates from the main crate's docs.
  • Add CI
  • move embedded-hal to a subdir as well
  • What should the nb, can crate versions be? 1.0? (no opinion on this from me).
    • can: 0.4
    • nb: 1.0

@rust-highfive
Copy link

r? @ryankurte

(rust-highfive has picked a reviewer for you, use r? to override)

@Dirbaio Dirbaio changed the title Split nb and can traits to separate crates. WIP: Split nb and can traits to separate crates. Jul 26, 2022
@burrbull
Copy link
Member

Could you add links to -async and -nb crates in embedded-hal README.md ?

@adamgreig
Copy link
Member

We discussed this a bunch at today's meeting (logs starting here), a few key points:

  • Lots of support for splitting nb traits into embedded-hal-nb (and therefore keeping embedded-hal-async separate for good)
  • For CAN, it seems like it might make most sense to use a new repository and publish to the old embedded-can crate rather than an embedded-hal-can; in general this approach seems favourable for more complicated protocols/peripherals/concepts like CAN, USB, DMA, etc (see also embedded-dma, embedded-i2s, etc). This way the CAN traits can change/have breaking releases/develop without impacting the embedded-hal crate versioning, without being much more work for HAL/driver/end users to actually use.

@Dirbaio Dirbaio added this to the v1.0.0 milestone Aug 2, 2022
@ryankurte
Copy link
Contributor

outcomes from #394 (comment) sound good to me!

(looking forward to daylight savings here in a couple of months so the meetings are a paletable 08:00 instead of 06:00 here 🤣)

@eldruin eldruin mentioned this pull request Aug 17, 2022
@adamgreig
Copy link
Member

Discussed in today's meeting: Let's go with putting the CAN traits into an embedded-can folder in this repository, and then we can publish a new version of embedded-can with the latest traits from embedded-hal 0.2.

@Dirbaio Dirbaio force-pushed the split-nb-can branch 5 times, most recently from d4b3c7b to f1c4356 Compare September 6, 2022 20:10
@Dirbaio
Copy link
Member Author

Dirbaio commented Sep 6, 2022

bors try

bors bot added a commit that referenced this pull request Sep 6, 2022
@Dirbaio Dirbaio marked this pull request as ready for review September 6, 2022 21:21
@Dirbaio Dirbaio requested a review from a team as a code owner September 6, 2022 21:21
@Dirbaio
Copy link
Member Author

Dirbaio commented Sep 6, 2022

This should be now ready to go :)
ping @rust-embedded/hal

The changelog checker is angry because I moved CHANGELOG.md to the subdir. How do we do this? Ideally the checker would require updating changelog for crate X only if you've touched files from subdir X, but it doesn't seem that's supported...

@Dirbaio Dirbaio changed the title WIP: Split nb and can traits to separate crates. Split nb and can traits to separate crates. Sep 6, 2022
Copy link
Member

@eldruin eldruin left a comment

Choose a reason for hiding this comment

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

Thanks! I added a few comments.
If you do not find any alternative, we can remove the changelog check since it does not seem to work with workspace repos.
Note that this includes removing the blocking modules from embedded-hal::X and puts all the traits there.
This is in line with only supporting one execution model but should be noted as such.
Please add a changelog entry to the e-h crate about it.

embedded-can/Cargo.toml Outdated Show resolved Hide resolved
embedded-can/README.md Outdated Show resolved Hide resolved
embedded-hal-async/README.md Outdated Show resolved Hide resolved
embedded-hal-bus/src/spi.rs Show resolved Hide resolved
embedded-hal-nb/README.md Show resolved Hide resolved
embedded-hal-nb/src/serial.rs Show resolved Hide resolved
@Dirbaio Dirbaio force-pushed the split-nb-can branch 2 times, most recently from 13aa203 to 3aacca7 Compare September 13, 2022 17:39
embedded-can/Cargo.toml Outdated Show resolved Hide resolved
Copy link
Member

@eldruin eldruin left a comment

Choose a reason for hiding this comment

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

After a rebase this should be good to go.
In the future let's please avoid such huge patchsets.
It just makes reviewing much more time-intensive and adds delay.
There are several easier-to-review PRs hiding inside this one.

embedded-hal-async/src/digital.rs Outdated Show resolved Hide resolved
@Dirbaio Dirbaio force-pushed the split-nb-can branch 2 times, most recently from da6d127 to 66f5909 Compare September 26, 2022 11:18
@Dirbaio Dirbaio mentioned this pull request Sep 26, 2022
@Dirbaio
Copy link
Member Author

Dirbaio commented Sep 26, 2022

Rebased, and split off the clippy stuff to a separate PR (#406)

eldruin
eldruin previously approved these changes Sep 26, 2022
Copy link
Member

@eldruin eldruin left a comment

Choose a reason for hiding this comment

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

Thanks!
bors r+

bors bot added a commit that referenced this pull request Sep 26, 2022
394: Split nb and can traits to separate crates. r=eldruin a=Dirbaio

Following up from #177 (comment), this PR splits `nb` and `can` traits to separate crates.

I propose keeping these crates (and `embedded-hal-async`) separate forever. (instead of merging EHA into EH when stable as we originally planned when we created EHA).

Reasons for splitting `nb`:
- its future is unclear. Some people who would like to see `nb` deprecated. By splitting, if we do deprecate it, we won't get stuck with it in the main `embedded-hal` crate forever.
- It makes the module paths in the main crate cleaner.
- Traits tied to a particular "execution model" in their own crates, which make the overall structure easier to understand IMO.

Reasons for splitting `can`:
- It has some open concerns: #381 #387 
- Even if we do solve these, it's nice to have separate crates for the "more specialized" traits so that they can be major-bumped in the future if more concerns arise, without having to major-bump the main `embedded-hal` crate.

TODO:

- [x] Name it `embedded-can`, not `embedded-hal-can`.
- [x] Move/remove docs/examples from the main crate that mention `nb`.
- [x] Mention the subcrates from the main crate's docs.
- [x] Add CI
- [x] move `embedded-hal` to a subdir as well
- [x] What should the nb, can crate versions be? 1.0? (no opinion on this from me).
   - [x] can: 0.4
   - [x] nb: 1.0

Co-authored-by: Dario Nieuwenhuis <dirbaio@dirbaio.net>
@bors
Copy link
Contributor

bors bot commented Sep 26, 2022

Build failed:

.github/bors.toml Outdated Show resolved Hide resolved
@eldruin
Copy link
Member

eldruin commented Sep 26, 2022

bors retry

@bors
Copy link
Contributor

bors bot commented Sep 26, 2022

👎 Rejected by too few approved reviews

Copy link
Member

@eldruin eldruin left a comment

Choose a reason for hiding this comment

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

bors r+

@bors bors bot merged commit 416aa2b into rust-embedded:master Sep 26, 2022
bors bot added a commit that referenced this pull request Sep 28, 2022
406: Enforce clippy in CI r=therealprof a=Dirbaio

Depends on #394

CI wasn't actually enforcing clippy, because `actions-rs/clippy-check` needs to run as `pull_request_target` to get the token to add the "fancy" comments to the diff. It does nothing when ran as `pull_request`.

`pull_request_target` is troublesome because it uses the yaml from `master` instead of from the PR branch, which means when bumping clippy you don't know whether CI passes until *after* it's merged. I've made it use `cargo clippy` instead, which works on `pull_request`.

Co-authored-by: Dario Nieuwenhuis <dirbaio@dirbaio.net>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants