export.fish 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. # This script should be sourced, not executed.
  2. function idf_export_main
  3. if not set -q IDF_PATH
  4. echo "IDF_PATH must be set before sourcing this script"
  5. return 1
  6. end
  7. set oldpath = $PATH
  8. echo "Detecting the Python interpreter"
  9. source "$IDF_PATH"/tools/detect_python.fish
  10. echo "Adding ESP-IDF tools to PATH..."
  11. # Call idf_tools.py to export tool paths
  12. set -x IDF_TOOLS_EXPORT_CMD "$IDF_PATH"/export.fish
  13. set -x IDF_TOOLS_INSTALL_CMD "$IDF_PATH"/install.fish
  14. set idf_exports ("$ESP_PYTHON" "$IDF_PATH"/tools/idf_tools.py export) || return 1
  15. eval "$idf_exports"
  16. echo "Checking if Python packages are up to date..."
  17. python "$IDF_PATH"/tools/check_python_dependencies.py || return 1
  18. # Allow calling some IDF python tools without specifying the full path
  19. # "$IDF_PATH"/tools is already added by 'idf_tools.py export'
  20. set IDF_ADD_PATHS_EXTRAS "$IDF_PATH"/components/esptool_py/esptool
  21. set IDF_ADD_PATHS_EXTRAS "$IDF_ADD_PATHS_EXTRAS":"$IDF_PATH"/components/espcoredump
  22. set IDF_ADD_PATHS_EXTRAS "$IDF_ADD_PATHS_EXTRAS":"$IDF_PATH"/components/partition_table
  23. set IDF_ADD_PATHS_EXTRAS "$IDF_ADD_PATHS_EXTRAS":"$IDF_PATH"/components/app_update
  24. set -x PATH "$IDF_ADD_PATHS_EXTRAS":"$PATH"
  25. set added_path_variables
  26. for entry in $PATH;
  27. if not contains $entry $oldpath
  28. set -a added_path_variables $entry
  29. end
  30. end
  31. if set -q added_path_variables[1]
  32. echo "Added the following directories to PATH:"
  33. for entry in $added_path_variables;
  34. echo $entry
  35. end
  36. else
  37. echo "All paths are already set."
  38. end
  39. # Clean up
  40. set -e added_path_variables
  41. set -e cmd
  42. set -e old_path
  43. set -e paths
  44. set -e path_prefix
  45. set -e path_entry
  46. set -e IDF_ADD_PATHS_EXTRAS
  47. set -e idf_exports
  48. set -e ESP_PYTHON
  49. # Not unsetting IDF_PYTHON_ENV_PATH, it can be used by IDF build system
  50. # to check whether we are using a private Python environment
  51. echo "Done! You can now compile ESP-IDF projects."
  52. echo "Go to the project directory and run:"
  53. echo ""
  54. echo " idf.py build"
  55. echo ""
  56. end
  57. idf_export_main
  58. set click_version (python -c 'import click; print(click.__version__.split(".")[0])')
  59. if test $click_version -lt 8
  60. eval (env _IDF.PY_COMPLETE=source_fish idf.py)
  61. else
  62. eval (env _IDF.PY_COMPLETE=fish_source idf.py)
  63. end
  64. set -e idf_export_main