windows-toolchain-download.ps1 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. Set-StrictMode -Version 2.0
  2. $ErrorActionPreference = "Stop"
  3. [Net.ServicePointManager]::SecurityProtocol = "tls12, tls11, tls"
  4. # TODO: fix
  5. $download_dir = (Get-Item "$PSScriptRoot\..\..").FullName
  6. $toolchain_version = $args[0]
  7. $toolchain_target_path = $args[1]
  8. $toolchain_url = "https://update.flipperzero.one/builds/toolchain/gcc-arm-none-eabi-10.3-x86_64-windows-flipper-$toolchain_version.zip"
  9. $toolchain_dist_folder = "gcc-arm-none-eabi-10.3-x86_64-windows-flipper"
  10. $toolchain_zip = "$toolchain_dist_folder-$toolchain_version.zip"
  11. $toolchain_zip_temp_path = "$download_dir\$toolchain_zip"
  12. $toolchain_dist_temp_path = "$download_dir\$toolchain_dist_folder"
  13. if (Test-Path -LiteralPath "$toolchain_target_path") {
  14. Write-Host -NoNewline "Removing old Windows toolchain.."
  15. Remove-Item -LiteralPath "$toolchain_target_path" -Force -Recurse
  16. Write-Host "done!"
  17. }
  18. if (!(Test-Path -Path "$toolchain_zip_temp_path" -PathType Leaf)) {
  19. Write-Host -NoNewline "Downloading Windows toolchain.."
  20. $wc = New-Object net.webclient
  21. $wc.Downloadfile("$toolchain_url", "$toolchain_zip_temp_path")
  22. Write-Host "done!"
  23. }
  24. if (!(Test-Path -LiteralPath "$toolchain_target_path\..")) {
  25. New-Item "$toolchain_target_path\.." -ItemType Directory -Force
  26. }
  27. Write-Host -NoNewline "Extracting Windows toolchain.."
  28. # This is faster than Expand-Archive
  29. Add-Type -Assembly "System.IO.Compression.Filesystem"
  30. [System.IO.Compression.ZipFile]::ExtractToDirectory("$toolchain_zip_temp_path", "$download_dir")
  31. # Expand-Archive -LiteralPath "$toolchain_zip_temp_path" -DestinationPath "$download_dir"
  32. Write-Host -NoNewline "moving.."
  33. Move-Item -LiteralPath "$toolchain_dist_temp_path" -Destination "$toolchain_target_path"
  34. Write-Host "done!"
  35. Write-Host -NoNewline "Cleaning up temporary files.."
  36. Remove-Item -LiteralPath "$toolchain_zip_temp_path" -Force
  37. Write-Host "done!"
  38. # dasdasd