ensure no_std

This commit is contained in:
stelzo 2024-05-20 16:00:24 +02:00
parent 927fc9a01f
commit 394bd1a9d7
No known key found for this signature in database
GPG Key ID: FC4EF89052319374
7 changed files with 63 additions and 11 deletions

24
.github/workflows/no_std.yml vendored Normal file
View File

@ -0,0 +1,24 @@
name: Tests
on:
push:
branches-ignore:
- rclrs
pull_request:
branches-ignore:
- rclrs
workflow_dispatch:
env:
CARGO_TERM_COLOR: always
jobs:
ubuntu:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: dtolnay/rust-toolchain@stable
with:
target: thumbv7em-none-eabihf
- name: no_std build
run: cargo build --target thumbv7em-none-eabihf --manifest-path rpcl2/ensure_no_std/Cargo.toml

View File

@ -16,15 +16,11 @@ jobs:
ubuntu:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install latest Rust
run: |
curl --proto '=https' --tlsv1.2 https://sh.rustup.rs -sSf | sh -s -- -y
rustc --version
cargo --version
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
components: clippy
- name: Linting
run: cargo clippy --all-targets --features derive,nalgebra,rayon -- -D warnings
- name: Tests
run: cargo test --features derive,nalgebra,rayon
- name: no_std Tests
run: cargo test --no-default-features --features nalgebra

View File

@ -26,6 +26,7 @@ exclude = [
"**/dist/**",
"**/docs/**",
"**/doc/**",
"**/ensure_no_std/**",
]
rust-version = "1.63"

2
rpcl2/ensure_no_std/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
/target
Cargo.lock

View File

@ -0,0 +1,15 @@
[workspace]
[package]
name = "ensure_no_std"
version = "0.1.0"
edition = "2021"
[dependencies]
ros_pointcloud2 = { path = "..", default-features = false, features = ["nalgebra", "derive"] }
[profile.dev]
panic = "abort"
[profile.release]
panic = "abort"

View File

@ -0,0 +1,14 @@
#![no_std]
#![no_main]
use core::panic::PanicInfo;
#[panic_handler]
fn panic(_info: &PanicInfo) -> ! {
loop {}
}
#[no_mangle]
pub extern "C" fn _start() -> ! {
loop {}
}

View File

@ -57,9 +57,9 @@
//! - rosrust_msg — Integration with the [rosrust](https://github.com/adnanademovic/rosrust) library for ROS1 message types.
//! - (rclrs_msg) — Integration for ROS2 [rclrs](https://github.com/ros2-rust/ros2_rust) but it currently needs [this workaround](https://github.com/stelzo/ros_pointcloud2?tab=readme-ov-file#rclrs-ros2_rust).
//! - derive — Offers implementations for the [`PointConvertible`] trait needed for custom points.
//! - rayon — Parallel iterator support for `_par_iter` functions. [`PointCloud2Msg::try_from_par_iter`] additionally needs the 'derive' feature.
//! - rayon — Parallel iterator support for `_par_iter` functions.
//! - nalgebra — Predefined points offer a nalgebra typed getter for coordinates (e.g. [`xyz`](points::PointXYZ::xyz)).
//! - std *(enabled by default)* — Use the standard library. `no_std` only works standalone or with the 'nalgebra' feature.
//! - std *(enabled by default)* — Omit this feature to use this library in no_std environments. ROS integrations and 'rayon' will not work with no_std.
//!
//! # Custom Points
//! Implement [`PointConvertible`] for your point with the `derive` feature or manually.
@ -474,7 +474,7 @@ fn ordered_field_names<const N: usize, C: PointConvertible<N>>() -> Vec<String>
name,
ty: _,
size: _,
} => name.to_string(),
} => name.as_ref().into(),
_ => unreachable!("Fields must be filtered before."),
})
.collect()