export.fish 2.1 KB

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