@@ -49,7 +49,7 @@ check_command()
4949}
5050
5151# Check if the current installation is a full SDK with all GNU toolchains
52- check_full_sdk ()
52+ check_full_gnu_sdk ()
5353{
5454 for toolchain in ${gnu_toolchains[@]} ; do
5555 if [ ! -d " gnu/${toolchain} " ]; then
@@ -67,6 +67,7 @@ usage()
6767 echo
6868 echo " -t <gnu_toolchain> Install specified GNU toolchain"
6969 echo " all Install all GNU toolchains"
70+ echo " -l Install LLVM toolchain"
7071 echo " -h Install host tools"
7172 echo " -c Register Zephyr SDK CMake package"
7273 echo
@@ -89,20 +90,27 @@ user_prompt()
8990 echo
9091
9192 # GNU Toolchains
92- check_full_sdk
93- if [ $? != 0 ]; then
94- ask_yn " Install GNU toolchains for all targets"
95- if [ $? == 0 ]; then
96- inst_gnu_toolchains=(${gnu_toolchains[*]} )
97- else
98- for toolchain in ${gnu_toolchains[@]} ; do
99- if [ ! -d " gnu/${toolchain} " ]; then
100- ask_yn " Install '${toolchain} ' GNU toolchain" && inst_gnu_toolchains+=(" ${toolchain} " )
101- fi
102- done
93+ ask_yn " Install GNU toolchain"
94+ if [ $? == 0 ]; then
95+ do_gnu_toolchain=" y"
96+ check_full_gnu_sdk
97+ if [ $? != 0 ]; then
98+ ask_yn " Install GNU toolchains for all targets"
99+ if [ $? == 0 ]; then
100+ inst_gnu_toolchains=(${gnu_toolchains[*]} )
101+ else
102+ for toolchain in ${gnu_toolchains[@]} ; do
103+ if [ ! -d " gnu/${toolchain} " ]; then
104+ ask_yn " Install '${toolchain} ' GNU toolchain" && inst_gnu_toolchains+=(" ${toolchain} " )
105+ fi
106+ done
107+ fi
103108 fi
104109 fi
105110
111+ # LLVM Toolchain
112+ ask_yn " Install LLVM toolchain" && do_llvm_toolchain=" y"
113+
106114 # Host Tools
107115 ask_yn " Install host tools" && do_hosttools=" y"
108116
@@ -140,6 +148,10 @@ else
140148 exit 2
141149 fi
142150 fi
151+ do_gnu_toolchain=" y"
152+ ;;
153+ -l)
154+ do_llvm_toolchain=" y"
143155 ;;
144156 -h)
145157 do_hosttools=" y"
187199# Resolve release download base URI
188200dl_rel_base=" https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v${version} "
189201dl_gnu_toolchain_filename=' toolchain_gnu_${host}_${toolchain}.tar.xz'
202+ dl_llvm_toolchain_filename=' toolchain_llvm_${host}.tar.xz'
190203
191204# Print banner
192205echo " Zephyr SDK ${version} Setup"
@@ -203,38 +216,65 @@ if [ "${interactive}" = "y" ]; then
203216fi
204217
205218# Install GNU toolchains
206- mkdir -p gnu
207- pushd gnu
219+ if [ " ${do_gnu_toolchain} " = " y" ]; then
220+ mkdir -p gnu
221+ pushd gnu
208222
209- for toolchain in ${inst_gnu_toolchains[@]} ; do
210- eval toolchain_filename=" ${dl_gnu_toolchain_filename} "
211- toolchain_uri=" ${dl_rel_base} /${toolchain_filename} "
223+ for toolchain in ${inst_gnu_toolchains[@]} ; do
224+ eval toolchain_filename=" ${dl_gnu_toolchain_filename} "
225+ toolchain_uri=" ${dl_rel_base} /${toolchain_filename} "
212226
213- # Skip if toolchain directory already exists
214- if [ -d " ${toolchain} " ]; then
215- continue
216- fi
227+ # Skip if toolchain directory already exists
228+ if [ -d " ${toolchain} " ]; then
229+ continue
230+ fi
231+
232+ echo " Installing '${toolchain} ' GNU toolchain ..."
233+
234+ # Download toolchain archive
235+ wget -q --show-progress -N -O " ${toolchain_filename} " " ${toolchain_uri} "
236+ if [ $? != 0 ]; then
237+ rm -f " ${toolchain_filename} "
238+ echo " ERROR: GNU toolchain download failed"
239+ exit 20
240+ fi
217241
218- echo " Installing '${toolchain} ' GNU toolchain ..."
242+ # Extract archive
243+ tar xf " ${toolchain_filename} "
244+ assert_rc " ERROR: GNU toolchain archive extraction failed" 21
245+
246+ # Remove archive
247+ rm -f " ${toolchain_filename} "
248+
249+ echo
250+ done
251+ popd
252+ fi
253+
254+ # Install LLVM toolchain
255+ if [ " ${do_llvm_toolchain} " = " y" ] && [ ! -d " llvm" ]; then
256+ echo " Installing LLVM toolchain ..."
257+
258+ eval toolchain_filename=" ${dl_llvm_toolchain_filename} "
259+ toolchain_uri=" ${dl_rel_base} /${toolchain_filename} "
219260
220261 # Download toolchain archive
221262 wget -q --show-progress -N -O " ${toolchain_filename} " " ${toolchain_uri} "
222263 if [ $? != 0 ]; then
223264 rm -f " ${toolchain_filename} "
224- echo " ERROR: GNU toolchain download failed"
265+ echo " ERROR: LLVM toolchain download failed"
225266 exit 20
226267 fi
227268
228269 # Extract archive
229270 tar xf " ${toolchain_filename} "
230- assert_rc " ERROR: GNU toolchain archive extraction failed" 21
271+ assert_rc " ERROR: LLVM toolchain archive extraction failed" 21
231272
232273 # Remove archive
233274 rm -f " ${toolchain_filename} "
234275
235276 echo
236- done
237- popd
277+ fi
238278
239279# Install host tools
240280if [ " ${do_hosttools} " = " y" ]; then
0 commit comments