esp-rs / esp-idf-template

A "Hello, world!" template of a Rust binary crate for the ESP-IDF framework.
417 stars 50 forks source link

rust-analyzer components not included #81

Closed wouterdebie closed 1 year ago

wouterdebie commented 1 year ago

Hi,

I'm experiencing the following discrepancy between rust-analyzer builds and regular cargo builds. I've added the esp-camera component by adding a components/ directory in the root of my project with a checked out repo of esp32-camera, added a bindings.h and added the following to my cargo.toml:

[package.metadata.esp-idf-sys]
extra_components = [
    { component_dirs = [ "components" ], bindings_header = "components/bindings.h" }
]

When I run with cargo build, the component is included and I can use functions from it. However, when I use rust-analyzer (through vscode), the component doesn't seem to be included. I end up with a different bindings.rs in my target build directory that doesn't contain any reference to the camera component. The bindings.rs that is generated during the cargo build does contain the camera code.

Any idea why those two builds are different?

ivmarkov commented 1 year ago

I have no idea. :( In theory, rust-analyzer should run the full build, but with that said, I've not used the custom components feature myself. Mr Obvious here, but you did restart VS Code (as in the Rust Analyzer language server) after applying the changes to Cargo.toml (though that should not be necessary, I think)?

wouterdebie commented 1 year ago

I've done some investigation and it seems an issue with the fact that wen using the esp tool chain the component is not included in the bindings. I don't think it has something to do with the template, so I'll check with the esp-idf-sys folks.