@@ -7,9 +7,53 @@ pushd %~dp0
7
7
setlocal ENABLEDELAYEDEXPANSION
8
8
set EXITCODE=0
9
9
10
+ goto entry
11
+
12
+ REM # Check if command is available
13
+ :check_command
14
+ where %1 > nul 2>&1
15
+ if [%ERRORLEVEL%] neq [0] (
16
+ echo Zephyr SDK setup requires '%1' to be installed and available in the PATH.
17
+ echo Please install '%1' and run this script again.
18
+
19
+ set EXITCODE=%2
20
+ exit /b 1
21
+ )
22
+ exit /b 0
23
+
24
+ :entry
25
+
26
+ REM # Initialise toolchain list
27
+ set TOOLCHAINS=
28
+ set TOOLCHAINS=%TOOLCHAINS% aarch64-zephyr-elf
29
+ set TOOLCHAINS=%TOOLCHAINS% arc64-zephyr-elf
30
+ set TOOLCHAINS=%TOOLCHAINS% arc-zephyr-elf
31
+ set TOOLCHAINS=%TOOLCHAINS% arm-zephyr-eabi
32
+ set TOOLCHAINS=%TOOLCHAINS% mips-zephyr-elf
33
+ set TOOLCHAINS=%TOOLCHAINS% nios2-zephyr-elf
34
+ set TOOLCHAINS=%TOOLCHAINS% riscv64-zephyr-elf
35
+ set TOOLCHAINS=%TOOLCHAINS% sparc-zephyr-elf
36
+ set TOOLCHAINS=%TOOLCHAINS% x86_64-zephyr-elf
37
+ set TOOLCHAINS=%TOOLCHAINS% xtensa-espressif_esp32_zephyr-elf
38
+ set TOOLCHAINS=%TOOLCHAINS% xtensa-espressif_esp32s2_zephyr-elf
39
+ set TOOLCHAINS=%TOOLCHAINS% xtensa-intel_apl_adsp_zephyr-elf
40
+ set TOOLCHAINS=%TOOLCHAINS% xtensa-intel_bdw_adsp_zephyr-elf
41
+ set TOOLCHAINS=%TOOLCHAINS% xtensa-intel_byt_adsp_zephyr-elf
42
+ set TOOLCHAINS=%TOOLCHAINS% xtensa-intel_s1000_zephyr-elf
43
+ set TOOLCHAINS=%TOOLCHAINS% xtensa-nxp_imx_adsp_zephyr-elf
44
+ set TOOLCHAINS=%TOOLCHAINS% xtensa-nxp_imx8m_adsp_zephyr-elf
45
+ set TOOLCHAINS=%TOOLCHAINS% xtensa-sample_controller_zephyr-elf
46
+
47
+ REM Initialise list of toolchains to install
48
+ set INST_TOOLCHAINS=
49
+
10
50
REM # Read bundle version from file
11
51
set /p VERSION=<sdk_version
12
52
53
+ REM # Resolve release download base URI
54
+ set DL_REL_BASE=https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v%VERSION%
55
+ set DL_TOOLCHAIN_FILENAME=toolchain_windows-x86_64_%%t.zip
56
+
13
57
REM # Print banner
14
58
echo Zephyr SDK %VERSION% Setup
15
59
echo.
@@ -20,14 +64,13 @@ if [%1] equ [] (
20
64
)
21
65
22
66
REM # Check dependencies
23
- where cmake > nul 2>&1
24
- if [%ERRORLEVEL%] neq [0] (
25
- echo Zephyr SDK setup requires CMake to be installed and available in the PATH.
26
- echo Please install CMake and run this script again.
27
67
28
- set EXITCODE=90
29
- goto end
30
- )
68
+ call :check_command cmake 90
69
+ if [%ERRORLEVEL%] neq [0] goto end
70
+ call :check_command wget 91
71
+ if [%ERRORLEVEL%] neq [0] goto end
72
+ call :check_command unzip 92
73
+ if [%ERRORLEVEL%] neq [0] goto end
31
74
32
75
REM # Enter interactive mode if enabled
33
76
if [%INTERACTIVE%] neq [] (
@@ -36,10 +79,25 @@ if [%INTERACTIVE%] neq [] (
36
79
37
80
REM # Parse arguments if specified
38
81
:parsearg
39
- if /i [%1] equ [/c] (
40
- set DO_CMAKE_PKG=y
41
- ) else if /i [%1] equ [/t] (
82
+ if /i [%1] equ [/t] (
83
+ if [%2] equ [all] (
84
+ set INST_TOOLCHAINS=%TOOLCHAINS%
85
+ ) else (
86
+ set IS_VALID=
87
+ for %%t in (%TOOLCHAINS%) do if [%%t] equ [%2] set IS_VALID=y
88
+ if [!IS_VALID!] equ [y] (
89
+ set INST_TOOLCHAINS=!INST_TOOLCHAINS! %2
90
+ ) else (
91
+ echo ERROR: Unknown toolchain '%2'
92
+ set EXITCODE=2
93
+ goto end
94
+ )
95
+ )
96
+ shift
97
+ ) else if /i [%1] equ [/h] (
42
98
set DO_HOSTTOOLS=y
99
+ ) else if /i [%1] equ [/c] (
100
+ set DO_CMAKE_PKG=y
43
101
) else (
44
102
goto usage
45
103
)
@@ -58,21 +116,67 @@ echo You only need to run this script once after extracting the Zephyr SDK
58
116
echo distribution bundle archive.
59
117
echo.
60
118
119
+ REM # Check installation type
120
+ for %%t in (%TOOLCHAINS%) do (
121
+ if not exist %%t\ (
122
+ set IS_PARTIAL_SDK=y
123
+ )
124
+ )
125
+
61
126
REM # Ask user for set-up choices
62
- choice /c:yn /m:"Register Zephyr SDK CMake package"
63
- if [%ERRORLEVEL%] equ [1] set DO_CMAKE_PKG=y
127
+ if [%IS_PARTIAL_SDK%] neq [] (
128
+ choice /c:yn /m:"Install toolchains for all targets"
129
+ if [!ERRORLEVEL!] equ [1] (
130
+ set INST_TOOLCHAINS=%TOOLCHAINS%
131
+ ) else (
132
+ for %%t in (%TOOLCHAINS%) do (
133
+ if not exist %%t\ (
134
+ choice /c:yn /m:"Install '%%t' toolchain"
135
+ if [!ERRORLEVEL!] equ [1] (
136
+ set INST_TOOLCHAINS=!INST_TOOLCHAINS! %%t
137
+ )
138
+ )
139
+ )
140
+ )
141
+ )
64
142
65
143
choice /c:yn /m:"Install host tools"
66
144
if [%ERRORLEVEL%] equ [1] set DO_HOSTTOOLS=y
67
145
146
+ choice /c:yn /m:"Register Zephyr SDK CMake package"
147
+ if [%ERRORLEVEL%] equ [1] set DO_CMAKE_PKG=y
148
+
68
149
echo.
69
150
70
151
:process
71
- REM # Register Zephyr SDK CMake package
72
- if [%DO_CMAKE_PKG%] neq [] (
73
- echo Registering Zephyr SDK CMake package ...
74
- cmake -P cmake\zephyr_sdk_export.cmake
75
- echo.
152
+ REM # Install toolchains
153
+ for %%t in (%INST_TOOLCHAINS%) do (
154
+ set TOOLCHAIN_FILENAME=%DL_TOOLCHAIN_FILENAME%
155
+ set TOOLCHAIN_URI=%DL_REL_BASE%/!TOOLCHAIN_FILENAME!
156
+
157
+ if not exist %%t\ (
158
+ echo Installing '%%t' toolchain ...
159
+
160
+ REM # Download toolchain archive
161
+ wget -q --show-progress -N -O !TOOLCHAIN_FILENAME! !TOOLCHAIN_URI!
162
+ if [!ERRORLEVEL!] neq [0] (
163
+ del /q !TOOLCHAIN_FILENAME!
164
+ echo ERROR: Toolchain download failed
165
+ set EXITCODE=20
166
+ goto end
167
+ )
168
+
169
+ REM # Extract archive
170
+ unzip -q !TOOLCHAIN_FILENAME!
171
+ if [!ERRORLEVEL!] neq [0] (
172
+ echo ERROR: Toolchain archive extraction failed
173
+ set EXITCODE=21
174
+ goto end
175
+ )
176
+
177
+ REM # Remove archive
178
+ del /q !TOOLCHAIN_FILENAME!
179
+ )
76
180
)
77
181
78
182
REM # Install host tools
@@ -82,15 +186,34 @@ if [%DO_HOSTTOOLS%] neq [] (
82
186
echo.
83
187
)
84
188
189
+ REM # Register Zephyr SDK CMake package
190
+ if [%DO_CMAKE_PKG%] neq [] (
191
+ echo Registering Zephyr SDK CMake package ...
192
+ cmake -P cmake\zephyr_sdk_export.cmake
193
+ if [!ERRORLEVEL!] neq [0] (
194
+ set EXITCODE=40
195
+ goto end
196
+ )
197
+ echo.
198
+ )
199
+
85
200
echo All done.
86
201
goto end
87
202
88
203
REM # Print scripting mode usage
89
204
:usage
90
- echo %~n0 [/c] [/t]
205
+ echo %~n0 [/t ^<toolchain^>] [/h] [/c]
206
+ echo.
207
+ echo /t ^<toolchain^> Install specified toolchain
208
+ echo all Install all toolchains
209
+ echo /h Install host tools
210
+ echo /c Register Zephyr SDK CMake package
91
211
echo.
92
- echo /c Register Zephyr SDK CMake package
93
- echo /t Install host tools
212
+ echo Supported Toolchains:
213
+ echo.
214
+ for %%t in (%TOOLCHAINS%) do (
215
+ echo %%t
216
+ )
94
217
echo.
95
218
echo When no arguments are specified, the setup script runs in the interactive
96
219
echo mode asking for user inputs.
0 commit comments