From 5b4e7f8dd124e350ebd721907a384f3756233ea4 Mon Sep 17 00:00:00 2001 From: Eng1n33r <101719414+Eng1n33r@users.noreply.github.com> Date: Sat, 2 Jul 2022 17:03:48 +0300 Subject: [PATCH] tc versioning from brunkbatya branch --- fbt.cmd | 10 +++++++++- scripts/toolchain/windows-toolchain-download.ps1 | 14 +++++++++----- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/fbt.cmd b/fbt.cmd index 90e4e5f5e..a5de266ad 100644 --- a/fbt.cmd +++ b/fbt.cmd @@ -1,4 +1,5 @@ @echo off +set "flipper_toolchain_version=2" set "toolchainRoot=%~dp0toolchain\i686-windows" set "SCONS_DEFAULT_FLAGS=-Q --warn=target-not-built" if not exist "%~dp0.git" ( @@ -7,6 +8,13 @@ if not exist "%~dp0.git" ( ) git submodule update --init if not exist "%toolchainRoot%" ( - powershell -ExecutionPolicy Bypass -File %~dp0scripts\toolchain\windows-toolchain-download.ps1 + powershell -ExecutionPolicy Bypass -File %~dp0scripts\toolchain\windows-toolchain-download.ps1 "%flipper_toolchain_version%" +) +if not exist "%toolchainRoot%\VERSION" ( + powershell -ExecutionPolicy Bypass -File %~dp0scripts\toolchain\windows-toolchain-download.ps1 "%flipper_toolchain_version%" +) +set /p real_toolchain_version=<%toolchainRoot%\VERSION +if not "%real_toolchain_version%" == "%flipper_toolchain_version%" ( + powershell -ExecutionPolicy Bypass -File %~dp0scripts\toolchain\windows-toolchain-download.ps1 "%flipper_toolchain_version%" ) cmd /V /C "set "PATH=%toolchainRoot%\python;%toolchainRoot%\bin;%toolchainRoot%\protoc\bin;%toolchainRoot%\openocd\bin;%PATH%" && python lib\scons\scripts\scons.py %SCONS_DEFAULT_FLAGS% %*" \ No newline at end of file diff --git a/scripts/toolchain/windows-toolchain-download.ps1 b/scripts/toolchain/windows-toolchain-download.ps1 index 0ae5c7255..b850a8315 100644 --- a/scripts/toolchain/windows-toolchain-download.ps1 +++ b/scripts/toolchain/windows-toolchain-download.ps1 @@ -2,8 +2,10 @@ Set-StrictMode -Version 2.0 $ErrorActionPreference = "Stop" [Net.ServicePointManager]::SecurityProtocol = "tls12, tls11, tls" $repo_root = (Get-Item "$PSScriptRoot\..\..").FullName -$toolchain_url = "https://update.flipperzero.one/builds/toolchain/gcc-arm-none-eabi-10.3-2022.06-i686-windows-flipper.zip" -$toolchain_zip = "gcc-arm-none-eabi-10.3-2022.06-i686-windows-flipper.zip" +$toolchain_version = $args[0] +$toolchain_url = "https://update.flipperzero.one/builds/toolchain/gcc-arm-none-eabi-10.3-i686-windows-flipper-$toolchain_version.zip" +$toolchain_zip = "gcc-arm-none-eabi-10.3-i686-windows-flipper-$toolchain_version.zip" +$toolchain_dir = "gcc-arm-none-eabi-10.3-i686-windows-flipper" if (Test-Path -LiteralPath "$repo_root\toolchain\i686-windows") { Write-Host -NoNewline "Removing old Windows toolchain.." @@ -12,7 +14,8 @@ if (Test-Path -LiteralPath "$repo_root\toolchain\i686-windows") { } if (!(Test-Path -Path "$repo_root\$toolchain_zip" -PathType Leaf)) { Write-Host -NoNewline "Downloading Windows toolchain.." - Invoke-WebRequest -Uri "$toolchain_url" -OutFile "$repo_root\$toolchain_zip" + $wc = New-Object net.webclient + $wc.Downloadfile("$toolchain_url", "$repo_root\$toolchain_zip") Write-Host "done!" } @@ -21,8 +24,9 @@ if (!(Test-Path -LiteralPath "$repo_root\toolchain")) { } Write-Host -NoNewline "Unziping Windows toolchain.." -Expand-Archive -LiteralPath "$toolchain_zip" -DestinationPath "$repo_root\" -Force -Move-Item -Path "$repo_root\gcc-arm-none-eabi-10.3-2022.06" -Destination "$repo_root\toolchain\i686-windows" +Add-Type -Assembly "System.IO.Compression.Filesystem" +[System.IO.Compression.ZipFile]::ExtractToDirectory("$toolchain_zip", "$repo_root\") +Move-Item -Path "$repo_root\$toolchain_dir" -Destination "$repo_root\toolchain\i686-windows" Write-Host "done!" Write-Host -NoNewline "Clearing temporary files.."