Skip to content

Commit 9e334cd

Browse files
tejlmandgalak
authored andcommitted
cmake: CMake package registry in setup script
The template_dir has been updated with a do_cmake_package. The do_cmake_package allows users who install the Zephyr SDK in a non-recommended directory to still have the setup script to generate an entry for the install directory in the CMake Package registry. This is optional for user's, which gives full flexibility of downloading and installing the SDK without having it being used automatically. Signed-off-by: Torsten Rasmussen <[email protected]>
1 parent 3d98719 commit 9e334cd

File tree

1 file changed

+34
-1
lines changed

1 file changed

+34
-1
lines changed

scripts/template_dir

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,38 @@ do_zephyrrc()
148148
fi
149149
}
150150

151+
do_cmake_package()
152+
{
153+
ZEPHYR_SDK_REGISTRY_DIR=$HOME/.cmake/packages/Zephyr-sdk
154+
155+
type md5sum
156+
if [ $? -eq 0 ]; then
157+
reg_file=$ZEPHYR_SDK_REGISTRY_DIR/`echo -n $target_sdk_dir | md5sum | cut -d' ' -f1`
158+
159+
if [ -e $reg_file ]; then
160+
# The install dir is already in CMake package registry so simply return.
161+
return
162+
fi
163+
164+
echo "Do you want to register the Zephyr-sdk at location: $target_sdk_dir"
165+
echo " in the CMake package registry (y/n)?"
166+
167+
while read confirm; do
168+
[ "$confirm" = "Y" -o "$confirm" = "y" -o "$confirm" = "n" \
169+
-o "$confirm" = "N" ] && break
170+
echo "Invalid input \"$confirm\", please input 'y' or 'n': "
171+
done
172+
173+
if [ "$confirm" = "y" -o "$confirm" = "Y" ]; then
174+
if [ ! -d $ZEPHYR_SDK_REGISTRY_DIR ]; then
175+
mkdir -p $ZEPHYR_SDK_REGISTRY_DIR
176+
fi
177+
echo "$target_sdk_dir" > $reg_file
178+
echo "$target_sdk_dir registered in $reg_file"
179+
fi
180+
fi
181+
}
182+
151183
# Read the input "y"
152184
# $1 is optional, but allows the caller to provide additional text.
153185
read_confirm () {
@@ -201,7 +233,7 @@ if [ -n "$(echo $target_sdk_dir|grep ' ')" ]; then
201233
exit 1
202234
fi
203235

204-
# Verify that the install forlder is among the default search paths for CMake.
236+
# Verify that the install folder is among the default search paths for CMake.
205237
# If not, prompt the user before continue, and create ~/.zephyrrc
206238
eval sdk_dirname=$(dirname "$target_sdk_dir")
207239
eval sdk_basename=$(basename "$target_sdk_dir")
@@ -230,6 +262,7 @@ if [ "$sdk_dirname" != "/opt" \
230262
echo "SDK installation aborted!"
231263
exit 1
232264
fi
265+
do_cmake_package
233266
create_zephyrrc=true
234267
fi
235268

0 commit comments

Comments
 (0)