Skip to content

Commit dfddf1b

Browse files
committed
Replace wget on Windows with builtin curl
Signed-off-by: paulober <[email protected]>
1 parent 734d7ee commit dfddf1b

File tree

1 file changed

+43
-4
lines changed

1 file changed

+43
-4
lines changed

scripts/template_setup_win

Lines changed: 43 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,23 @@ REM # Check dependencies
5353

5454
call :check_command cmake 90
5555
if [%ERRORLEVEL%] neq [0] goto end
56-
call :check_command wget 91
57-
if [%ERRORLEVEL%] neq [0] goto end
56+
57+
REM # Pick a downloader: prefer curl (built into modern Windows), else wget
58+
set DL_TOOL=
59+
call :check_command curl 91
60+
if [%ERRORLEVEL%] equ [0] set DL_TOOL=curl
61+
62+
if [%DL_TOOL%] equ [] (
63+
call :check_command wget 91
64+
if [%ERRORLEVEL%] equ [0] set DL_TOOL=wget
65+
)
66+
67+
if [%DL_TOOL%] equ [] (
68+
echo Zephyr SDK setup requires either 'curl' (preferred) or 'wget' in PATH.
69+
set EXITCODE=91
70+
goto end
71+
)
72+
5873
call :check_command 7z 92
5974
if [%ERRORLEVEL%] neq [0] goto end
6075

@@ -144,6 +159,30 @@ if [%ERRORLEVEL%] equ [1] set DO_CMAKE_PKG=y
144159

145160
echo.
146161

162+
REM # Download helper
163+
REM # usage: call :download URL OUTFILE
164+
:download
165+
setlocal ENABLEDELAYEDEXPANSION
166+
set _URL=%~1
167+
set _OUT=%~2
168+
169+
if /i [%DL_TOOL%] equ [wget] (
170+
REM Emulate quiet+progress+timestamping:
171+
wget -q --show-progress -N -O "!_OUT!" "!_URL!"
172+
endlocal & exit /b %ERRORLEVEL%
173+
) else (
174+
REM curl: -f fail on HTTP errors; -L follow redirects
175+
REM --remote-time preserves Last-Modified on the file
176+
REM -z OUTFILE does conditional GET (only download if newer)
177+
REM Replace the --progress-bar with an -sS to make it quiet if needed
178+
if exist "!_OUT!" (
179+
curl.exe -fL --retry 5 --retry-delay 2 --progress-bar --remote-time -z "!_OUT!" -o "!_OUT!" "!_URL!"
180+
) else (
181+
curl.exe -fL --retry 5 --retry-delay 2 --progress-bar --remote-time -o "!_OUT!" "!_URL!"
182+
)
183+
endlocal & exit /b %ERRORLEVEL%
184+
)
185+
147186
:process
148187
REM # Install GNU toolchains
149188
if [%DO_GNU_TOOLCHAIN%] neq [] (
@@ -158,7 +197,7 @@ if [%DO_GNU_TOOLCHAIN%] neq [] (
158197
echo Installing '%%t' GNU toolchain ...
159198

160199
REM # Download toolchain archive
161-
wget -q --show-progress -N -O !TOOLCHAIN_FILENAME! !TOOLCHAIN_URI!
200+
call :download !TOOLCHAIN_URI! !TOOLCHAIN_FILENAME!
162201
if [!ERRORLEVEL!] neq [0] (
163202
del /q !TOOLCHAIN_FILENAME!
164203
echo ERROR: GNU toolchain download failed
@@ -190,7 +229,7 @@ if [%DO_LLVM_TOOLCHAIN%] neq [] (
190229
set TOOLCHAIN_URI=%DL_REL_BASE%/!TOOLCHAIN_FILENAME!
191230

192231
REM # Download toolchain archive
193-
wget -q --show-progress -N -O !TOOLCHAIN_FILENAME! !TOOLCHAIN_URI!
232+
call :download !TOOLCHAIN_URI! !TOOLCHAIN_FILENAME!
194233
if [!ERRORLEVEL!] neq [0] (
195234
del /q !TOOLCHAIN_FILENAME!
196235
echo ERROR: LLVM toolchain download failed

0 commit comments

Comments
 (0)