From d8d3fbe15a74b4ff6c8d2619f2468ca42bcd8a12 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Sat, 1 Jun 2024 18:59:27 +0200 Subject: [PATCH] final release preparations --- examples/src/lib.rs | 1 + libcsp-cargo-build/release-checklist.md | 22 ++++++++ libcsp-sys/Cargo.toml | 3 ++ libcsp-sys/README.md | 14 +++++ libcsp-sys/build.rs | 12 ++++- libcsp-sys/release-checklist.md | 22 ++++++++ libcsp-sys/src/lib.rs | 71 +++++++++++++------------ libcsp/Cargo.toml | 2 +- libcsp/release-checklist.md | 22 ++++++++ 9 files changed, 132 insertions(+), 37 deletions(-) create mode 100644 examples/src/lib.rs create mode 100644 libcsp-cargo-build/release-checklist.md create mode 100644 libcsp-sys/release-checklist.md create mode 100644 libcsp/release-checklist.md diff --git a/examples/src/lib.rs b/examples/src/lib.rs new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/examples/src/lib.rs @@ -0,0 +1 @@ + diff --git a/libcsp-cargo-build/release-checklist.md b/libcsp-cargo-build/release-checklist.md new file mode 100644 index 0000000..cb23420 --- /dev/null +++ b/libcsp-cargo-build/release-checklist.md @@ -0,0 +1,22 @@ +Checklist for new releases +======= + +# Pre-Release + +1. Make sure any new modules are documented sufficiently enough and check docs with + `cargo +nightly doc --all-features --config 'build.rustdocflags=["--cfg", "docs_rs"]' --open`. +2. Bump version specifier in `Cargo.toml`. +3. Update `CHANGELOG.md`: Convert `unreleased` section into version section with date and add new + `unreleased` section. +4. Run `cargo test --all-features` or `cargo nextest r --all-features`. +5. Run `cargo fmt` and `cargo clippy`. +6. Wait for CI/CD results for EGit and Github. These also check cross-compilation for bare-metal + targets. + +# Release + +1. `cargo publish` + +# Post-Release + +1. Create a new release on `EGit` based on the release branch. diff --git a/libcsp-sys/Cargo.toml b/libcsp-sys/Cargo.toml index 9e3f683..fa75b86 100644 --- a/libcsp-sys/Cargo.toml +++ b/libcsp-sys/Cargo.toml @@ -14,3 +14,6 @@ links = "csp" [dependencies] libc = "0.2" + +[package.metadata.docs.rs] +rustdoc-args = ["--cfg", "docs_rs"] diff --git a/libcsp-sys/README.md b/libcsp-sys/README.md index 5f0d119..c9d4ad2 100644 --- a/libcsp-sys/README.md +++ b/libcsp-sys/README.md @@ -19,3 +19,17 @@ The user has to provide the path to a directory containing this `autoconfig.rs` It is recommended to read the [main workspace README](https://egit.irs.uni-stuttgart.de/rust/libcsp-rust) for more information to make the generation and specification of this auto-configuration file as conveniently and easy as possible. + +## Run unittests + +Running unittests required the `RUN_TESTS` environmental variable to be set to 1. This is because +the actual `libcsp` library might be built and linked in a separate crate, so the linker is not +able to process `-l csp` when running the tests. + +You can use + +```sh +RUN_TESTS=1 cargo test +``` + +to run the unittests. diff --git a/libcsp-sys/build.rs b/libcsp-sys/build.rs index cfe75de..cbec136 100644 --- a/libcsp-sys/build.rs +++ b/libcsp-sys/build.rs @@ -1,9 +1,19 @@ use std::{env, path::PathBuf}; pub const ENV_KEY_CSP_CONFIG_DIR: &str = "CSP_CONFIG_DIR"; +pub const ENV_KEY_TEST: &str = "RUN_TESTS"; fn main() { - println!("cargo:rustc-link-lib=csp"); + // libcsp is built in a separate project, so linking it for tests will fail. + // For tests, we do not want to have the link directive to csp. + let run_tests = if let Ok(val) = env::var(ENV_KEY_TEST) { + val == "1" + } else { + false + }; + if !run_tests { + println!("cargo:rustc-link-lib=csp"); + } let out_path = env::var("OUT_DIR").unwrap(); let csp_conf_dir = match env::var(ENV_KEY_CSP_CONFIG_DIR) { diff --git a/libcsp-sys/release-checklist.md b/libcsp-sys/release-checklist.md new file mode 100644 index 0000000..cb23420 --- /dev/null +++ b/libcsp-sys/release-checklist.md @@ -0,0 +1,22 @@ +Checklist for new releases +======= + +# Pre-Release + +1. Make sure any new modules are documented sufficiently enough and check docs with + `cargo +nightly doc --all-features --config 'build.rustdocflags=["--cfg", "docs_rs"]' --open`. +2. Bump version specifier in `Cargo.toml`. +3. Update `CHANGELOG.md`: Convert `unreleased` section into version section with date and add new + `unreleased` section. +4. Run `cargo test --all-features` or `cargo nextest r --all-features`. +5. Run `cargo fmt` and `cargo clippy`. +6. Wait for CI/CD results for EGit and Github. These also check cross-compilation for bare-metal + targets. + +# Release + +1. `cargo publish` + +# Post-Release + +1. Create a new release on `EGit` based on the release branch. diff --git a/libcsp-sys/src/lib.rs b/libcsp-sys/src/lib.rs index eee5b36..515ad60 100644 --- a/libcsp-sys/src/lib.rs +++ b/libcsp-sys/src/lib.rs @@ -14,6 +14,8 @@ //! [here](https://egit.irs.uni-stuttgart.de/rust/libcsp-rust/src/branch/main/examples/autoconfig.rs). //! The user has to provide the path to a directory containing this `autoconfig.rs` file using the //! `CSP_CONFIG_DIR` environmental variable. +#![no_std] +#![cfg_attr(docs_rs, feature(doc_auto_cfg))] #![allow(non_upper_case_globals)] #![allow(non_camel_case_types)] #![allow(non_snake_case)] @@ -549,8 +551,7 @@ pub mod hooks { #[cfg(test)] mod tests { use super::*; - use core::mem::{align_of, size_of}; - use std::mem::MaybeUninit; + use core::mem::{align_of, size_of, MaybeUninit}; #[test] fn bindgen_test_layout_csp_timestamp_t() { @@ -562,12 +563,12 @@ mod tests { concat!("Size of: ", stringify!(csp_timestamp_t)) ); assert_eq!( - std::mem::align_of::(), + core::mem::align_of::(), 4usize, concat!("Alignment of ", stringify!(csp_timestamp_t)) ); assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).tv_sec) as usize - ptr as usize }, + unsafe { ::core::ptr::addr_of!((*ptr).tv_sec) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -577,7 +578,7 @@ mod tests { ) ); assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).tv_nsec) as usize - ptr as usize }, + unsafe { ::core::ptr::addr_of!((*ptr).tv_nsec) as usize - ptr as usize }, 4usize, concat!( "Offset of field: ", @@ -603,7 +604,7 @@ mod tests { concat!("Alignment of ", stringify!(__packed)) ); assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).pri) as usize - ptr as usize }, + unsafe { ::core::ptr::addr_of!((*ptr).pri) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -613,7 +614,7 @@ mod tests { ) ); assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).flags) as usize - ptr as usize }, + unsafe { core::ptr::addr_of!((*ptr).flags) as usize - ptr as usize }, 1usize, concat!( "Offset of field: ", @@ -623,7 +624,7 @@ mod tests { ) ); assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).src) as usize - ptr as usize }, + unsafe { core::ptr::addr_of!((*ptr).src) as usize - ptr as usize }, 2usize, concat!( "Offset of field: ", @@ -633,7 +634,7 @@ mod tests { ) ); assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).dst) as usize - ptr as usize }, + unsafe { core::ptr::addr_of!((*ptr).dst) as usize - ptr as usize }, 4usize, concat!( "Offset of field: ", @@ -643,7 +644,7 @@ mod tests { ) ); assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).dport) as usize - ptr as usize }, + unsafe { core::ptr::addr_of!((*ptr).dport) as usize - ptr as usize }, 6usize, concat!( "Offset of field: ", @@ -653,7 +654,7 @@ mod tests { ) ); assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).sport) as usize - ptr as usize }, + unsafe { core::ptr::addr_of!((*ptr).sport) as usize - ptr as usize }, 7usize, concat!( "Offset of field: ", @@ -685,7 +686,7 @@ mod tests { ) ); assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).rdp_quarantine) as usize - ptr as usize }, + unsafe { core::ptr::addr_of!((*ptr).rdp_quarantine) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -695,7 +696,7 @@ mod tests { ) ); assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).timestamp_tx) as usize - ptr as usize }, + unsafe { core::ptr::addr_of!((*ptr).timestamp_tx) as usize - ptr as usize }, 4usize, concat!( "Offset of field: ", @@ -705,7 +706,7 @@ mod tests { ) ); assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).timestamp_rx) as usize - ptr as usize }, + unsafe { core::ptr::addr_of!((*ptr).timestamp_rx) as usize - ptr as usize }, 8usize, concat!( "Offset of field: ", @@ -715,7 +716,7 @@ mod tests { ) ); assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).conn) as usize - ptr as usize }, + unsafe { core::ptr::addr_of!((*ptr).conn) as usize - ptr as usize }, 16usize, concat!( "Offset of field: ", @@ -747,7 +748,7 @@ mod tests { ) ); assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).rx_count) as usize - ptr as usize }, + unsafe { core::ptr::addr_of!((*ptr).rx_count) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -757,7 +758,7 @@ mod tests { ) ); assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).remain) as usize - ptr as usize }, + unsafe { core::ptr::addr_of!((*ptr).remain) as usize - ptr as usize }, 2usize, concat!( "Offset of field: ", @@ -767,7 +768,7 @@ mod tests { ) ); assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).cfpid) as usize - ptr as usize }, + unsafe { core::ptr::addr_of!((*ptr).cfpid) as usize - ptr as usize }, 4usize, concat!( "Offset of field: ", @@ -777,7 +778,7 @@ mod tests { ) ); assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).last_used) as usize - ptr as usize }, + unsafe { core::ptr::addr_of!((*ptr).last_used) as usize - ptr as usize }, 8usize, concat!( "Offset of field: ", @@ -787,7 +788,7 @@ mod tests { ) ); assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).frame_begin) as usize - ptr as usize }, + unsafe { core::ptr::addr_of!((*ptr).frame_begin) as usize - ptr as usize }, 16usize, concat!( "Offset of field: ", @@ -797,7 +798,7 @@ mod tests { ) ); assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).frame_length) as usize - ptr as usize }, + unsafe { core::ptr::addr_of!((*ptr).frame_length) as usize - ptr as usize }, 24usize, concat!( "Offset of field: ", @@ -836,7 +837,7 @@ mod tests { concat!("Alignment of ", stringify!(csp_packet_s__bindgen_ty_2)) ); assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).data) as usize - ptr as usize }, + unsafe { core::ptr::addr_of!((*ptr).data) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -846,7 +847,7 @@ mod tests { ) ); assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).data16) as usize - ptr as usize }, + unsafe { core::ptr::addr_of!((*ptr).data16) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -856,7 +857,7 @@ mod tests { ) ); assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).data32) as usize - ptr as usize }, + unsafe { core::ptr::addr_of!((*ptr).data32) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -881,7 +882,7 @@ mod tests { concat!("Alignment of ", stringify!(csp_packet_s)) ); assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).length) as usize - ptr as usize }, + unsafe { core::ptr::addr_of!((*ptr).length) as usize - ptr as usize }, 32usize, concat!( "Offset of field: ", @@ -891,7 +892,7 @@ mod tests { ) ); assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).id) as usize - ptr as usize }, + unsafe { core::ptr::addr_of!((*ptr).id) as usize - ptr as usize }, 34usize, concat!( "Offset of field: ", @@ -901,7 +902,7 @@ mod tests { ) ); assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).next) as usize - ptr as usize }, + unsafe { core::ptr::addr_of!((*ptr).next) as usize - ptr as usize }, 48usize, concat!( "Offset of field: ", @@ -911,7 +912,7 @@ mod tests { ) ); assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).header) as usize - ptr as usize }, + unsafe { core::ptr::addr_of!((*ptr).header) as usize - ptr as usize }, 56usize, concat!( "Offset of field: ", @@ -924,20 +925,20 @@ mod tests { #[test] fn bindgen_test_layout_csp_socket_s() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + const UNINIT: core::mem::MaybeUninit = core::mem::MaybeUninit::uninit(); let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::size_of::(), + core::mem::size_of::(), 152usize, concat!("Size of: ", stringify!(csp_socket_s)) ); assert_eq!( - ::std::mem::align_of::(), + core::mem::align_of::(), 8usize, concat!("Alignment of ", stringify!(csp_socket_s)) ); assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).rx_queue) as usize - ptr as usize }, + unsafe { core::ptr::addr_of!((*ptr).rx_queue) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -947,7 +948,7 @@ mod tests { ) ); assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).rx_queue_static) as usize - ptr as usize }, + unsafe { core::ptr::addr_of!((*ptr).rx_queue_static) as usize - ptr as usize }, 8usize, concat!( "Offset of field: ", @@ -957,7 +958,7 @@ mod tests { ) ); assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).rx_queue_static_data) as usize - ptr as usize }, + unsafe { core::ptr::addr_of!((*ptr).rx_queue_static_data) as usize - ptr as usize }, 16usize, concat!( "Offset of field: ", @@ -967,7 +968,7 @@ mod tests { ) ); assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).opts) as usize - ptr as usize }, + unsafe { core::ptr::addr_of!((*ptr).opts) as usize - ptr as usize }, 144usize, concat!( "Offset of field: ", diff --git a/libcsp/Cargo.toml b/libcsp/Cargo.toml index 6988083..d7a0e72 100644 --- a/libcsp/Cargo.toml +++ b/libcsp/Cargo.toml @@ -15,4 +15,4 @@ categories = ["aerospace", "external-ffi-bindings", "no-std", "hardware-support" bitflags = "2" num_enum = "0.7" libc = "0.2" -libcsp-sys = { path = "../libcsp-sys" } +libcsp-sys = { version = "0.1", path = "../libcsp-sys" } diff --git a/libcsp/release-checklist.md b/libcsp/release-checklist.md new file mode 100644 index 0000000..cb23420 --- /dev/null +++ b/libcsp/release-checklist.md @@ -0,0 +1,22 @@ +Checklist for new releases +======= + +# Pre-Release + +1. Make sure any new modules are documented sufficiently enough and check docs with + `cargo +nightly doc --all-features --config 'build.rustdocflags=["--cfg", "docs_rs"]' --open`. +2. Bump version specifier in `Cargo.toml`. +3. Update `CHANGELOG.md`: Convert `unreleased` section into version section with date and add new + `unreleased` section. +4. Run `cargo test --all-features` or `cargo nextest r --all-features`. +5. Run `cargo fmt` and `cargo clippy`. +6. Wait for CI/CD results for EGit and Github. These also check cross-compilation for bare-metal + targets. + +# Release + +1. `cargo publish` + +# Post-Release + +1. Create a new release on `EGit` based on the release branch.