@@ -38,6 +38,7 @@ set /p VERSION=<sdk_version
3838REM # Resolve release download base URI
3939set DL_REL_BASE=https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v%VERSION%
4040set DL_GNU_TOOLCHAIN_FILENAME=toolchain_gnu_windows-x86_64_%%t.7z
41+ set DL_LLVM_TOOLCHAIN_FILENAME=toolchain_llvm_windows-x86_64.7z
4142
4243REM # Print banner
4344echo Zephyr SDK %VERSION% Setup
@@ -78,7 +79,10 @@ if /i [%1] equ [/t] (
7879 goto end
7980 )
8081 )
82+ set DO_GNU_TOOLCHAIN=y
8183 shift
84+ ) else if /i [%1] equ [/l] (
85+ set DO_LLVM_TOOLCHAIN=y
8286) else if /i [%1] equ [/h] (
8387 set DO_HOSTTOOLS=y
8488) else if /i [%1] equ [/c] (
@@ -104,27 +108,34 @@ echo.
104108REM # Check installation type
105109for %%t in (%GNU_TOOLCHAINS%) do (
106110 if not exist gnu\%%t\ (
107- set IS_PARTIAL_SDK =y
111+ set IS_PARTIAL_GNU_SDK =y
108112 )
109113)
110114
111115REM # Ask user for set-up choices
112- if [%IS_PARTIAL_SDK%] neq [] (
113- choice /c:yn /m:"Install GNU toolchains for all targets"
114- if [!ERRORLEVEL!] equ [1] (
115- set INST_GNU_TOOLCHAINS=%GNU_TOOLCHAINS%
116- ) else (
117- for %%t in (%GNU_TOOLCHAINS%) do (
118- if not exist gnu\%%t\ (
119- choice /c:yn /m:"Install '%%t' GNU toolchain"
120- if [!ERRORLEVEL!] equ [1] (
121- set INST_GNU_TOOLCHAINS=!INST_GNU_TOOLCHAINS! %%t
116+ choice /c:yn /m:"Install GNU toolchain"
117+ if [!ERRORLEVEL!] equ [1] (
118+ set DO_GNU_TOOLCHAIN=y
119+ if [%IS_PARTIAL_GNU_SDK%] neq [] (
120+ choice /c:yn /m:"Install GNU toolchains for all targets"
121+ if [!ERRORLEVEL!] equ [1] (
122+ set INST_GNU_TOOLCHAINS=%GNU_TOOLCHAINS%
123+ ) else (
124+ for %%t in (%GNU_TOOLCHAINS%) do (
125+ if not exist gnu\%%t\ (
126+ choice /c:yn /m:"Install '%%t' GNU toolchain"
127+ if [!ERRORLEVEL!] equ [1] (
128+ set INST_GNU_TOOLCHAINS=!INST_GNU_TOOLCHAINS! %%t
129+ )
122130 )
123131 )
124132 )
125133 )
126134)
127135
136+ choice /c:yn /m:"Install LLVM toolchain"
137+ if [%ERRORLEVEL%] equ [1] set DO_LLVM_TOOLCHAIN=y
138+
128139choice /c:yn /m:"Install host tools"
129140if [%ERRORLEVEL%] equ [1] set DO_HOSTTOOLS=y
130141
@@ -135,38 +146,72 @@ echo.
135146
136147:process
137148REM # Install GNU toolchains
138- if not exist gnu\ mkdir gnu
139- pushd gnu
149+ if [%DO_GNU_TOOLCHAIN%] neq [] (
150+ if not exist gnu\ mkdir gnu
151+ pushd gnu
152+
153+ for %%t in (%INST_GNU_TOOLCHAINS%) do (
154+ set TOOLCHAIN_FILENAME=%DL_GNU_TOOLCHAIN_FILENAME%
155+ set TOOLCHAIN_URI=%DL_REL_BASE%/!TOOLCHAIN_FILENAME!
156+
157+ if not exist %%t\ (
158+ echo Installing '%%t' GNU 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: GNU toolchain download failed
165+ set EXITCODE=20
166+ goto end
167+ )
168+
169+ REM # Extract archive
170+ 7z x -o. !TOOLCHAIN_FILENAME!
171+ if [!ERRORLEVEL!] neq [0] (
172+ echo ERROR: GNU toolchain archive extraction failed
173+ set EXITCODE=21
174+ goto end
175+ )
140176
141- for %%t in (%INST_GNU_TOOLCHAINS%) do (
142- set TOOLCHAIN_FILENAME=%DL_GNU_TOOLCHAIN_FILENAME%
143- set TOOLCHAIN_URI=%DL_REL_BASE%/!TOOLCHAIN_FILENAME!
177+ REM # Remove archive
178+ del /q !TOOLCHAIN_FILENAME!
179+ )
180+ )
181+ popd
182+ )
144183
145- if not exist %%t\ (
146- echo Installing '%%t' GNU toolchain ...
184+ REM # Install LLVM toolchain
185+ if [%DO_LLVM_TOOLCHAIN%] neq [] (
186+ if not exist llvm\ (
187+ echo Installing LLVM toolchain ...
188+
189+ set TOOLCHAIN_FILENAME=%DL_GNU_TOOLCHAIN_FILENAME%
190+ set TOOLCHAIN_URI=%DL_REL_BASE%/!TOOLCHAIN_FILENAME!
147191
148192 REM # Download toolchain archive
149193 wget -q --show-progress -N -O !TOOLCHAIN_FILENAME! !TOOLCHAIN_URI!
150194 if [!ERRORLEVEL!] neq [0] (
151195 del /q !TOOLCHAIN_FILENAME!
152- echo ERROR: GNU toolchain download failed
196+ echo ERROR: LLVM toolchain download failed
153197 set EXITCODE=20
154198 goto end
155199 )
156200
157201 REM # Extract archive
158202 7z x -o. !TOOLCHAIN_FILENAME!
159203 if [!ERRORLEVEL!] neq [0] (
160- echo ERROR: GNU toolchain archive extraction failed
204+ echo ERROR: LLVM toolchain archive extraction failed
161205 set EXITCODE=21
162206 goto end
163207 )
164208
165209 REM # Remove archive
166210 del /q !TOOLCHAIN_FILENAME!
211+
212+ echo.
167213 )
168214)
169- popd
170215
171216REM # Install host tools
172217if [%DO_HOSTTOOLS%] neq [] (
@@ -195,6 +240,7 @@ echo %~n0 [/t ^<gnu_toolchain^>] [/h] [/c]
195240echo.
196241echo /t ^<gnu_toolchain^> Install specified GNU toolchain
197242echo all Install all GNU toolchains
243+ echo /l Install LLVM toolchain
198244echo /h Install host tools
199245echo /c Register Zephyr SDK CMake package
200246echo.
0 commit comments