From 89e077125b2f089945f0e5eb450196a3b741f86f Mon Sep 17 00:00:00 2001 From: Eng1n33r <101719414+Eng1n33r@users.noreply.github.com> Date: Sat, 2 Jul 2022 02:31:16 +0300 Subject: [PATCH] windows toolchain from ofw https://github.com/flipperdevices/flipperzero-firmware/pull/1351 --- .gitattributes | 3 ++ .gitignore | 2 +- fbt.cmd | 19 ++++++------ .../toolchain/windows-toolchain-download.ps1 | 30 +++++++++++++++++++ 4 files changed, 44 insertions(+), 10 deletions(-) create mode 100644 scripts/toolchain/windows-toolchain-download.ps1 diff --git a/.gitattributes b/.gitattributes index 6313b56c5..09c279e49 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1 +1,4 @@ * text=auto eol=lf +*.bat eol=crlf +*.ps1 eol=crlf +*.cmd eol=crlf \ No newline at end of file diff --git a/.gitignore b/.gitignore index 48a37cfc9..fc8ed1383 100644 --- a/.gitignore +++ b/.gitignore @@ -47,4 +47,4 @@ null.d build/ # Toolchain -toolchain*/ +/toolchain diff --git a/fbt.cmd b/fbt.cmd index 67d42132a..90e4e5f5e 100644 --- a/fbt.cmd +++ b/fbt.cmd @@ -1,11 +1,12 @@ @echo off - -set SCONS_EP=%~dp0\lib\scons\scripts\scons.py - -if exist ".git" ( - echo Updating git submodules - git submodule update --init -) - +set "toolchainRoot=%~dp0toolchain\i686-windows" set "SCONS_DEFAULT_FLAGS=-Q --warn=target-not-built" -python %SCONS_EP% %SCONS_DEFAULT_FLAGS% %* +if not exist "%~dp0.git" ( + echo ".git" directory not found, please clone repo via "git clone --recursive" + exit /B 1 +) +git submodule update --init +if not exist "%toolchainRoot%" ( + powershell -ExecutionPolicy Bypass -File %~dp0scripts\toolchain\windows-toolchain-download.ps1 +) +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 new file mode 100644 index 000000000..0ae5c7255 --- /dev/null +++ b/scripts/toolchain/windows-toolchain-download.ps1 @@ -0,0 +1,30 @@ +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" + +if (Test-Path -LiteralPath "$repo_root\toolchain\i686-windows") { + Write-Host -NoNewline "Removing old Windows toolchain.." + Remove-Item -LiteralPath "$repo_root\toolchain\i686-windows" -Force -Recurse + Write-Host "done!" +} +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" + Write-Host "done!" +} + +if (!(Test-Path -LiteralPath "$repo_root\toolchain")) { + New-Item "$repo_root\toolchain" -ItemType Directory +} + +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" +Write-Host "done!" + +Write-Host -NoNewline "Clearing temporary files.." +Remove-Item -LiteralPath "$repo_root\$toolchain_zip" -Force +Write-Host "done!" \ No newline at end of file