diff --git a/.github/workflows/no_std.yml b/.github/workflows/no_std.yml new file mode 100644 index 0000000..6bc4d2b --- /dev/null +++ b/.github/workflows/no_std.yml @@ -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 diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 09572fe..b3f3bbb 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -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 diff --git a/rpcl2/Cargo.toml b/rpcl2/Cargo.toml index e85200a..63e3d4b 100644 --- a/rpcl2/Cargo.toml +++ b/rpcl2/Cargo.toml @@ -26,6 +26,7 @@ exclude = [ "**/dist/**", "**/docs/**", "**/doc/**", + "**/ensure_no_std/**", ] rust-version = "1.63" diff --git a/rpcl2/ensure_no_std/.gitignore b/rpcl2/ensure_no_std/.gitignore new file mode 100644 index 0000000..869df07 --- /dev/null +++ b/rpcl2/ensure_no_std/.gitignore @@ -0,0 +1,2 @@ +/target +Cargo.lock \ No newline at end of file diff --git a/rpcl2/ensure_no_std/Cargo.toml b/rpcl2/ensure_no_std/Cargo.toml new file mode 100644 index 0000000..1f416e6 --- /dev/null +++ b/rpcl2/ensure_no_std/Cargo.toml @@ -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" diff --git a/rpcl2/ensure_no_std/src/main.rs b/rpcl2/ensure_no_std/src/main.rs new file mode 100644 index 0000000..0823a5f --- /dev/null +++ b/rpcl2/ensure_no_std/src/main.rs @@ -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 {} +} \ No newline at end of file diff --git a/rpcl2/src/lib.rs b/rpcl2/src/lib.rs index 67e995c..371f4c9 100644 --- a/rpcl2/src/lib.rs +++ b/rpcl2/src/lib.rs @@ -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>() -> Vec name, ty: _, size: _, - } => name.to_string(), + } => name.as_ref().into(), _ => unreachable!("Fields must be filtered before."), }) .collect()