From dfddf1bb40350b7bd6cf8b24fa4809c7af58b47c Mon Sep 17 00:00:00 2001 From: paulober <44974737+paulober@users.noreply.github.com> Date: Mon, 15 Sep 2025 11:52:19 +0100 Subject: [PATCH 1/2] Replace wget on Windows with builtin curl Signed-off-by: paulober <44974737+paulober@users.noreply.github.com> --- scripts/template_setup_win | 47 ++++++++++++++++++++++++++++++++++---- 1 file changed, 43 insertions(+), 4 deletions(-) diff --git a/scripts/template_setup_win b/scripts/template_setup_win index 02af1d4c..9f7dcdf2 100644 --- a/scripts/template_setup_win +++ b/scripts/template_setup_win @@ -53,8 +53,23 @@ REM # Check dependencies call :check_command cmake 90 if [%ERRORLEVEL%] neq [0] goto end -call :check_command wget 91 -if [%ERRORLEVEL%] neq [0] goto end + +REM # Pick a downloader: prefer curl (built into modern Windows), else wget +set DL_TOOL= +call :check_command curl 91 +if [%ERRORLEVEL%] equ [0] set DL_TOOL=curl + +if [%DL_TOOL%] equ [] ( + call :check_command wget 91 + if [%ERRORLEVEL%] equ [0] set DL_TOOL=wget +) + +if [%DL_TOOL%] equ [] ( + echo Zephyr SDK setup requires either 'curl' (preferred) or 'wget' in PATH. + set EXITCODE=91 + goto end +) + call :check_command 7z 92 if [%ERRORLEVEL%] neq [0] goto end @@ -144,6 +159,30 @@ if [%ERRORLEVEL%] equ [1] set DO_CMAKE_PKG=y echo. +REM # Download helper +REM # usage: call :download URL OUTFILE +:download +setlocal ENABLEDELAYEDEXPANSION +set _URL=%~1 +set _OUT=%~2 + +if /i [%DL_TOOL%] equ [wget] ( + REM Emulate quiet+progress+timestamping: + wget -q --show-progress -N -O "!_OUT!" "!_URL!" + endlocal & exit /b %ERRORLEVEL% +) else ( + REM curl: -f fail on HTTP errors; -L follow redirects + REM --remote-time preserves Last-Modified on the file + REM -z OUTFILE does conditional GET (only download if newer) + REM Replace the --progress-bar with an -sS to make it quiet if needed + if exist "!_OUT!" ( + curl.exe -fL --retry 5 --retry-delay 2 --progress-bar --remote-time -z "!_OUT!" -o "!_OUT!" "!_URL!" + ) else ( + curl.exe -fL --retry 5 --retry-delay 2 --progress-bar --remote-time -o "!_OUT!" "!_URL!" + ) + endlocal & exit /b %ERRORLEVEL% +) + :process REM # Install GNU toolchains if [%DO_GNU_TOOLCHAIN%] neq [] ( @@ -158,7 +197,7 @@ if [%DO_GNU_TOOLCHAIN%] neq [] ( echo Installing '%%t' GNU toolchain ... REM # Download toolchain archive - wget -q --show-progress -N -O !TOOLCHAIN_FILENAME! !TOOLCHAIN_URI! + call :download !TOOLCHAIN_URI! !TOOLCHAIN_FILENAME! if [!ERRORLEVEL!] neq [0] ( del /q !TOOLCHAIN_FILENAME! echo ERROR: GNU toolchain download failed @@ -190,7 +229,7 @@ if [%DO_LLVM_TOOLCHAIN%] neq [] ( set TOOLCHAIN_URI=%DL_REL_BASE%/!TOOLCHAIN_FILENAME! REM # Download toolchain archive - wget -q --show-progress -N -O !TOOLCHAIN_FILENAME! !TOOLCHAIN_URI! + call :download !TOOLCHAIN_URI! !TOOLCHAIN_FILENAME! if [!ERRORLEVEL!] neq [0] ( del /q !TOOLCHAIN_FILENAME! echo ERROR: LLVM toolchain download failed From 303c90403d40ff543147da7dba702c8de6d160e1 Mon Sep 17 00:00:00 2001 From: paulober <44974737+paulober@users.noreply.github.com> Date: Fri, 26 Sep 2025 11:59:30 +0100 Subject: [PATCH 2/2] Make wget default and add curl flag Signed-off-by: paulober <44974737+paulober@users.noreply.github.com> --- scripts/template_setup_win | 68 +++++++++++++++++++++++++++++--------- 1 file changed, 52 insertions(+), 16 deletions(-) diff --git a/scripts/template_setup_win b/scripts/template_setup_win index 9f7dcdf2..6bb0375c 100644 --- a/scripts/template_setup_win +++ b/scripts/template_setup_win @@ -54,22 +54,6 @@ REM # Check dependencies call :check_command cmake 90 if [%ERRORLEVEL%] neq [0] goto end -REM # Pick a downloader: prefer curl (built into modern Windows), else wget -set DL_TOOL= -call :check_command curl 91 -if [%ERRORLEVEL%] equ [0] set DL_TOOL=curl - -if [%DL_TOOL%] equ [] ( - call :check_command wget 91 - if [%ERRORLEVEL%] equ [0] set DL_TOOL=wget -) - -if [%DL_TOOL%] equ [] ( - echo Zephyr SDK setup requires either 'curl' (preferred) or 'wget' in PATH. - set EXITCODE=91 - goto end -) - call :check_command 7z 92 if [%ERRORLEVEL%] neq [0] goto end @@ -96,6 +80,17 @@ if /i [%1] equ [/t] ( ) set DO_GNU_TOOLCHAIN=y shift +) else if /i [%1] equ [/dl] ( + if /i [%2] equ [curl] ( + set DL_FORCE=curl + ) else if /i [%2] equ [wget] ( + set DL_FORCE=wget + ) else ( + echo ERROR: /dl expects ^ + set EXITCODE=3 + goto end + ) + shift ) else if /i [%1] equ [/l] ( set DO_LLVM_TOOLCHAIN=y ) else if /i [%1] equ [/h] ( @@ -184,6 +179,46 @@ if /i [%DL_TOOL%] equ [wget] ( ) :process +REM # Choose downloader (default: wget; fallback to curl). Allow /dl override. +set DL_TOOL= + +if /i [%DL_FORCE%] equ [curl] ( + call :check_command curl 91 + if [%ERRORLEVEL%] equ [0] ( + set DL_TOOL=curl + ) else ( + echo ERROR: /dl curl requested but 'curl' not found in PATH. + set EXITCODE=91 + goto end + ) +) else if /i [%DL_FORCE%] equ [wget] ( + call :check_command wget 91 + if [%ERRORLEVEL%] equ [0] ( + set DL_TOOL=wget + ) else ( + echo ERROR: /dl wget requested but 'wget' not found in PATH. + set EXITCODE=91 + goto end + ) +) else ( + REM Default behavior: prefer wget, else curl + call :check_command wget 91 + if [%ERRORLEVEL%] equ [0] ( + set DL_TOOL=wget + ) else ( + call :check_command curl 91 + if [%ERRORLEVEL%] equ [0] ( + set DL_TOOL=curl + ) + ) +) + +if [%DL_TOOL%] equ [] ( + echo Zephyr SDK setup requires either 'wget' or 'curl' in PATH. + set EXITCODE=91 + goto end +) + REM # Install GNU toolchains if [%DO_GNU_TOOLCHAIN%] neq [] ( if not exist gnu\ mkdir gnu @@ -282,6 +317,7 @@ echo all Install all GNU toolchains echo /l Install LLVM toolchain echo /h Install host tools echo /c Register Zephyr SDK CMake package +echo /dl ^ Force downloader (default: wget, fallback to curl) echo. echo Supported GNU Toolchains: echo.