You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: documentation/DEVELOPER-GUIDELINES.md
+69Lines changed: 69 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,6 +10,75 @@ This is a living document - make sure to check the latest version of this docume
10
10
In general, the [Rust API Guidelines](https://rust-lang.github.io/api-guidelines) apply to all projects in the ESP-RS GitHub organization where possible.
11
11
- Especially for public API but if possible also for internal APIs.
12
12
13
+
## Working with the repository
14
+
15
+
### rust-analyzer
16
+
17
+
The repository contains multiple crates, with support for multiple different devices. `rust-analyzer` is not able to handle the complete repository at once, so you will need to change configuration depending on what you work on.
18
+
You will need to point `rust-analyzer` to one of the crates you want to work on, using `linkedProjects`. While this option can be used to add multiple crates to the workspace, we often need to enable features
19
+
on them which may only exist in one of the crates (e.g. `esp-radio`'s `wifi` feature). The recommendation is, therefore, to only enable a single crate at a time - ideally one that pulls in other crates as a dependency.
20
+
21
+
Additionally, you will need to specify the target triple of your particular chip, enable the chip's Cargo feature, and select the `esp` toolchain if you are working with an Xtensa MCU.
22
+
23
+
It is also recommended to directly configure `rustfmt` to use the config file in the repository root. This will
24
+
prevent your editor from reformatting code in a way that CI would reject.
25
+
26
+
An example configuration for the Zed editor may look like this:
27
+
28
+
```json
29
+
{
30
+
"lsp": {
31
+
"rust-analyzer": {
32
+
"initialization_options": {
33
+
"rustfmt": {
34
+
// note this needs to be an absolute path
35
+
"extraArgs": ["--config-path=<path to the repository>/rustfmt.toml"]
36
+
},
37
+
// Select esp-rtos, which also pulls in esp-hal
38
+
"linkedProjects": ["./esp-rtos/Cargo.toml"],
39
+
"cargo": {
40
+
// This must match the target MCU's target
41
+
"target": "xtensa-esp32s3-none-elf",
42
+
// Prevents rust-analyzer from blocking cargo
43
+
"targetDir": "target/rust-analyzer",
44
+
"extraEnv": {
45
+
// ESP32-S3 is an Xtensa MCU, we need to work with the esp toolchain
46
+
"RUSTUP_TOOLCHAIN": "esp"
47
+
},
48
+
// Enable device support and a wide set of features on the esp-rtos crate.
If you switch between crates and/or devices often, you may want to keep multiple sets of configurations commented in your config file, or as separate files as templates.
0 commit comments