2020-07-21 20:35:22 +03:00
|
|
|
#!/usr/bin/env sh
|
2023-06-07 16:32:36 +03:00
|
|
|
|
2023-02-19 16:17:49 +03:00
|
|
|
# Copyright 2019-2023 Tauri Programme within The Commons Conservancy
|
2021-04-11 01:09:09 +03:00
|
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
|
|
# SPDX-License-Identifier: MIT
|
|
|
|
|
2020-07-24 17:19:02 +03:00
|
|
|
# note: you can pass in the cargo sub-commands used to check manually.
|
|
|
|
# allowed commands: check, clippy, fmt, test
|
|
|
|
# default: clippy, fmt, test
|
|
|
|
|
|
|
|
# exit the script early if any of the commands return an error
|
2020-07-21 20:35:22 +03:00
|
|
|
set -e
|
|
|
|
|
2020-07-24 17:19:02 +03:00
|
|
|
# set the script arguments if none are found
|
|
|
|
if [ -z "$*" ]; then
|
|
|
|
set -- "clippy" "fmt" "test"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# run n+1 times, where n is the amount of mutually exclusive features.
|
|
|
|
# the extra run is for all the crates without mutually exclusive features.
|
|
|
|
# as many features as possible are enabled at for each command
|
2021-02-10 08:24:38 +03:00
|
|
|
run() {
|
2020-07-24 17:19:02 +03:00
|
|
|
command=$1
|
|
|
|
shift 1
|
2021-02-10 08:24:38 +03:00
|
|
|
cargo "$command" --workspace --all-targets --all-features "$@"
|
2020-07-24 17:19:02 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
for command in "$@"; do
|
|
|
|
case "$command" in
|
|
|
|
check | test)
|
2021-02-10 08:24:38 +03:00
|
|
|
run "$command"
|
2020-07-24 17:19:02 +03:00
|
|
|
;;
|
|
|
|
clippy)
|
2021-02-10 08:24:38 +03:00
|
|
|
run clippy -- -D warnings
|
2020-07-24 17:19:02 +03:00
|
|
|
;;
|
|
|
|
fmt)
|
|
|
|
echo "[$command] checking formatting"
|
2021-04-04 03:41:04 +03:00
|
|
|
cargo +nightly fmt -- --check
|
2020-07-24 17:19:02 +03:00
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "[cargo-check.sh] Unknown cargo sub-command: $command"
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
2020-07-21 20:35:22 +03:00
|
|
|
done
|