2022-07-14 16:24:26 +00:00
|
|
|
Set-StrictMode -Version 2.0
|
|
|
|
$ErrorActionPreference = "Stop"
|
|
|
|
[Net.ServicePointManager]::SecurityProtocol = "tls12, tls11, tls"
|
2023-08-22 17:56:27 +00:00
|
|
|
# TODO FL-3536: fix path to download_dir
|
2022-11-02 15:15:40 +00:00
|
|
|
$download_dir = (Get-Item "$PSScriptRoot\..\..").FullName
|
2022-07-14 16:24:26 +00:00
|
|
|
$toolchain_version = $args[0]
|
2022-11-02 15:15:40 +00:00
|
|
|
$toolchain_target_path = $args[1]
|
|
|
|
|
2022-10-25 22:15:02 +00:00
|
|
|
$toolchain_url = "https://update.flipperzero.one/builds/toolchain/gcc-arm-none-eabi-10.3-x86_64-windows-flipper-$toolchain_version.zip"
|
2022-11-02 15:15:40 +00:00
|
|
|
$toolchain_dist_folder = "gcc-arm-none-eabi-10.3-x86_64-windows-flipper"
|
|
|
|
$toolchain_zip = "$toolchain_dist_folder-$toolchain_version.zip"
|
|
|
|
|
|
|
|
$toolchain_zip_temp_path = "$download_dir\$toolchain_zip"
|
|
|
|
$toolchain_dist_temp_path = "$download_dir\$toolchain_dist_folder"
|
2022-07-14 16:24:26 +00:00
|
|
|
|
2022-11-02 15:15:40 +00:00
|
|
|
if (Test-Path -LiteralPath "$toolchain_target_path") {
|
2022-07-14 16:24:26 +00:00
|
|
|
Write-Host -NoNewline "Removing old Windows toolchain.."
|
2022-11-02 15:15:40 +00:00
|
|
|
Remove-Item -LiteralPath "$toolchain_target_path" -Force -Recurse
|
2022-07-14 16:24:26 +00:00
|
|
|
Write-Host "done!"
|
|
|
|
}
|
2022-11-02 15:15:40 +00:00
|
|
|
if (!(Test-Path -Path "$toolchain_zip_temp_path" -PathType Leaf)) {
|
2022-07-14 16:24:26 +00:00
|
|
|
Write-Host -NoNewline "Downloading Windows toolchain.."
|
|
|
|
$wc = New-Object net.webclient
|
2022-11-02 15:15:40 +00:00
|
|
|
$wc.Downloadfile("$toolchain_url", "$toolchain_zip_temp_path")
|
2022-07-14 16:24:26 +00:00
|
|
|
Write-Host "done!"
|
|
|
|
}
|
|
|
|
|
2022-11-02 15:15:40 +00:00
|
|
|
if (!(Test-Path -LiteralPath "$toolchain_target_path\..")) {
|
|
|
|
New-Item "$toolchain_target_path\.." -ItemType Directory -Force
|
2022-07-14 16:24:26 +00:00
|
|
|
}
|
|
|
|
|
2022-10-28 15:32:06 +00:00
|
|
|
Write-Host -NoNewline "Extracting Windows toolchain.."
|
2022-11-02 15:15:40 +00:00
|
|
|
# This is faster than Expand-Archive
|
2022-07-14 16:24:26 +00:00
|
|
|
Add-Type -Assembly "System.IO.Compression.Filesystem"
|
2022-11-02 15:15:40 +00:00
|
|
|
[System.IO.Compression.ZipFile]::ExtractToDirectory("$toolchain_zip_temp_path", "$download_dir")
|
|
|
|
# Expand-Archive -LiteralPath "$toolchain_zip_temp_path" -DestinationPath "$download_dir"
|
|
|
|
|
|
|
|
Write-Host -NoNewline "moving.."
|
2022-11-29 13:31:32 +00:00
|
|
|
Move-Item -LiteralPath "$toolchain_dist_temp_path" -Destination "$toolchain_target_path" -Force
|
2022-07-14 16:24:26 +00:00
|
|
|
Write-Host "done!"
|
|
|
|
|
2022-10-28 15:32:06 +00:00
|
|
|
Write-Host -NoNewline "Cleaning up temporary files.."
|
2022-11-02 15:15:40 +00:00
|
|
|
Remove-Item -LiteralPath "$toolchain_zip_temp_path" -Force
|
2022-07-14 16:24:26 +00:00
|
|
|
Write-Host "done!"
|
2022-11-02 15:15:40 +00:00
|
|
|
|
2022-11-29 13:31:32 +00:00
|
|
|
# dasdasd
|