-
Notifications
You must be signed in to change notification settings - Fork 10
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
Add contributing guide #139
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
90d7d27
Add contributing guide
chrysn 830b3a5
contributing: Point to Rust style guide
chrysn 21ee7d0
contributing: Mention draft PRs
chrysn ab88723
contributing: Add tl;dr
chrysn 3a37139
README: link to contributing guide
chrysn 4d5eb3c
contributing: remind future editors of the intended audience
chrysn File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
**Contributions are welcome.** | ||
|
||
*tl;dr: Open issues. PR early, PR small. Tests are good. Callback lifetimes are hard.* | ||
|
||
<!-- This text is aimed at people who already decided they want to contribute; let's keep it concise, acknowledging that they probably have some experience in software development. --> | ||
|
||
## Contribution guidelines | ||
|
||
General [RIOT contribution guidelines](https://github.com/RIOT-OS/RIOT/blob/master/CONTRIBUTING.md) apply, | ||
with some | ||
|
||
* focus points: | ||
|
||
* When wrapping a new RIOT feature, **keep it small**. | ||
Attempting to implement all features of a particular RIOT subsystem easily gets caught in long iterations of review. | ||
Try wrapping a minimal viable version first, and let's take it from there. | ||
|
||
chrysn marked this conversation as resolved.
Show resolved
Hide resolved
|
||
* Let's **verify concepts early**. | ||
Opening an issue before larger changes, creating them as draft PRs or discussing it on [our Matrix channel](https://matrix.to/#/#riot-os:matrix.org) | ||
are all convenient ways to do that. | ||
|
||
* New features should come with tests, at least on a coarse granularity. | ||
Tests in [`./tests/`](tests) are automatically picked up by CI. | ||
|
||
* and alterations: | ||
|
||
* RIOT has no coding conventions for Rust; | ||
instead, [common Rust conventions](https://doc.rust-lang.org/stable/style-guide/) apply. | ||
Public items should be documented, | ||
and code should be `cargo fmt` before each commit. | ||
|
||
* Merging criteria are not as strict as in RIOT OS: | ||
RIOT maintainers may merge PRs without a 2nd pair of eyes | ||
(but are encouraged to solicit review on larger changes). | ||
|
||
Before code from this crate gets used by RIOT OS, | ||
it undergoes a secondary review step [similar to PR #20786](https://github.com/RIOT-OS/RIOT/pull/20786), | ||
just like any external package code. | ||
|
||
* The license of this crate is "[MIT](https://spdx.org/licenses/MIT.html) OR [Apache-2.0](https://spdx.org/licenses/Apache-2.0.html)" as stated in [Cargo.toml](Cargo.toml) and the [README](README.md). | ||
This eases interoperability with the rest of the Rust ecosystem; | ||
beware that built binaries include RIOT OS, and thus have LGPL-2.1 components. | ||
|
||
## Common pitfalls | ||
|
||
* Threads and interrupts in RIOT are modelled as is [common](https://onevariable.com/blog/interrupts-is-threads/) in Rust: | ||
Data needs to be [`Send`](https://doc.rust-lang.org/std/marker/trait.Send.html) to be passed around. | ||
Whenever generic data (in particular references) is passed into C functions, | ||
trait bounds need to ensure that it is `Send`. | ||
|
||
* Registering callbacks with RIOT OS typically means | ||
that the OS may invoke the callback at any time. | ||
Thus the callback either must be `'static`, | ||
or it needs to be ensured that the callback is fully unregistered | ||
before its lifetime ends. | ||
|
||
Note that we can not rely on [`Drop`](https://doc.rust-lang.org/std/ops/trait.Drop.html) to be called | ||
(for any user may safely [`forget()`](https://doc.rust-lang.org/std/mem/fn.forget.html) an item at any time). | ||
|
||
Running user code in Rust closures is a common workaround | ||
(eg. [in `thread::scope`](https://doc.riot-os.org/rustdoc/latest/riot_wrappers/thread/fn.scope.html)), | ||
but beware that any items in that scope need to be [branded](http://plv.mpi-sws.org/rustbelt/ghostcell/paper.pdf) (like with the `'id` of the thread scope): | ||
Otherwise, users might create nested scopes and switch around the provided types, | ||
delaying their cleanup from the inner to the outer scope. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
What sorts?
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.
I'd rather not limit peoples' imagination. People will have an idea what they want to do by the time they get to this document, and if someone wants to contribute an introduction poem, I'm happy to review metre.