Skip to content

Commit dd31a41

Browse files
author
Marek Fiala
committed
fix(tools): Enable to use IDF_PATH with export.sh
1 parent 40d450d commit dd31a41

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

export.sh

+19-3
Original file line numberDiff line numberDiff line change
@@ -22,24 +22,40 @@ idf_path="."
2222
shell_type="detect"
2323

2424
# shellcheck disable=SC2128,SC2169,SC2039,SC3054,SC3028 # ignore array expansion warning
25-
if test -n "${BASH_SOURCE-}"
25+
if [ -n "${BASH_SOURCE-}" ]
2626
then
2727
# shellcheck disable=SC3028,SC3054 # unreachable with 'dash'
2828
idf_path=$(dirname "${BASH_SOURCE[0]}")
2929
shell_type="bash"
30-
elif test -n "${ZSH_VERSION-}"
30+
elif [ -n "${ZSH_VERSION-}" ]
3131
then
3232
# shellcheck disable=SC2296 # ignore parameter starts with '{' because it's zsh
3333
idf_path=$(dirname "${(%):-%x}")
3434
shell_type="zsh"
35+
elif [ -n "${IDF_PATH-}" ]
36+
then
37+
if [ -f "/.dockerenv" ]
38+
then
39+
echo "Using the IDF_PATH found in the environment as docker environment detected."
40+
idf_path=$IDF_PATH
41+
elif [ -n "${IDF_PATH_FORCE-}" ]
42+
then
43+
echo "Using the forced IDF_PATH found in the environment."
44+
idf_path=$IDF_PATH
45+
fi
3546
fi
3647

3748
if [ ! -f "${idf_path}/tools/idf.py" ] ||
3849
[ ! -f "${idf_path}/tools/idf_tools.py" ] ||
3950
[ ! -f "${idf_path}/tools/activate.py" ]
4051
then
41-
echo "Could not detect IDF_PATH. Please navigate to your ESP-IDF directory and run:"
52+
echo "Could not automatically detect IDF_PATH from script location. Please navigate to your ESP-IDF directory and run:"
4253
echo ". ./export.sh"
54+
if [ -n "${IDF_PATH-}" ]
55+
then
56+
echo
57+
echo "To use the IDF_PATH set in the environment, you can enforce it by setting 'export IDF_PATH_FORCE=1'"
58+
fi
4359
unset idf_path
4460
return 1
4561
fi

0 commit comments

Comments
 (0)