mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
tools: bugfix export.sh change IDF_PATH only if file is esp-idf
Set the self_path where the export.sh script is located, not the sourcing directory.
This commit is contained in:
parent
e3c084a2dc
commit
029de43db3
@ -16,6 +16,8 @@ function __main
|
|||||||
set script_dir $pwd
|
set script_dir $pwd
|
||||||
end
|
end
|
||||||
if test "$IDF_PATH" != "$script_dir"
|
if test "$IDF_PATH" != "$script_dir"
|
||||||
|
# Change IDF_PATH is important when there are 2 ESP-IDF versions in different directories.
|
||||||
|
# Sourcing this script without change, would cause sourcing wrong export script.
|
||||||
echo "Resetting IDF_PATH from '$IDF_PATH' to '$script_dir'"
|
echo "Resetting IDF_PATH from '$IDF_PATH' to '$script_dir'"
|
||||||
set IDF_PATH "$script_dir"
|
set IDF_PATH "$script_dir"
|
||||||
end
|
end
|
||||||
|
43
export.sh
43
export.sh
@ -49,42 +49,37 @@ __main() {
|
|||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# If using bash or zsh, try to guess IDF_PATH from script location.
|
||||||
|
self_path=""
|
||||||
|
# shellcheck disable=SC2128 # ignore array expansion warning
|
||||||
|
if [ -n "${BASH_SOURCE-}" ]
|
||||||
|
then
|
||||||
|
self_path="${BASH_SOURCE}"
|
||||||
|
elif [ -n "${ZSH_VERSION-}" ]
|
||||||
|
then
|
||||||
|
self_path="${(%):-%x}"
|
||||||
|
else
|
||||||
|
echo "Could not detect IDF_PATH. Please set it before sourcing this script:"
|
||||||
|
echo " export IDF_PATH=(add path here)"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
script_dir=$(__script_dir)
|
||||||
|
|
||||||
if [ -z "${IDF_PATH}" ]
|
if [ -z "${IDF_PATH}" ]
|
||||||
then
|
then
|
||||||
# IDF_PATH not set in the environment.
|
# IDF_PATH not set in the environment.
|
||||||
# If using bash or zsh, try to guess IDF_PATH from script location.
|
|
||||||
self_path=""
|
|
||||||
|
|
||||||
# shellcheck disable=SC2128 # ignore array expansion warning
|
|
||||||
if [ -n "${BASH_SOURCE-}" ]
|
|
||||||
then
|
|
||||||
self_path="${BASH_SOURCE}"
|
|
||||||
elif [ -n "${ZSH_VERSION-}" ]
|
|
||||||
then
|
|
||||||
self_path="${(%):-%x}"
|
|
||||||
else
|
|
||||||
echo "Could not detect IDF_PATH. Please set it before sourcing this script:"
|
|
||||||
echo " export IDF_PATH=(add path here)"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
script_dir=$(__script_dir)
|
|
||||||
export IDF_PATH="${script_dir}"
|
export IDF_PATH="${script_dir}"
|
||||||
echo "Setting IDF_PATH to '${IDF_PATH}'"
|
echo "Setting IDF_PATH to '${IDF_PATH}'"
|
||||||
else
|
else
|
||||||
# IDF_PATH came from the environment, check if the path is valid
|
# IDF_PATH came from the environment, check if the path is valid
|
||||||
script_dir=$(__script_dir)
|
|
||||||
if [ ! "${IDF_PATH}" = "${script_dir}" ]
|
if [ ! "${IDF_PATH}" = "${script_dir}" ]
|
||||||
then
|
then
|
||||||
|
# Change IDF_PATH is important when there are 2 ESP-IDF versions in different directories.
|
||||||
|
# Sourcing this script without change, would cause sourcing wrong export script.
|
||||||
echo "Resetting IDF_PATH from '${IDF_PATH}' to '${script_dir}' "
|
echo "Resetting IDF_PATH from '${IDF_PATH}' to '${script_dir}' "
|
||||||
export IDF_PATH="${script_dir}"
|
export IDF_PATH="${script_dir}"
|
||||||
fi
|
fi
|
||||||
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
|
# Check if this path looks like an IDF directory
|
||||||
if [ ! -f "${IDF_PATH}/tools/idf.py" ] || [ ! -f "${IDF_PATH}/tools/idf_tools.py" ]
|
if [ ! -f "${IDF_PATH}/tools/idf.py" ] || [ ! -f "${IDF_PATH}/tools/idf_tools.py" ]
|
||||||
then
|
then
|
||||||
|
@ -1199,9 +1199,10 @@ def deactivate_statement(args): # type: (list[str]) -> None
|
|||||||
if 'sha' in idf_env_json['idfInstalled']:
|
if 'sha' in idf_env_json['idfInstalled']:
|
||||||
try:
|
try:
|
||||||
idf_env_json['idfInstalled'].pop('sha')
|
idf_env_json['idfInstalled'].pop('sha')
|
||||||
|
if idf_env_json['idfPreviousId'] == 'sha':
|
||||||
|
idf_env_json['idfPreviousId'] = ''
|
||||||
if idf_env_json['idfSelectedId'] == 'sha':
|
if idf_env_json['idfSelectedId'] == 'sha':
|
||||||
idf_env_json['idfSelectedId'] = active_repo_id()
|
idf_env_json['idfSelectedId'] = active_repo_id()
|
||||||
idf_env_json['idfPreviousId'] = ''
|
|
||||||
return
|
return
|
||||||
finally:
|
finally:
|
||||||
save_idf_env(idf_env_json)
|
save_idf_env(idf_env_json)
|
||||||
|
Loading…
Reference in New Issue
Block a user