|
@@ -1,6 +1,6 @@
|
|
|
# This script should be sourced, not executed.
|
|
# This script should be sourced, not executed.
|
|
|
|
|
|
|
|
-realpath_int() {
|
|
|
|
|
|
|
+__realpath() {
|
|
|
wdir="$PWD"; [ "$PWD" = "/" ] && wdir=""
|
|
wdir="$PWD"; [ "$PWD" = "/" ] && wdir=""
|
|
|
arg=$1
|
|
arg=$1
|
|
|
case "$arg" in
|
|
case "$arg" in
|
|
@@ -12,7 +12,12 @@ realpath_int() {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
-idf_export_main() {
|
|
|
|
|
|
|
+__verbose() {
|
|
|
|
|
+ [ -n "${IDF_EXPORT_QUIET}" ] && return
|
|
|
|
|
+ echo "$@"
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+__main() {
|
|
|
# The file doesn't have executable permissions, so this shouldn't really happen.
|
|
# The file doesn't have executable permissions, so this shouldn't really happen.
|
|
|
# Doing this in case someone tries to chmod +x it and execute...
|
|
# Doing this in case someone tries to chmod +x it and execute...
|
|
|
|
|
|
|
@@ -82,15 +87,15 @@ idf_export_main() {
|
|
|
echo "Detecting the Python interpreter"
|
|
echo "Detecting the Python interpreter"
|
|
|
. "${IDF_PATH}/tools/detect_python.sh"
|
|
. "${IDF_PATH}/tools/detect_python.sh"
|
|
|
|
|
|
|
|
- echo "Adding ESP-IDF tools to PATH..."
|
|
|
|
|
|
|
+ __verbose "Adding ESP-IDF tools to PATH..."
|
|
|
# Call idf_tools.py to export tool paths
|
|
# Call idf_tools.py to export tool paths
|
|
|
export IDF_TOOLS_EXPORT_CMD=${IDF_PATH}/export.sh
|
|
export IDF_TOOLS_EXPORT_CMD=${IDF_PATH}/export.sh
|
|
|
export IDF_TOOLS_INSTALL_CMD=${IDF_PATH}/install.sh
|
|
export IDF_TOOLS_INSTALL_CMD=${IDF_PATH}/install.sh
|
|
|
idf_exports=$("$ESP_PYTHON" "${IDF_PATH}/tools/idf_tools.py" export) || return 1
|
|
idf_exports=$("$ESP_PYTHON" "${IDF_PATH}/tools/idf_tools.py" export) || return 1
|
|
|
eval "${idf_exports}"
|
|
eval "${idf_exports}"
|
|
|
|
|
|
|
|
- echo "Using Python interpreter in $(which python)"
|
|
|
|
|
- echo "Checking if Python packages are up to date..."
|
|
|
|
|
|
|
+ __verbose "Using Python interpreter in $(which python)"
|
|
|
|
|
+ __verbose "Checking if Python packages are up to date..."
|
|
|
python "${IDF_PATH}/tools/check_python_dependencies.py" || return 1
|
|
python "${IDF_PATH}/tools/check_python_dependencies.py" || return 1
|
|
|
|
|
|
|
|
|
|
|
|
@@ -108,20 +113,28 @@ idf_export_main() {
|
|
|
# shellcheck disable=SC2169,SC2039 # unreachable with 'dash'
|
|
# shellcheck disable=SC2169,SC2039 # unreachable with 'dash'
|
|
|
paths="${path_prefix//:/ }"
|
|
paths="${path_prefix//:/ }"
|
|
|
if [ -n "${paths}" ]; then
|
|
if [ -n "${paths}" ]; then
|
|
|
- echo "Added the following directories to PATH:"
|
|
|
|
|
|
|
+ __verbose "Added the following directories to PATH:"
|
|
|
else
|
|
else
|
|
|
- echo "All paths are already set."
|
|
|
|
|
|
|
+ __verbose "All paths are already set."
|
|
|
fi
|
|
fi
|
|
|
for path_entry in ${paths}
|
|
for path_entry in ${paths}
|
|
|
do
|
|
do
|
|
|
- echo " ${path_entry}"
|
|
|
|
|
|
|
+ __verbose " ${path_entry}"
|
|
|
done
|
|
done
|
|
|
else
|
|
else
|
|
|
- echo "Updated PATH variable:"
|
|
|
|
|
- echo " ${PATH}"
|
|
|
|
|
|
|
+ __verbose "Updated PATH variable:"
|
|
|
|
|
+ __verbose " ${PATH}"
|
|
|
fi
|
|
fi
|
|
|
|
|
|
|
|
- # Clean up
|
|
|
|
|
|
|
+
|
|
|
|
|
+ __verbose "Done! You can now compile ESP-IDF projects."
|
|
|
|
|
+ __verbose "Go to the project directory and run:"
|
|
|
|
|
+ __verbose ""
|
|
|
|
|
+ __verbose " idf.py build"
|
|
|
|
|
+ __verbose ""
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+__cleanup() {
|
|
|
unset old_path
|
|
unset old_path
|
|
|
unset paths
|
|
unset paths
|
|
|
unset path_prefix
|
|
unset path_prefix
|
|
@@ -129,18 +142,23 @@ idf_export_main() {
|
|
|
unset IDF_ADD_PATHS_EXTRAS
|
|
unset IDF_ADD_PATHS_EXTRAS
|
|
|
unset idf_exports
|
|
unset idf_exports
|
|
|
unset ESP_PYTHON
|
|
unset ESP_PYTHON
|
|
|
|
|
+ unset SOURCE_ZSH
|
|
|
|
|
+ unset SOURCE_BASH
|
|
|
|
|
+
|
|
|
|
|
+ unset __realpath
|
|
|
|
|
+ unset __main
|
|
|
|
|
+ unset __verbose
|
|
|
|
|
+ unset __enable_autocomplete
|
|
|
|
|
+ unset __cleanup
|
|
|
|
|
|
|
|
# Not unsetting IDF_PYTHON_ENV_PATH, it can be used by IDF build system
|
|
# Not unsetting IDF_PYTHON_ENV_PATH, it can be used by IDF build system
|
|
|
# to check whether we are using a private Python environment
|
|
# to check whether we are using a private Python environment
|
|
|
|
|
|
|
|
- echo "Done! You can now compile ESP-IDF projects."
|
|
|
|
|
- echo "Go to the project directory and run:"
|
|
|
|
|
- echo ""
|
|
|
|
|
- echo " idf.py build"
|
|
|
|
|
- echo ""
|
|
|
|
|
|
|
+ return $1
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-enable_autocomplete() {
|
|
|
|
|
|
|
+
|
|
|
|
|
+__enable_autocomplete() {
|
|
|
click_version="$(python -c 'import click; print(click.__version__.split(".")[0])')"
|
|
click_version="$(python -c 'import click; print(click.__version__.split(".")[0])')"
|
|
|
if [[ click_version -lt 8 ]]
|
|
if [[ click_version -lt 8 ]]
|
|
|
then
|
|
then
|
|
@@ -158,15 +176,7 @@ enable_autocomplete() {
|
|
|
then
|
|
then
|
|
|
eval "$(env LANG=en _IDF.PY_COMPLETE=$SOURCE_BASH idf.py)" || echo "WARNING: Failed to load shell autocompletion for bash version: $BASH_VERSION!"
|
|
eval "$(env LANG=en _IDF.PY_COMPLETE=$SOURCE_BASH idf.py)" || echo "WARNING: Failed to load shell autocompletion for bash version: $BASH_VERSION!"
|
|
|
fi
|
|
fi
|
|
|
-
|
|
|
|
|
- unset SOURCE_ZSH
|
|
|
|
|
- unset SOURCE_BASH
|
|
|
|
|
-
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-idf_export_main
|
|
|
|
|
-enable_autocomplete
|
|
|
|
|
-
|
|
|
|
|
-unset realpath_int
|
|
|
|
|
-unset idf_export_main
|
|
|
|
|
-unset enable_autocomplete
|
|
|
|
|
|
|
+__main && __enable_autocomplete
|
|
|
|
|
+__cleanup $?
|