Commit Graph

43 Commits

Author SHA1 Message Date
Frantisek Hrbata
6f3241a34b fix(tools): Upgrade shell detection & simplify autocompletion
Explicitly set shell type in export.sh for bash and zsh

-Most of the issues reported with the updated export scripts are related
 to shell detection. Since we already know the shell type for commonly
 used ones like bash or zsh, we can pass the shell type directly to the
 activate script. This should hopefully resolve the shell detection
 problems for most users.

 This update also modifies the shell type detection to rely solely on
 psutil.Process().cmdline() rather than psutil.Process().exe(). This
 change aims to resolve permission issues that may occur if, for example,
 the Python binary has certain capabilities assigned.

Move shell completion to the init script

- Currently we are expanding the autocompletion in the activate script and
 adding the expanded commands into the init script. To avoid
 concerns about shell versions, move the entire expansion to the init
 script.
2024-09-18 13:03:26 +02:00
Marek Fiala
7b417fc3f2 feat(tools): Add backup option to use legacy export script
This feature serves as an immediate fix in case
the new export approach causes issues.
The user can simply set the environment variable `ESP_IDF_LEGACY_EXPORT`,
and the old export script will be used.
2024-09-05 10:13:05 +02:00
Marek Fiala
88527faff8 feat(tools): Added Windows shells support + refactoring 2024-09-05 10:13:04 +02:00
Frantisek Hrbata
1c22f6c4e8 feat: add python script to activate ESP-IDF environment
Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2024-09-05 10:13:03 +02:00
Roland Dobai
0c2decc3be Merge branch 'pull12247' into 'master'
feat(tools): keep export.sh compatible with BourneShell

Closes IDFGH-11073

See merge request espressif/esp-idf!26303
2023-10-05 17:50:32 +08:00
Marek Fiala
addbc79ee7 refactor(tools): shellcheck pass modification
Closes https://github.com/espressif/esp-idf/pull/12247
2023-10-03 13:41:05 +02:00
Marek Fiala
37c7c5b58d feat(tools): Add shellcheck for shell scripts to CI
- shellcheck fixes in shell scripts
2023-10-03 10:57:29 +02:00
Mike Krupicka
c4da3d4d32 Keep export.sh Bourne Shell compatible 2023-09-26 06:59:33 -05:00
Justin Ong
8097cc9d72 Fix references to IDF_ADD_PATHS_EXTRAS before being declared 2023-04-28 21:30:53 +08:00
Roland Dobai
7473fd3f0f Tools: don't add the esptool directory with wrappers to the PATH
Esptool.py is available from the esptool package which is installed in
every ESP-IDF v5.0+ shells. Therefore, the path to the legacy wrapper
scripts is not needed to be in the PATH. In some cases like
https://github.com/espressif/esp-idf/issues/10926 it even cases problem
because the wrapper doesn't have a shebang line and is not executable.

Note that the wrapper is kept only for invoking esptool as "python
$IDF_PATH/..../esptool.py" which was previously used mostly in CMake
files. There should be no other use-case where the esptool wrappers are
still needed.
2023-03-22 11:18:24 +01:00
Marc Finet
13e59ed7a9 export: avoid error on unbound variable
I the shell has `set -u` (to abort on unbound variable), sourcing
export.sh currently fails when IDF_EXPORT_QUIET or IDF_PATH is not set:
> /path/to/esp-idf/export.sh:16: IDF_EXPORT_QUIET: unbound variable

This commit sets a default empty value to those variable, as done
in 16731833fb (which forgot IDF_PATH as it's usually set, the other
variable landed later in the file).
2023-03-10 12:56:11 +01:00
Marek Fiala
c63ec6cf08 Tools: Support ESP-IDF installed in system-wide shared directory for all users
Closes: https://github.com/espressif/esp-idf/issues/9329
Closes: https://github.com/espressif/esp-idf/pull/9328
2022-09-16 09:15:19 +02:00
Morgan Harris
20487e7a06 Tools: Fix export.sh failure if python is unavailable
In the latest release of macOS (and probable some other recent *nixes as well?) `python` is no longer available by default, only `python3`. This causes `export.sh` to fail as it still had a reference to plain `python`. This now works as expected.

Merges https://github.com/espressif/esp-idf/pull/9749
2022-09-14 13:53:32 +02:00
Ivan Grokhotkov
9703b68215
tools: export.sh: fix expansion of IDF_PATH with spaces 2022-05-02 19:05:47 +02:00
Marek Fiala
0bf264a948 tools: bugfix - broken export script while working with esp-idf file
+ bugfix IDF_PATH detection in sh and dash shells.
+ created Classes that represents idf-env.json file
2022-04-24 22:29:18 +02:00
Marek Fiala
029de43db3 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.
2022-03-15 11:24:09 +01:00
Marek Fiala
df16a45d7a tools: Switching between ESP-IDF versions
Support switching between ESP-IDF versions on UNIX systems.
2022-03-11 12:57:25 +01:00
Marek Fiala
a4b0560014 tools: Remove tools that are not used by active ESP-IDF version.
Or remove unused archives from tools - older version, or unused tool archive
2022-02-20 19:48:50 +01:00
Roland Dobai
a93e372364 Tools: Fix silent failure about the incompatible Python 2022-02-16 18:44:13 +01:00
Roland Dobai
b28d7e6850 Tools: Improve the Python package system
Introduce features into the Python package management system & manage
package versions outside of ESP-IDF repo.
2022-01-17 16:54:36 +01:00
Martin Gaňo
9a5d699969 Avoid exception messages while autocomplete initialization in export.sh 2021-11-29 18:39:49 +01:00
Ivan Grokhotkov
2c375458ab export.sh: fix undefined reference to realpath after renaming 2021-10-14 09:45:30 +02:00
Ivan Grokhotkov
a038fb24bd tools: {export,install}.sh: fix quoting issues 2021-10-14 09:45:30 +02:00
Marek Fiala
d8a8eceef4 Edited Jen Chitty's commit to keep ESP_IDF consistency 2021-10-13 21:28:35 +08:00
Jen Chitty
6c564bd690 Correct export.sh failure exit code and cleanup
In failure cases, when idf_export_main() returns 1 (failure),
the export.sh script returns 0 (success). This makes it very
difficult to detect failure when writing scripts that use
export.sh. Furthermore, idf_export_main() does not clean up all
internal variables and functions in failure cases.

