mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-04 21:24:32 +02:00
Merge branch 'bugfix/export_path_checks' into 'master'
tools: export script improvements Closes IDFGH-2277 See merge request espressif/esp-idf!8224
This commit is contained in:
@@ -31,7 +31,8 @@ function idf_export_main
|
|||||||
# "$IDF_PATH"/tools is already added by 'idf_tools.py export'
|
# "$IDF_PATH"/tools is already added by 'idf_tools.py export'
|
||||||
set IDF_ADD_PATHS_EXTRAS "$IDF_PATH"/components/esptool_py/esptool
|
set IDF_ADD_PATHS_EXTRAS "$IDF_PATH"/components/esptool_py/esptool
|
||||||
set IDF_ADD_PATHS_EXTRAS "$IDF_ADD_PATHS_EXTRAS":"$IDF_PATH"/components/espcoredump
|
set IDF_ADD_PATHS_EXTRAS "$IDF_ADD_PATHS_EXTRAS":"$IDF_PATH"/components/espcoredump
|
||||||
set IDF_ADD_PATHS_EXTRAS "$IDF_ADD_PATHS_EXTRAS":"$IDF_PATH"/components/partition_table/
|
set IDF_ADD_PATHS_EXTRAS "$IDF_ADD_PATHS_EXTRAS":"$IDF_PATH"/components/partition_table
|
||||||
|
set IDF_ADD_PATHS_EXTRAS "$IDF_ADD_PATHS_EXTRAS":"$IDF_PATH"/components/app_update
|
||||||
set -x PATH "$IDF_ADD_PATHS_EXTRAS":"$PATH"
|
set -x PATH "$IDF_ADD_PATHS_EXTRAS":"$PATH"
|
||||||
|
|
||||||
set added_path_variables
|
set added_path_variables
|
||||||
|
54
export.sh
54
export.sh
@@ -23,23 +23,54 @@ function idf_export_main() {
|
|||||||
|
|
||||||
if [[ -z "${IDF_PATH}" ]]
|
if [[ -z "${IDF_PATH}" ]]
|
||||||
then
|
then
|
||||||
# If using bash, try to guess IDF_PATH from script location
|
# IDF_PATH not set in the environment.
|
||||||
|
# If using bash or zsh, try to guess IDF_PATH from script location.
|
||||||
|
self_path=""
|
||||||
if [[ -n "${BASH_SOURCE}" ]]
|
if [[ -n "${BASH_SOURCE}" ]]
|
||||||
then
|
then
|
||||||
if [[ "$OSTYPE" == "darwin"* ]]; then
|
self_path="${BASH_SOURCE}"
|
||||||
script_dir="$(realpath_int $BASH_SOURCE)"
|
elif [[ -n "${ZSH_VERSION}" ]]
|
||||||
else
|
then
|
||||||
script_name="$(readlink -f $BASH_SOURCE)"
|
self_path="${(%):-%x}"
|
||||||
script_dir="$(dirname $script_name)"
|
|
||||||
fi
|
|
||||||
export IDF_PATH="${script_dir}"
|
|
||||||
else
|
else
|
||||||
echo "IDF_PATH must be set before sourcing this script"
|
echo "Could not detect IDF_PATH. Please set it before sourcing this script:"
|
||||||
|
echo " export IDF_PATH=(add path here)"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [[ "$OSTYPE" == "darwin"* ]]; then
|
||||||
|
# convert possibly relative path to absolute
|
||||||
|
script_dir="$(realpath_int ${self_path})"
|
||||||
|
# resolve any ../ references to make the path shorter
|
||||||
|
script_dir="$(cd ${script_dir}; pwd)"
|
||||||
|
else
|
||||||
|
# convert to full path and get the directory name of that
|
||||||
|
script_name="$(readlink -f ${self_path})"
|
||||||
|
script_dir="$(dirname ${script_name})"
|
||||||
|
fi
|
||||||
|
export IDF_PATH="${script_dir}"
|
||||||
|
echo "Setting IDF_PATH to '${IDF_PATH}'"
|
||||||
|
else
|
||||||
|
# IDF_PATH came from the environment, check if the path is valid
|
||||||
|
if [[ ! -d "${IDF_PATH}" ]]
|
||||||
|
then
|
||||||
|
echo "IDF_PATH is set to '${IDF_PATH}', but it is not a valid directory."
|
||||||
|
echo "If you have set IDF_PATH manually, check if the path is correct."
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
# Check if this path looks like an IDF directory
|
||||||
|
if [[ ! -f "${IDF_PATH}/tools/idf.py" || ! -f "${IDF_PATH}/tools/idf_tools.py" ]]
|
||||||
|
then
|
||||||
|
echo "IDF_PATH is set to '${IDF_PATH}', but it doesn't look like an ESP-IDF directory."
|
||||||
|
echo "If you have set IDF_PATH manually, check if the path is correct."
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# The varible might have been set (rather than exported), re-export it to be sure
|
||||||
|
export IDF_PATH="${IDF_PATH}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
old_path=$PATH
|
old_path="$PATH"
|
||||||
|
|
||||||
echo "Adding ESP-IDF tools to PATH..."
|
echo "Adding ESP-IDF tools to PATH..."
|
||||||
# Call idf_tools.py to export tool paths
|
# Call idf_tools.py to export tool paths
|
||||||
@@ -56,7 +87,8 @@ function idf_export_main() {
|
|||||||
# ${IDF_PATH}/tools is already added by 'idf_tools.py export'
|
# ${IDF_PATH}/tools is already added by 'idf_tools.py export'
|
||||||
IDF_ADD_PATHS_EXTRAS="${IDF_PATH}/components/esptool_py/esptool"
|
IDF_ADD_PATHS_EXTRAS="${IDF_PATH}/components/esptool_py/esptool"
|
||||||
IDF_ADD_PATHS_EXTRAS="${IDF_ADD_PATHS_EXTRAS}:${IDF_PATH}/components/espcoredump"
|
IDF_ADD_PATHS_EXTRAS="${IDF_ADD_PATHS_EXTRAS}:${IDF_PATH}/components/espcoredump"
|
||||||
IDF_ADD_PATHS_EXTRAS="${IDF_ADD_PATHS_EXTRAS}:${IDF_PATH}/components/partition_table/"
|
IDF_ADD_PATHS_EXTRAS="${IDF_ADD_PATHS_EXTRAS}:${IDF_PATH}/components/partition_table"
|
||||||
|
IDF_ADD_PATHS_EXTRAS="${IDF_ADD_PATHS_EXTRAS}:${IDF_PATH}/components/app_update"
|
||||||
export PATH="${IDF_ADD_PATHS_EXTRAS}:${PATH}"
|
export PATH="${IDF_ADD_PATHS_EXTRAS}:${PATH}"
|
||||||
|
|
||||||
if [[ -n "$BASH" ]]
|
if [[ -n "$BASH" ]]
|
||||||
|
Reference in New Issue
Block a user