dist/tools: improve the esptools, enhance documentation#21625
dist/tools: improve the esptools, enhance documentation#21625crasbe merged 1 commit intoRIOT-OS:masterfrom
esptools, enhance documentation#21625Conversation
|
I still wonder whether the output regarding the permanent setting of the PATH variable should be inside of the @benpicco added these lines there, maybe he has an strong opinion. My suggestion would be that could be part of this PR: diff --git a/dist/tools/esptools/export.sh b/dist/tools/esptools/export.sh
index defd527abf..dc04187327 100755
--- a/dist/tools/esptools/export.sh
+++ b/dist/tools/esptools/export.sh
@@ -47,10 +47,10 @@ export_arch()
if [ -e "${TOOLS_DIR}" ] && [ -z "${TOOLS_DIR_IN_PATH}" ]; then
echo "Extending PATH by ${TOOLS_DIR}/bin"
export PATH="${TOOLS_DIR}/bin:${PATH}"
- fi
- echo "To make this permanent, add this line to your ~/.bashrc or ~/.profile:"
- echo PATH="\$PATH:${TOOLS_DIR}/bin"
+ echo "To make this permanent, add this line to your ~/.bashrc or ~/.profile:"
+ echo PATH="\$PATH:${TOOLS_DIR}/bin"
+ fi
unset TOOLS_DIR
} |
|
Sure, why not. I'll add it later. |
|
I also added the version check now, but this has to be tested more extensively. |
|
@gschorcht one thing I noticed is that no warning etc is printed when the toolchain is not present. For example, I don't have Perhaps that should at least print an error message? |
Yes, but this is only true for the additional tools, that is, We have just to these lines also to |
|
BTW, since the export_tool()
{
if [ ! -e "${TOOLS_DIR}" ]; then
echo "${TOOLS_DIR} does not exist - please run"
echo "\${RIOTBASE}/dist/tools/esptools/install.sh $1"
exit(1)
fi
echo "$PATH" | tr ':' '\n' | while read -r entry; do
if echo "$entry" | grep -q "^${TOOLS_PATH}/${TARGET_ARCH}/.*/${TARGET_ARCH}/bin$"; then
if [ "$entry" != "${TOOLS_DIR}/bin" ]; then
echo "Warning: PATH contains outdated entry: \"$entry\"." \
"Please check your ~/.bashrc or ~/.profile.">&2
fi
fi
done
unset entry
if [ -e "${TOOLS_DIR}" ] && [ -z "${TOOLS_DIR_IN_PATH}" ]; then
echo "Extending PATH by ${TOOLS_DIR}/bin"
export PATH="${TOOLS_DIR}/bin:${PATH}"
echo "To make this permanent, add this line to your ~/.bashrc or ~/.profile:"
echo PATH="\$PATH:${TOOLS_DIR}/bin"
fi
}It makes no sense to repeat the same code again and again. |
|
The new Note here: There was a bug in |
esptools, enhance documentation
Not really a bug, it stems from a time when no additional parameters were required for the architecture because |
|
Should be correct now: I also added the distinction between |
gschorcht
left a comment
There was a problem hiding this comment.
Looks good, please squash.
The esptools/export.sh script has to be sourced, otherwise the exported variables are not persistent in the environment, rendering the script useless. The commit adds a check to the script that it runs in the correct environment and enhances the documentation to make it clearer that the "source" prefix command is important. The PR also introduces a version check for the PATH variable to notify the user if an old version is present.
6524a6f to
bd0f8b7
Compare
|
Thanks a lot for your work on these scripts. |
Contribution description
The esptools/export.sh script has to be sourced, otherwise the exported variables are not persistent in the environment, rendering the script useless. The commit adds a check to the script that it runs in the correct environment and enhances the documentation to make it clearer that the "source" prefix command is important.
The documentation mentioned that, but I did not understand what "sourcing a script" means and I did not pay attention to the dot in front of the script. Sorry @gschorcht for not reading the documentation well enough 👀
Open for discussion: Should the script terminate before doing anything (as it does now) or should it print out the warning instead of the
Extending PATH by ...message?Testing procedure: Sourcing
Pre: Make sure your PATH variable does not contain the latest ESP SDK version yet.
Current situation on
master: Calling thedist/tools/esptools/export.shscript without a.orsourcecommand in the front suggests to be adding the SDK path to the PATH variable, while it actually doesn't (well it does, but to the environment of the script, which is lost after the script terminates):With this PR, an error message is printed:
Testing Procedure: Version Check
Testing procedure:
Issues/PRs references
Came up in #21616 (comment)