Guest User

Untitled

a guest
Mar 21st, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.26 KB | None | 0 0
  1. # Build in release Mode
  2. param (
  3. [switch]$release=$false,
  4. [switch]$ru=$false,
  5. [switch]$clean=$false,
  6. [switch]$clippy=$false
  7. )
  8.  
  9. $BASH_WORK_DIR="/mnt/c/Users/HeapUnderflow/Documents/Projects/music_bot/dmusic"
  10. $BASH_PATH="/home/byte/.cargo/bin:/home/byte/.pyenv/shims:/home/byte/.pyenv/bin:/home/byte/bin:/usr/local/bin:/usr/bin:/bin:/usr/games:/usr/lib/mit/bin:/usr/lib/mit/sbin"
  11.  
  12. $BCP="cd '$BASH_WORK_DIR' && PATH='$BASH_PATH' "
  13.  
  14. $MODE = @{$true="release";$false="debug"}[$release -eq $true]
  15.  
  16. Write-Host "!Building in $MODE mode" -ForegroundColor Green
  17.  
  18. if ($release) {
  19. Write-Host "!!release mode" -ForegroundColor Green
  20. } else {
  21. Write-Host "!!debug mode" -ForegroundColor Green
  22. }
  23.  
  24. if ($ru) {
  25. Write-Host "!!run" -ForegroundColor Green
  26. } else {
  27. Write-Host "!!no-run" -ForegroundColor Green
  28. }
  29.  
  30. function ReadDiscordToken () {
  31. return Get-Content -Path ".token"
  32. }
  33.  
  34. $DTOKEN = ReadDiscordToken
  35.  
  36. if ($clippy) {
  37. Write-Host "?Linting Clippy..." -ForegroundColor Yellow
  38. Write-Host "?Please wait while we generate your custom help message" -ForegroundColor Yellow
  39. bash -c "$BCP cargo clippy"
  40. if ($LASTEXITCODE -ne 0) {
  41. Write-Error -Message "Cargo exited with $($LASTEXITCODE)" -CategoryReason "Clippy Error" -CategoryTargetName "Cargo" -CategoryTargetType "clippy"
  42. }
  43. break
  44. }
  45.  
  46. if ($clean) {
  47. Write-Host "?Cleaning target" -ForegroundColor Yellow
  48. bash -c "$BCP cargo clean"
  49. if ($LASTEXITCODE -ne 0) {
  50. Write-Error -Message "Cargo exited with $($LASTEXITCODE)" -CategoryReason "Cargo Error" -CategoryTargetName "Cargo" -CategoryTargetType "clean"
  51. }
  52. }
  53.  
  54. Write-Host "?Building target" -ForegroundColor Yellow
  55. bash -c "$BCP cargo build $(@{$true=`"--$MODE`";$false=`"`"}[$release -eq $true])"
  56.  
  57. if ($LASTEXITCODE -ne 0) {
  58. Write-Error -Message "Cargo exited with $($LASTEXITCODE)" -CategoryReason "Cargo Error" -CategoryTargetName "Cargo" -CategoryTargetType "build"
  59. Break
  60. }
  61.  
  62. if ($ru) {
  63. Write-Host "?Running target" -ForegroundColor Yellow
  64. bash -c "$BCP DISCORD_TOKEN='$($DTOKEN)' cargo run $(@{$true=`"--$MODE`";$false=`"`"}[$release -eq $true])"
  65. if ($LASTEXITCODE -ne 0) {
  66. Write-Error -Message "Cargo exited with $($LASTEXITCODE)" -CategoryReason "Cargo Error" -CategoryTargetName "Cargo" -CategoryTargetType "run"
  67. }
  68. }
Add Comment
Please, Sign In to add comment