Skip to content

Commit 953f91f

Browse files
alexeicolingalak
authored andcommitted
scripts/template_dir: -[no]cmake flag for CMake module installation
There are two issues with CMake module installation that are problematic for distro packages: 1. the cmake module is installed under $HOME and this path is not overridable 2. the path to SDK recorded in the cmake file is the same as the target directory, which might be prefixed by the staging path of the package build (e.g. ~/mypackages/zerphyr-sdk/destdir/opt/zerphyr-sdk), not the final installation directory in the system (/opt/zephyr-sdk). 1 is fixable by making the variable overridable from the environment: : ${ZEPHYR_SDK_REGISTRY_DIR:=$HOME/.cmake/packages/Zephyr-sdk} (but this may be a bashism). But, 1 is not useful unless 2 is also addressed. 2 might be fixable by introducing a prefix argument -p (default "") in addition to the target_dir (-d), and composing the destination directory for copying files as $prefix/$target_dir while using only $target_dir wherever installation paths are written, such as in the CMake module. Until 1 or 2 are addressed, add -[no]cmake arg so that the package scripts can install the CMake module themselves.
1 parent e821052 commit 953f91f

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

scripts/template_dir

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ target_sdk_dir=""
33
post_install_cleanup=1
44
confirm=0
55
rc_confirm=""
6+
cmake_confirm=""
67

78
usage () {
89
cat << EOF
@@ -22,6 +23,9 @@ Options:
2223
-[no]rc
2324
Whether to create/update the ~/.zerphyrc file (prompt if not given)
2425

26+
-[no]cmake
27+
Whether to install Zephyr-sdk CMake module (prompt if not given)
28+
2529
EOF
2630
}
2731

@@ -69,13 +73,22 @@ while [ "$1" != "" ]; do
6973
if [ -z "$rc_confirm" ]; then
7074
rc_confirm="y"
7175
fi
76+
if [ -z "$cmake_confirm" ]; then
77+
cmake_confirm="y"
78+
fi
7279
;;
7380
-rc )
7481
rc_confirm="y";
7582
;;
7683
-norc )
7784
rc_confirm="n";
7885
;;
86+
-cmake )
87+
cmake_confirm="y"
88+
;;
89+
-nocmake )
90+
cmake_confirm="n"
91+
;;
7992
* )
8093
echo "Error: Invalid argument \"$1\""
8194
usage
@@ -158,8 +171,11 @@ do_cmake_package()
158171
return
159172
fi
160173

161-
query "registering Zephyr-sdk CMake module with path $target_sdk_dir "
162-
if [ "$answer" = "y" ]; then
174+
if [ -z "$cmake_confirm" ]; then
175+
prompt "registering Zephyr-sdk CMake module with path $target_sdk_dir "
176+
cmake_confirm=$answer
177+
fi
178+
if [ "$cmake_confirm" = "y" ]; then
163179
if [ ! -d $ZEPHYR_SDK_REGISTRY_DIR ]; then
164180
mkdir -p $ZEPHYR_SDK_REGISTRY_DIR
165181
fi

0 commit comments

Comments
 (0)