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