windows-toolchain-download.ps1 1.5 KB

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