I successfully compiled & linked Rust code against the Arduino framework compiled by pio (yay!). I did this in a very “hacky” way - at least that’s what it feels like - with a build middleware that hooks the main.cpp compilation (which is almost empty) and compiles with cargo instead.
My question is, what is the “correct” way to do this? I want to sit on top of any framework or platform that pio has by default - I don’t care if it’s mbed on an nrf52 or Arduino on an ESP32. I want the underlying framework to compile and then I generate bindings on the fly (bindgen) and give the appropriate RUSTFLAGS to cargo for the linking process - Rust supports almost all of the targets that pio supports (apart from the AVR).
Keep in mind that Rust is not a framework on its own - at least not the way I use it (I want to blink a light with digitalWrite
).
Also keep in mind (if it changes anything) that my target(s) are not .rs
files but the whole project directory (that’s how cargo works - it’s like make, rustc on the other side is like gcc. Using the internal SCons instead of cargo currently sounds to me like a terrible idea and a TON of work)
Current progress: GitHub - dzervas/platformio-arduino-rust: Arduino Framework bindings for Rust using PlatformIO - pio run
does produce an ELF yet - getting there though