cargo-check.sh 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #!/usr/bin/env sh
  2. # note: you can pass in the cargo sub-commands used to check manually.
  3. # allowed commands: check, clippy, fmt, test
  4. # default: clippy, fmt, test
  5. # exit the script early if any of the commands return an error
  6. set -e
  7. # set the script arguments if none are found
  8. if [ -z "$*" ]; then
  9. set -- "clippy" "fmt" "test"
  10. fi
  11. # run n+1 times, where n is the amount of mutually exclusive features.
  12. # the extra run is for all the crates without mutually exclusive features.
  13. # as many features as possible are enabled at for each command
  14. mutex() {
  15. command=$1
  16. shift 1
  17. for feature in "no-server" "embedded-server"; do
  18. echo "[$command][$feature] tauri"
  19. cargo "$command" --manifest-path tauri/Cargo.toml --all-targets --features "$feature,cli,all-api" "$@"
  20. done
  21. echo "[$command] other crates"
  22. cargo "$command" --workspace --exclude tauri --all-targets --all-features "$@"
  23. }
  24. for command in "$@"; do
  25. case "$command" in
  26. check | test)
  27. mutex "$command"
  28. ;;
  29. clippy)
  30. mutex clippy -- -D warnings
  31. ;;
  32. fmt)
  33. echo "[$command] checking formatting"
  34. cargo fmt -- --check
  35. ;;
  36. *)
  37. echo "[cargo-check.sh] Unknown cargo sub-command: $command"
  38. exit 1
  39. ;;
  40. esac
  41. done