export.fish 2.5 KB

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