Skip to content

Add Rust build system support#356

Merged
rolandreichweinbmw merged 1 commit intoeclipse-openbsw:mainfrom
esrlabs:cr-138280
Feb 6, 2026
Merged

Add Rust build system support#356
rolandreichweinbmw merged 1 commit intoeclipse-openbsw:mainfrom
esrlabs:cr-138280

Conversation

@M-Hassanin
Copy link
Contributor

@M-Hassanin M-Hassanin commented Jan 23, 2026

Add Rust build system support
Enable mixed C++/Rust development.

Build System:

  • Add BUILD_RUST CMake option (opt-in, default OFF)
  • Integrate Corrosion using rim (vendored in libs/3rdparty/corrosion/)
  • Configure cross-compilation for S32K148 (thumbv7em-none-eabihf)
  • Use manual C header for FFI (cbindgen installed for future use)

CMake Presets:

  • posix-rust: POSIX platform with Rust and FreeRTOS support
  • s32k148-rust-gcc: S32K148 with Rust and FreeRTOS support

Example Crate:

  • Add rustHelloWorld example crate demonstrating FFI
  • Use no_std for embedded compatibility
  • Export rust_add() function callable from C++

CI/CD:

  • Update Dockerfile with Rust 1.90.0, cbindgen 0.27.0, and ARM target
  • Add posix-rust and s32k148-rust-gcc to CI build matrix

Documentation:

  • Add Rust setup instructions for POSIX and S32K148 builds
  • Pin Rust version to 1.90.0 for CI compatibility
  • Update NOTICE.md with Corrosion license info

@rolandreichweinbmw
Copy link
Contributor

See discussion, incl. roadmap: #60

/// \param a First number to add
/// \param b Second number to add
/// \return The sum of a and b
uint32_t rust_add(uint32_t a, uint32_t b);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This example shows a C-only interface use case.

For interfacing between C++ and Rust, would it be possible to give a more complex example, e.g. mapping between C++ class and Rust crate interface? Maybe put it on the linked agenda/Rust discussion, but we would need it at some point to support reasonably complex interfaces.

Copy link
Contributor Author

@M-Hassanin M-Hassanin Jan 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point! This initial PR intentionally uses a minimal C-style interface (extern "C") to establish the basic Rust build infrastructure with Corrosion. The upcoming features in the agenda will include more interfaces between C++ and Rust.

Copy link
Contributor

@christian-schilling christian-schilling left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The commit message needs to be adjusted according the the guidelines.

@M-Hassanin M-Hassanin changed the title Add Rust support to OpenBSW build system with the following: Add Rust support to OpenBSW build system. Jan 30, 2026
@rolandreichweinbmw
Copy link
Contributor

Please note that if you changed the PR description, you need to change the commit message also, separately.

@M-Hassanin M-Hassanin changed the title Add Rust support to OpenBSW build system. Add Rust support to OpenBSW build system with the following: Jan 30, 2026
@M-Hassanin
Copy link
Contributor Author

@rolandreichweinbmw @christian-schilling, could you please proceed with resolving your review comments, if there are no other points.

@rolandreichweinbmw
Copy link
Contributor

You still should adjust the commit message, as Christian suggested: It should not mention "OpenBSW". Also "with the following:" can be omitted.

@M-Hassanin M-Hassanin changed the title Add Rust support to OpenBSW build system with the following: Add Rust build system support Feb 2, 2026
Enable mixed C++/Rust development.

Build System:
- Add BUILD_RUST CMake option (opt-in, default OFF)
- Integrate Corrosion using rim (vendored in libs/3rdparty/corrosion/)
- Configure cross-compilation for S32K148 (thumbv7em-none-eabihf)
- Use manual C header for FFI (cbindgen installed for future use)

CMake Presets:
- posix-rust: POSIX platform with Rust and FreeRTOS support
- s32k148-rust-gcc: S32K148 with Rust and FreeRTOS support

Example Crate:
- Add rustHelloWorld example crate demonstrating FFI
- Use no_std for embedded compatibility
- Export rust_add() function callable from C++

CI/CD:
- Update Dockerfile with Rust 1.90.0, cbindgen 0.27.0, and ARM target
- Add posix-rust and s32k148-rust-gcc to CI build matrix

Documentation:
- Add Rust setup instructions for POSIX and S32K148 builds
- Pin Rust version to 1.90.0 for CI compatibility
- Update NOTICE.md with Corrosion license info

Change-Id: I5902e6cbb956ebe4112bdd941d9dd25d8f97721a
@M-Hassanin
Copy link
Contributor Author

@rolandreichweinbmw Done. could you please review again if the commit message satisfies the guidelines?

Copy link
Contributor

@rolandreichweinbmw rolandreichweinbmw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@johannes-esr johannes-esr dismissed christian-schilling’s stale review February 4, 2026 13:23

Commit message updated, approved by Roland

@M-Hassanin
Copy link
Contributor Author

@rolandreichweinbmw, can we merge?

@rolandreichweinbmw rolandreichweinbmw merged commit 403d15f into eclipse-openbsw:main Feb 6, 2026
164 checks passed
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.

3 participants