esp-rs / esp-idf-template

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

missing cfg flags with cmake build #79

Closed simonchatts closed 1 year ago

simonchatts commented 1 year ago

Thanks for all your work on esp-rs!

esp-idf-svc has a bunch of cfg flags, eg esp_idf_comp_esp_netif_enabled, that normally get set by some automatic process I don't understand.

This doesn't work with cmake projects from this template. If you:

then you get this error:

error[E0432]: unresolved import `esp_idf_svc::netif`
 --> src/lib.rs:2:5
  |
2 | use esp_idf_svc::netif;
  |     ^^^^^^^^^^^^^^^^^^ no `netif` in the root

If you brute-force it, by adding set(ESP_RUSTFLAGS "--cfg esp_idf_comp_esp_netif_enabled") to components/rust-test/CMakeLists.txt, then this shifts the error onto other missing flags (such as esp_idf_comp_esp_event_enabled).

Any ideas?

ivmarkov commented 1 year ago

esp_idf_comp_* flags get auto-defined by the build system when you enable the corresponding ESP IDF component as part of the CMake build.

simonchatts commented 1 year ago

Aha! Thank you!