Skip to content

Commit

Permalink
Added 'buildtst.sh' for local CI
Browse files Browse the repository at this point in the history
  • Loading branch information
fpagliughi committed Dec 10, 2024
1 parent 912c343 commit 6e3a12d
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 2 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),

- Upgraded to Rust Edition 2021, MSRV 1.73.0
- New bindings in the -sys crate for _libiio_ v0.24 & v0.25
- Build features to select the version of bindings to match the installed _libiio_, with several options.
- Build features to select the version of bindings to match the installed target _libiio_, with several options.
- Conditional features based on the version of _libiio_.
- Updated examples and utils to use `clap` v3.2, with forward-looking implementation.
- Added _buildtst.sh_ for local CI testing.
- Fixed new clippy warnings.


### [v0.5.2](https://github.com/fpagliughi/rust-industrial-io/compare/v0.5.1..v0.5.2) - 2023-02-03

Expand Down
49 changes: 49 additions & 0 deletions buildtst.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/bin/bash
#
# This tests building the industrial-io crate with various features
# enabled and disabled. This should be run before any pull requests.


# Extract MSRV from Cargo.toml and ensure it's the full version triplet
# The value is stored in the variable `MSRV`
get_crate_msrv() {
MSRV=$(awk '/rust-version/ { print substr($3, 2, length($3)-2) }' Cargo.toml)
local N_DOT
N_DOT=$(echo "${MSRV}" | grep -o "\." | wc -l | xargs)
[[ ${N_DOT} == 1 ]] && MSRV="${MSRV}".0
}

printf "Cleaning the crate...\n"
! cargo clean && exit 1
printf " Ok\n"

printf "\nFormat check...\n"
! cargo +nightly fmt --check && exit 1
printf " Ok\n"

get_crate_msrv
printf "\nUsing MSRV %s\n" "${MSRV}"

FEATURES="utilities,libiio_v0_25 libiio_v0_25 libiio_v0_24 libiio_v0_23 libiio_v0_21 libiio_v0_19"

for VER in ${MSRV} stable ; do
printf "\n\nChecking default features for version: %s...\n" "${VER}"
cargo clean && \
cargo +${VER} check && \
cargo +${VER} test && \
cargo +${VER} clippy && \
cargo +${VER} doc # --all-features
[ "$?" -ne 0 ] && exit 1

for FEATURE in ${FEATURES}; do
printf "\n\nBuilding with feature [%s] for version: %s...\n" "${FEATURE}" "${VER}"
cargo clean && \
cargo +${VER} check --no-default-features --features="$FEATURE" && \
cargo +${VER} test --no-default-features --features="$FEATURE" && \
cargo +${VER} clippy --no-default-features --features="$FEATURE"
[ "$?" -ne 0 ] && exit 1
done
done

cargo clean
printf "\n\n*** All builds succeeded ***\n"
2 changes: 1 addition & 1 deletion src/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ impl Device {
}

/// Gets the label of the device, if any.
#[cfg(any(feature = "libiio_v0_23", feature = "libiio_v0_24"))]
#[cfg(not(any(feature = "libiio_v0_19", feature = "libiio_v0_21")))]
pub fn label(&self) -> Option<String> {
let pstr = unsafe { ffi::iio_device_get_label(self.dev) };
cstring_opt(pstr)
Expand Down

0 comments on commit 6e3a12d

Please sign in to comment.