Skip to content

refactor: only include OpenThread-relevant bindings#63

Merged
ivmarkov merged 3 commits intoesp-rs:mainfrom
inomotech-foss:feat/reduce-bindings
Feb 26, 2026
Merged

refactor: only include OpenThread-relevant bindings#63
ivmarkov merged 3 commits intoesp-rs:mainfrom
inomotech-foss:feat/reduce-bindings

Conversation

@scootermon
Copy link
Copy Markdown
Contributor

@scootermon scootermon commented Feb 25, 2026

Compared to a lot of other C libraries, OpenThread's headers are very sanitised. They only rely on OpenThread types or on C primitives.
This allows us to specifically only generate bindings for their items, which makes the sys crate much nicer to use.

In fact, the only difference between the different binding files is now "short-enum" vs "normal" enum representation. Even if we add more platforms I expect those will remain the only difference, allowing us to stick with only two pre-generated files.

This is something I would like to look at in a future PR but next up is the mbedtls unification :)

NOTE: I "tested" these changes by compiling the openthread crate for the 4 supported targets. All 4 of them compile without issue.

Instead of blocklisting some specific items, let's just only include
any items that start with "ot" or "OT_". This removes a lot of noise
from the bindings and also makes them more portable.

The only difference between the riscv* and the thumb* bindings is now
the different enum representation, so technically we now only need two
sets of bindings instead of four.
@ivmarkov
Copy link
Copy Markdown
Collaborator

@scootermon Well, I don't care that much because the bindings are anyway under the openthread_sys namespace.

But if you feel that's important, I don't mind merging that as long as you include in the PR all .a lib artefacts. I do realize they should be unchanged (only the bindgen artefacts are affected by this change) - yet - for completeness let's have them too.

The new libraries are now compiled using clang and the new sysroot.
@ivmarkov ivmarkov merged commit 6ba22d9 into esp-rs:main Feb 26, 2026
1 check passed
@scootermon scootermon deleted the feat/reduce-bindings branch February 26, 2026 09:32
@scootermon
Copy link
Copy Markdown
Contributor Author

Well, I don't care that much because the bindings are anyway under the openthread_sys namespace.

Fair enough. It's mainly a personal pet peeve of mine that -sys crate often don't get the love they deserve :P

@ivmarkov
Copy link
Copy Markdown
Collaborator

Well, I don't care that much because the bindings are anyway under the openthread_sys namespace.

Fair enough. It's mainly a personal pet peeve of mine that -sys crate often don't get the love they deserve :P

Hm. Then you can send some love to the mbedtls-rs-sys crate too, where it seems everything is prefixed with mbedtls_? Ah wait, not sure about the PSA stuff, but maybe also having a good prefix? :P

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants