@@ -53,8 +53,23 @@ REM # Check dependencies
53
53
54
54
call :check_command cmake 90
55
55
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
+
58
73
call :check_command 7z 92
59
74
if [%ERRORLEVEL%] neq [0] goto end
60
75
@@ -144,6 +159,30 @@ if [%ERRORLEVEL%] equ [1] set DO_CMAKE_PKG=y
144
159
145
160
echo.
146
161
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
+
147
186
:process
148
187
REM # Install GNU toolchains
149
188
if [%DO_GNU_TOOLCHAIN%] neq [] (
@@ -158,7 +197,7 @@ if [%DO_GNU_TOOLCHAIN%] neq [] (
158
197
echo Installing '%%t' GNU toolchain ...
159
198
160
199
REM # Download toolchain archive
161
- wget -q --show-progress -N -O !TOOLCHAIN_FILENAME ! !TOOLCHAIN_URI !
200
+ call :download !TOOLCHAIN_URI ! !TOOLCHAIN_FILENAME !
162
201
if [!ERRORLEVEL!] neq [0] (
163
202
del /q !TOOLCHAIN_FILENAME!
164
203
echo ERROR: GNU toolchain download failed
@@ -190,7 +229,7 @@ if [%DO_LLVM_TOOLCHAIN%] neq [] (
190
229
set TOOLCHAIN_URI=%DL_REL_BASE%/!TOOLCHAIN_FILENAME!
191
230
192
231
REM # Download toolchain archive
193
- wget -q --show-progress -N -O !TOOLCHAIN_FILENAME ! !TOOLCHAIN_URI !
232
+ call :download !TOOLCHAIN_URI ! !TOOLCHAIN_FILENAME !
194
233
if [!ERRORLEVEL!] neq [0] (
195
234
del /q !TOOLCHAIN_FILENAME!
196
235
echo ERROR: LLVM toolchain download failed
0 commit comments