Skip to content

Commit

Permalink
fix(tools): Enable to use IDF_PATH with export.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
Marek Fiala committed Dec 18, 2024
1 parent 40d450d commit dd31a41
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions export.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,40 @@ idf_path="."
shell_type="detect"

# shellcheck disable=SC2128,SC2169,SC2039,SC3054,SC3028 # ignore array expansion warning
if test -n "${BASH_SOURCE-}"
if [ -n "${BASH_SOURCE-}" ]
then
# shellcheck disable=SC3028,SC3054 # unreachable with 'dash'
idf_path=$(dirname "${BASH_SOURCE[0]}")
shell_type="bash"
elif test -n "${ZSH_VERSION-}"
elif [ -n "${ZSH_VERSION-}" ]
then
# shellcheck disable=SC2296 # ignore parameter starts with '{' because it's zsh
idf_path=$(dirname "${(%):-%x}")
shell_type="zsh"
elif [ -n "${IDF_PATH-}" ]
then
if [ -f "/.dockerenv" ]
then
echo "Using the IDF_PATH found in the environment as docker environment detected."
idf_path=$IDF_PATH
elif [ -n "${IDF_PATH_FORCE-}" ]
then
echo "Using the forced IDF_PATH found in the environment."
idf_path=$IDF_PATH
fi
fi

if [ ! -f "${idf_path}/tools/idf.py" ] ||
[ ! -f "${idf_path}/tools/idf_tools.py" ] ||
[ ! -f "${idf_path}/tools/activate.py" ]
then
echo "Could not detect IDF_PATH. Please navigate to your ESP-IDF directory and run:"
echo "Could not automatically detect IDF_PATH from script location. Please navigate to your ESP-IDF directory and run:"
echo ". ./export.sh"
if [ -n "${IDF_PATH-}" ]
then
echo
echo "To use the IDF_PATH set in the environment, you can enforce it by setting 'export IDF_PATH_FORCE=1'"
fi
unset idf_path
return 1
fi
Expand Down

0 comments on commit dd31a41

Please sign in to comment.