From 706b10cddfd781e3c7f1006a64ad23e09601e77c Mon Sep 17 00:00:00 2001 From: Alexei Colin Date: Sat, 18 Jul 2020 12:18:20 -0400 Subject: [PATCH 4/4] 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. --- scripts/template_dir | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/scripts/template_dir b/scripts/template_dir index 0a0d69e..fccf6f0 100644 --- a/scripts/template_dir +++ b/scripts/template_dir @@ -3,6 +3,7 @@ target_sdk_dir="" post_install_cleanup=1 confirm=0 rc_confirm="" +cmake_confirm="" usage () { cat << EOF @@ -22,6 +23,9 @@ Options: -[no]rc Whether to create/update the ~/.zerphyrc file (prompt if not given) + -[no]cmake + Whether to install Zephyr-sdk CMake module (prompt if not given) + EOF } @@ -69,6 +73,9 @@ while [ "$1" != "" ]; do if [ -z "$rc_confirm" ]; then rc_confirm="y" fi + if [ -z "$cmake_confirm" ]; then + cmake_confirm="y" + fi ;; -rc ) rc_confirm="y"; @@ -76,6 +83,12 @@ while [ "$1" != "" ]; do -norc ) rc_confirm="n"; ;; + -cmake ) + cmake_confirm="y" + ;; + -nocmake ) + cmake_confirm="n" + ;; * ) echo "Error: Invalid argument \"$1\"" usage @@ -158,8 +171,11 @@ do_cmake_package() return fi - query "registering Zephyr-sdk CMake module with path $target_sdk_dir " - if [ "$answer" = "y" ]; then + if [ -z "$cmake_confirm" ]; then + prompt "registering Zephyr-sdk CMake module with path $target_sdk_dir " + cmake_confirm=$answer + fi + if [ "$cmake_confirm" = "y" ]; then if [ ! -d $ZEPHYR_SDK_REGISTRY_DIR ]; then mkdir -p $ZEPHYR_SDK_REGISTRY_DIR fi -- 2.27.0