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

External component #32

Closed
YOxan opened this issue Nov 8, 2021 · 4 comments · Fixed by #114
Closed

External component #32

YOxan opened this issue Nov 8, 2021 · 4 comments · Fixed by #114
Labels
enhancement New feature or request

Comments

@YOxan
Copy link

YOxan commented Nov 8, 2021

Hey, guys! Thanks for building such a great library! I just have a quick question - is there a way to use external (custom) ESP-IDF component in building this crate? Like importing with some env variable or anything else? For a moment I see that all of framework components and their headers are hardcoded in binding.h for bindgen and without modification of sources I won't be able to integrate smth. Thanks in advance!

@MabezDev
Copy link
Member

MabezDev commented Nov 8, 2021

AFAIK there is no way to do this yet. Perhaps adding an env variable, or something in the Cargo.toml to allow specifying more header files? Instead of hardcoded to binding.h.

An alternative option is to move your custom component into a -sys crate itself, and manage the bindings from your side. esp-idf-sys exports the esp-idf include paths so it should be pretty easy to build the two crates together.

@YOxan
Copy link
Author

YOxan commented Nov 8, 2021

I've tried to go in an other way, just with creating a wrapper around this component based on esp-idf-sys repo. But in that case linker is going crazy and I should add component to both esp-idf repo and created in wrapper crate to fix that. Will try to go with "include paths" as you suggested, but it would be really helpful if sometime esp-idf-sys could support this case.

@N3xed
Copy link
Collaborator

N3xed commented Nov 8, 2021

There is currently no esp-idf-native way to do this, but you can do this with a sys-crate.

We actually propagate all esp-idf gcc include arguments here. They can then be retrieved in all dependent build scripts with:

embuild::build::CInclArgs::try_from_env("ESP_IDF")

With this and the compiler you can use embuild::cmake or the cc crate to compile your C library and embuild::bindgen to generate the Rust bindings.

The compiler path you can get using embuild::espidf::Installer::install(), which will give you the exported PATH (among other things) containing all the tools used (note: see this as an example). From the exported PATH the compiler binary can then be retrieved for example using the which crate.

@YOxan
Copy link
Author

YOxan commented Nov 9, 2021

Awesome! Thanks for assistant, will try that

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants