Skip to content

Commit 516f7f9

Browse files
committed
scripts: Rework POSIX setup script for restructured bundle
This commit reworks the POSIX Zephyr SDK distribution bundle setup script to work with the restructured distribution bundle. Signed-off-by: Stephanos Ioannidis <[email protected]>
1 parent 7dc658b commit 516f7f9

File tree

1 file changed

+38
-32
lines changed

1 file changed

+38
-32
lines changed

scripts/template_setup_posix

Lines changed: 38 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,11 @@ check_command()
4848
fi
4949
}
5050

51-
# Check if the current installation is a full SDK with all toolchains
51+
# Check if the current installation is a full SDK with all GNU toolchains
5252
check_full_sdk()
5353
{
54-
for toolchain in ${toolchains[@]}; do
55-
if [ ! -d "${toolchain}" ]; then
54+
for toolchain in ${gnu_toolchains[@]}; do
55+
if [ ! -d "gnu/${toolchain}" ]; then
5656
return 1
5757
fi
5858
done
@@ -63,16 +63,16 @@ check_full_sdk()
6363
# Display script usage
6464
usage()
6565
{
66-
echo "Usage: $(basename $0) [-t <toolchain>] [-h] [-c]"
66+
echo "Usage: $(basename $0) [-t <gnu_toolchain>] [-h] [-c]"
6767
echo
68-
echo " -t <toolchain> Install specified toolchain"
69-
echo " all Install all toolchains"
70-
echo " -h Install host tools"
71-
echo " -c Register Zephyr SDK CMake package"
68+
echo " -t <gnu_toolchain> Install specified GNU toolchain"
69+
echo " all Install all GNU toolchains"
70+
echo " -h Install host tools"
71+
echo " -c Register Zephyr SDK CMake package"
7272
echo
73-
echo "Supported Toolchains:"
73+
echo "Supported GNU Toolchains:"
7474
echo
75-
for toolchain in ${toolchains[@]}; do
75+
for toolchain in ${gnu_toolchains[@]}; do
7676
echo " ${toolchain}"
7777
done
7878
echo
@@ -88,16 +88,16 @@ user_prompt()
8888
echo "distribution bundle archive."
8989
echo
9090

91-
# Toolchains
91+
# GNU Toolchains
9292
check_full_sdk
9393
if [ $? != 0 ]; then
94-
ask_yn "Install toolchains for all targets"
94+
ask_yn "Install GNU toolchains for all targets"
9595
if [ $? == 0 ]; then
96-
inst_toolchains=(${toolchains[*]})
96+
inst_gnu_toolchains=(${gnu_toolchains[*]})
9797
else
98-
for toolchain in ${toolchains[@]}; do
99-
if [ ! -d "${toolchain}" ]; then
100-
ask_yn "Install '${toolchain}' toolchain" && inst_toolchains+=("${toolchain}")
98+
for toolchain in ${gnu_toolchains[@]}; do
99+
if [ ! -d "gnu/${toolchain}" ]; then
100+
ask_yn "Install '${toolchain}' GNU toolchain" && inst_gnu_toolchains+=("${toolchain}")
101101
fi
102102
done
103103
fi
@@ -115,12 +115,12 @@ user_prompt()
115115
# Entry point
116116
pushd "$(dirname "${BASH_SOURCE[0]}")"
117117

118-
# Initialise toolchain list
119-
toolchains=$(<sdk_toolchains)
120-
toolchains=("${toolchains[@]//$'\n'/ }")
118+
# Initialise GNU toolchain list
119+
gnu_toolchains=$(<sdk_gnu_toolchains)
120+
gnu_toolchains=("${gnu_toolchains[@]//$'\n'/ }")
121121

122-
# Initialise list of toolchains to install
123-
inst_toolchains=()
122+
# Initialise list of GNU toolchains to install
123+
inst_gnu_toolchains=()
124124

125125
# Parse arguments
126126
if [ $# == "0" ]; then
@@ -131,12 +131,12 @@ else
131131
-t)
132132
shift
133133
if [[ "$1" = "all" ]]; then
134-
inst_toolchains=(${toolchains[*]})
134+
inst_gnu_toolchains=(${gnu_toolchains[*]})
135135
else
136-
if [[ " ${toolchains[*]} " =~ " $1 " ]]; then
137-
inst_toolchains+=("$1")
136+
if [[ " ${gnu_toolchains[*]} " =~ " $1 " ]]; then
137+
inst_gnu_toolchains+=("$1")
138138
else
139-
echo "ERROR: Unknown toolchain '$1'"
139+
echo "ERROR: Unknown GNU toolchain '$1'"
140140
exit 2
141141
fi
142142
fi
@@ -186,7 +186,7 @@ esac
186186

187187
# Resolve release download base URI
188188
dl_rel_base="https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v${version}"
189-
dl_toolchain_filename='toolchain_${host}_${toolchain}.tar.xz'
189+
dl_gnu_toolchain_filename='toolchain_gnu_${host}_${toolchain}.tar.xz'
190190

191191
# Print banner
192192
echo "Zephyr SDK ${version} Setup"
@@ -202,43 +202,49 @@ if [ "${interactive}" = "y" ]; then
202202
user_prompt
203203
fi
204204

205-
# Install toolchains
206-
for toolchain in ${inst_toolchains[@]}; do
207-
eval toolchain_filename="${dl_toolchain_filename}"
205+
# Install GNU toolchains
206+
mkdir -p gnu
207+
pushd gnu
208+
209+
for toolchain in ${inst_gnu_toolchains[@]}; do
210+
eval toolchain_filename="${dl_gnu_toolchain_filename}"
208211
toolchain_uri="${dl_rel_base}/${toolchain_filename}"
209212

210213
# Skip if toolchain directory already exists
211214
if [ -d "${toolchain}" ]; then
212215
continue
213216
fi
214217

215-
echo "Installing '${toolchain}' toolchain ..."
218+
echo "Installing '${toolchain}' GNU toolchain ..."
216219

217220
# Download toolchain archive
218221
wget -q --show-progress -N -O "${toolchain_filename}" "${toolchain_uri}"
219222
if [ $? != 0 ]; then
220223
rm -f "${toolchain_filename}"
221-
echo "ERROR: Toolchain download failed"
224+
echo "ERROR: GNU toolchain download failed"
222225
exit 20
223226
fi
224227

225228
# Extract archive
226229
tar xf "${toolchain_filename}"
227-
assert_rc "ERROR: Toolchain archive extraction failed" 21
230+
assert_rc "ERROR: GNU toolchain archive extraction failed" 21
228231

229232
# Remove archive
230233
rm -f "${toolchain_filename}"
231234

232235
echo
233236
done
237+
popd
234238

235239
# Install host tools
236240
if [ "${do_hosttools}" = "y" ]; then
237241
echo "Installing host tools ..."
238242
case ${host} in
239243
linux-*)
244+
pushd hosttools
240245
./zephyr-sdk-${HOSTTYPE}-hosttools-standalone-0.9.sh -y -d . &> /dev/null
241246
assert_rc "ERROR: Host tools installation failed" 30
247+
popd
242248
;;
243249
macos-*)
244250
echo "SKIPPED: macOS host tools are not available yet."

0 commit comments

Comments
 (0)