1 # This script should be sourced, not executed.
3 function idf_export_main() {
4 # The file doesn't have executable permissions, so this shouldn't really happen.
5 # Doing this in case someone tries to chmod +x it and execute...
6 if [[ -n "${BASH_SOURCE}" && ( "${BASH_SOURCE[0]}" == "${0}" ) ]]; then
7 echo "This script should be sourced, not executed:"
8 echo ". ${BASH_SOURCE[0]}"
12 if [[ -z "${IDF_PATH}" ]]
14 # If using bash, try to guess IDF_PATH from script location
15 if [[ -n "${BASH_SOURCE}" ]]
17 script_name="$(readlink -f $BASH_SOURCE)"
18 export IDF_PATH="$(dirname ${script_name})"
20 echo "IDF_PATH must be set before sourcing this script"
27 echo "Adding ESP-IDF tools to PATH..."
28 # Call idf_tools.py to export tool paths
29 export IDF_TOOLS_EXPORT_CMD=${IDF_PATH}/export.sh
30 export IDF_TOOLS_INSTALL_CMD=${IDF_PATH}/install.sh
31 idf_exports=$(${IDF_PATH}/tools/idf_tools.py export) || return 1
34 echo "Checking if Python packages are up to date..."
35 python ${IDF_PATH}/tools/check_python_dependencies.py || return 1
38 # Allow calling some IDF python tools without specifying the full path
39 # ${IDF_PATH}/tools is already added by 'idf_tools.py export'
40 IDF_ADD_PATHS_EXTRAS="${IDF_PATH}/components/esptool_py/esptool"
41 IDF_ADD_PATHS_EXTRAS="${IDF_ADD_PATHS_EXTRAS}:${IDF_PATH}/components/espcoredump"
42 IDF_ADD_PATHS_EXTRAS="${IDF_ADD_PATHS_EXTRAS}:${IDF_PATH}/components/partition_table/"
43 export PATH="${IDF_ADD_PATHS_EXTRAS}:${PATH}"
47 path_prefix=${PATH%%${old_path}}
48 paths="${path_prefix//:/ }"
49 if [ -n "${paths}" ]; then
50 echo "Added the following directories to PATH:"
52 echo "All paths are already set."
54 for path_entry in ${paths}
59 echo "Updated PATH variable:"
68 unset IDF_ADD_PATHS_EXTRAS
70 # Not unsetting IDF_PYTHON_ENV_PATH, it can be used by IDF build system
71 # to check whether we are using a private Python environment
73 echo "Done! You can now compile ESP-IDF projects."
74 echo "Go to the project directory and run:"