ESP32-CAN/components/rustlib
Scott Mabin 3ded88a65c Fix esp32c3 build by moving to the new upstream target, riscv32imc-esp-espidf. 2021-08-20 14:21:24 +01:00
..
src Simple inline assembly addition example (#24) 2021-08-17 11:08:22 +02:00
CMakeLists.txt Fix esp32c3 build by moving to the new upstream target, riscv32imc-esp-espidf. 2021-08-20 14:21:24 +01:00
Cargo.toml Create components for Rust and C integration (#10) 2021-06-25 13:57:03 +02:00
README.md Create components for Rust and C integration (#10) 2021-06-25 13:57:03 +02:00
build.rs Fix esp32c3 build by moving to the new upstream target, riscv32imc-esp-espidf. 2021-08-20 14:21:24 +01:00
placeholder.c Create components for Rust and C integration (#10) 2021-06-25 13:57:03 +02:00

README.md

rustlib

This component generates a static library from Rust source code and exposes functions that will be callable from the main IDF application from C.

This component is responsible for three separate functions:

  • Export C bindings for Rust functions with cbindgen.
  • Import Rust binding for C functions with bindgen.
  • Build a top level static library from Rust code. The cargo build command is wrapped in a CMake ExternalProject_Add command.

Currently the build.rs script expects the clib component to export a header with the name CApi.h. If the name of the include file changes or if more files are added, the build script must be updated to process the latest headers.

Depending on the complexity of the project, the cbindgen and bindgen steps could be broken out into one or more IDF components or Rust crates. However, to prevent redundant duplication of the Rust runtime, all Rust crates should be compiled into a single static library that will be linked into the final IDF application.