cargo-check.ps1 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #!/usr/bin/env pwsh
  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. # set the script arguments if none are found
  6. if(-Not $args) {
  7. $args=@("clippy","fmt","test")
  8. }
  9. # exit the script early if the last command returned an error
  10. function check_error {
  11. if($LASTEXITCODE -ne 0 ) {
  12. Exit $LASTEXITCODE
  13. }
  14. }
  15. # run n+1 times, where n is the amount of mutually exclusive features.
  16. # the extra run is for all the crates without mutually exclusive features.
  17. # as many features as possible are enabled at for each command
  18. function mutex {
  19. $command, $_args = $args
  20. foreach ($feature in @("no-server","embedded-server")) {
  21. Write-Output "[$command][$feature] tauri"
  22. cargo $command --manifest-path tauri/Cargo.toml --all-targets --features "$feature,cli,all-api" $_args
  23. check_error
  24. }
  25. Write-Output "[$command] other crates"
  26. cargo $command --workspace --exclude tauri --all-targets --all-features $_args
  27. check_error
  28. }
  29. foreach ($command in $args) {
  30. Switch ($command) {
  31. "check" {
  32. mutex check
  33. break
  34. }
  35. "test" {
  36. mutex test
  37. break
  38. }
  39. "clippy" {
  40. mutex clippy "--" -D warnings
  41. break
  42. }
  43. "fmt" {
  44. Write-Output "[$command] checking formatting"
  45. cargo fmt "--" --check
  46. check_error
  47. }
  48. default {
  49. Write-Output "[cargo-check.ps1] Unknown cargo sub-command: $command"
  50. Exit 1
  51. }
  52. }
  53. }