2023-01-12 20:38:08 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
set -ex
|
|
|
|
|
|
|
|
FEATURES="std alloc"
|
|
|
|
|
|
|
|
cargo --version
|
|
|
|
rustc --version
|
|
|
|
|
|
|
|
# Work out if we are using a nightly toolchain.
|
|
|
|
NIGHTLY=false
|
|
|
|
if cargo --version | grep nightly >/dev/null; then
|
|
|
|
NIGHTLY=true
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Make all cargo invocations verbose
|
|
|
|
export CARGO_TERM_VERBOSE=true
|
|
|
|
|
|
|
|
# Defaults / sanity checks
|
2022-09-14 11:09:57 +00:00
|
|
|
cargo --locked build
|
|
|
|
cargo --locked test
|
2023-01-12 20:38:08 +00:00
|
|
|
|
|
|
|
if [ "$DO_LINT" = true ]
|
|
|
|
then
|
2022-09-14 11:09:57 +00:00
|
|
|
cargo clippy --locked --all-features --all-targets -- -D warnings
|
2023-01-12 20:38:08 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$DO_FEATURE_MATRIX" = true ]; then
|
|
|
|
# No features
|
2022-09-14 11:09:57 +00:00
|
|
|
cargo build --locked --no-default-features
|
|
|
|
cargo test --locked --no-default-features
|
2023-01-12 20:38:08 +00:00
|
|
|
|
|
|
|
# All features
|
2022-09-14 11:09:57 +00:00
|
|
|
cargo build --locked --no-default-features --features="$FEATURES"
|
|
|
|
cargo test --locked --no-default-features --features="$FEATURES"
|
2023-01-12 20:38:08 +00:00
|
|
|
|
|
|
|
# Single features
|
|
|
|
for feature in ${FEATURES}
|
|
|
|
do
|
2022-09-14 11:09:57 +00:00
|
|
|
cargo build --locked --no-default-features --features="$feature"
|
|
|
|
cargo test --locked --no-default-features --features="$feature"
|
2023-01-12 20:38:08 +00:00
|
|
|
done
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Build the docs if told to (this only works with the nightly toolchain)
|
|
|
|
if [ "$DO_DOCSRS" = true ]; then
|
|
|
|
RUSTDOCFLAGS="--cfg docsrs -D warnings -D rustdoc::broken-intra-doc-links" cargo +nightly doc --all-features
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Build the docs with a stable toolchain, in unison with the DO_DOCSRS command
|
|
|
|
# above this checks that we feature guarded docs imports correctly.
|
|
|
|
if [ "$DO_DOCS" = true ]; then
|
2022-09-14 11:09:57 +00:00
|
|
|
RUSTDOCFLAGS="-D warnings" cargo +stable doc --locked --all-features
|
2023-01-12 20:38:08 +00:00
|
|
|
fi
|
2022-09-30 01:56:12 +00:00
|
|
|
|
|
|
|
# Run formatter if told to.
|
|
|
|
if [ "$DO_FMT" = true ]; then
|
|
|
|
if [ "$NIGHTLY" = false ]; then
|
|
|
|
echo "DO_FMT requires a nightly toolchain (consider using RUSTUP_TOOLCHAIN)"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
rustup component add rustfmt
|
|
|
|
cargo fmt --check
|
|
|
|
fi
|