export.fish 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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 "Adding ESP-IDF tools to PATH..."
  17. # Call idf_tools.py to export tool paths
  18. set -x IDF_TOOLS_EXPORT_CMD "$IDF_PATH"/export.fish
  19. set -x IDF_TOOLS_INSTALL_CMD "$IDF_PATH"/install.fish
  20. set idf_exports ("$IDF_PATH"/tools/idf_tools.py export) || return 1
  21. eval "$idf_exports"
  22. echo "Checking if Python packages are up to date..."
  23. python "$IDF_PATH"/tools/check_python_dependencies.py || return 1
  24. # Allow calling some IDF python tools without specifying the full path
  25. # "$IDF_PATH"/tools is already added by 'idf_tools.py export'
  26. set IDF_ADD_PATHS_EXTRAS "$IDF_PATH"/components/esptool_py/esptool
  27. set IDF_ADD_PATHS_EXTRAS "$IDF_ADD_PATHS_EXTRAS":"$IDF_PATH"/components/espcoredump
  28. set IDF_ADD_PATHS_EXTRAS "$IDF_ADD_PATHS_EXTRAS":"$IDF_PATH"/components/partition_table
  29. set IDF_ADD_PATHS_EXTRAS "$IDF_ADD_PATHS_EXTRAS":"$IDF_PATH"/components/app_update
  30. set -x PATH "$IDF_ADD_PATHS_EXTRAS":"$PATH"
  31. set added_path_variables
  32. for entry in $PATH;
  33. if not contains $entry $oldpath
  34. set -a added_path_variables $entry
  35. end
  36. end
  37. if set -q added_path_variables[1]
  38. echo "Added the following directories to PATH:"
  39. for entry in $added_path_variables;
  40. echo $entry
  41. end
  42. else
  43. echo "All paths are already set."
  44. end
  45. # Clean up
  46. set -e added_path_variables
  47. set -e cmd
  48. set -e old_path
  49. set -e paths
  50. set -e path_prefix
  51. set -e path_entry
  52. set -e IDF_ADD_PATHS_EXTRAS
  53. set -e idf_exports
  54. # Not unsetting IDF_PYTHON_ENV_PATH, it can be used by IDF build system
  55. # to check whether we are using a private Python environment
  56. echo "Done! You can now compile ESP-IDF projects."
  57. echo "Go to the project directory and run:"
  58. echo ""
  59. echo " idf.py build"
  60. echo ""
  61. end
  62. idf_export_main
  63. set -e idf_export_main