Skip to content

Commit

Permalink
CI: extend env2cmake() to exit if a variable is not defined
Browse files Browse the repository at this point in the history
  • Loading branch information
SimeonEhrig committed Sep 2, 2024
1 parent 032e98c commit b45ddd6
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion script/run_generate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,24 @@ echo_green "<SCRIPT: run_generate>"
#
# @param $1 cmake/environment variable name
#
# @result if $1 exists cmake variable definition else nothing is returned
# @result if $1 exists cmake variable definition else nothing is returned. If variable is not
# defined, the script will be exited.
#
# @code{.bash}
# FOO=ON
# BAR=""
# echo "$(env2cmake FOO)" # returns "-DFOO=ON"
# echo "$(env2cmake BAR)" # returns nothing
# echo "$(env2cmake FOOBAR)" # exit 1
# @endcode
function env2cmake()
{
# check if variable is definded
if [ -z ${!1+x} ]; then
kill -SIGTERM $$
fi

# return only content of variable is not empty
if [ ! -z "${!1}" ] ; then
echo -n "-D$1=${!1}"
fi
Expand Down

0 comments on commit b45ddd6

Please sign in to comment.