Move all cleanup steps into a cleanup function and pass
the return value from idf_export_main() to the cleanup
function so it can return with that same return value.

Signed-off-by: Marek Fiala <marek.fiala@espressif.com>

Closes https://github.com/espressif/esp-idf/pull/5744
2021-10-13 21:28:35 +08:00
Marek Fiala
8dd6d9fa5f Edited Rob Walker's commit to keep ESP_IDF consistency 2021-10-13 21:28:35 +08:00
Rob Walker
25619bef04 tools/echo and cleanup fix in export scripts
Signed-off-by: Marek Fiala <marek.fiala@espressif.com>

Closes https://github.com/espressif/esp-idf/pull/5816
2021-10-13 21:28:35 +08:00
Martin Gaňo
38c148b904 Temporarily set LANG to en code to avoid RuntimeError
Closes https://github.com/espressif/esp-idf/issues/7173
2021-06-22 13:05:44 +02:00
Martin Gaňo
330d1cf2ae Fix autocomplete for bash 2021-06-11 01:59:36 +02:00
Martin Gaňo
fb70ea6d13 Fixed test autocompletion 2021-05-26 10:58:05 +02:00
Martin Gaňo
16731833fb add default value for unset env variables
Closes IDFGH-4784
2021-03-08 09:18:34 +01:00
Markus Reiter
d20a5c39da Fix error when ZSH_VERSION is unset.
Merges https://github.com/espressif/esp-idf/pull/6587
2021-03-08 09:18:34 +01:00
Roland Dobai
47f67f8b81 tools: Prefer python3 during install and export
Install and export script should work on systems without "python"
executable.

Closes https://github.com/espressif/esp-idf/pull/6471

Closes https://github.com/espressif/esp-idf/issues/6532

Related to https://github.com/espressif/esp-idf/issues/6421 and
https://github.com/espressif/arduino-esp32/issues/4717
2021-02-13 11:34:40 +01:00
martin.gano
304cff9f75 Redirect warning to stderr and unset temporary shell procedure 2020-11-11 15:12:58 +01:00
Angus Gratton
66fb5a29bb Whitespace: Automated whitespace fixes (large commit)
Apply the pre-commit hook whitespace fixes to all files in the repo.

(Line endings, blank lines at end of file, trailing whitespace)
2020-11-11 07:36:35 +00:00
martin.gano
346b002d9a enable autocompletion for command idf.py 2020-11-03 23:27:58 +01:00
Ivan Grokhotkov
4712392161 tools: export.sh: fix compatibility with dash shell
* fix constructs invalid in dash
* clean shellcheck warnings and disable false positive ones

Closes https://github.com/espressif/esp-idf/issues/5366
2020-06-08 19:33:00 +02:00
Ivan Grokhotkov
46e9aef6c9 tools/check_python_dependencies: print diagnostic info on failure
Helps collect more data for cases such as:
https://github.com/espressif/esp-idf/issues/5133
2020-04-16 11:58:16 +02:00
Ivan Grokhotkov
a1f5866424 tools: export.{sh,fish}: add otatool.py to PATH 2020-04-03 01:15:29 +02:00
Ivan Grokhotkov
1c4c584e28 tools: export.sh: better detection and checking of IDF_PATH
1. detect IDF_PATH in zsh, if it is not set
2. if IDF_PATH is set, check that it is valid
3. make sure IDF_PATH is exported, not just set

Related to https://github.com/espressif/esp-idf/issues/3793
Closes https://github.com/espressif/esp-idf/pull/4418
Closes https://github.com/espressif/esp-idf/issues/4770
2020-04-03 01:15:29 +02:00
Ivan Grokhotkov
3f9fc97de7 tools: export.sh: fix ESP-IDF path detection on macos
The argument passed to the function is in $1; $0 contains `-bash`.
Before this fix, IDF_PATH would be set to $PWD instead of the correct
path.
2019-07-28 10:04:36 +02:00
Martin Vychodil
54b16b7f5a tools: added realpath_int() for MacOS script path resolution
JIRA IDF-790
2019-07-18 13:36:11 +02:00
Ivan Grokhotkov
12b6da0388 tools: {install,export}.{bat,sh} tools 2019-07-01 14:51:44 +02:00