export.fish 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. # This script should be sourced, not executed.
  2. function __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 "Checking Python compatibility"
  11. "$ESP_PYTHON" "$IDF_PATH"/tools/python_version_checker.py
  12. echo "Adding ESP-IDF tools to PATH..."
  13. # Call idf_tools.py to export tool paths
  14. set -x IDF_TOOLS_EXPORT_CMD "$IDF_PATH"/export.fish
  15. set -x IDF_TOOLS_INSTALL_CMD "$IDF_PATH"/install.fish
  16. set idf_exports ("$ESP_PYTHON" "$IDF_PATH"/tools/idf_tools.py export) || return 1
  17. eval "$idf_exports"
  18. echo "Checking if Python packages are up to date..."
  19. python "$IDF_PATH"/tools/idf_tools.py check-python-dependencies || return 1
  20. # Allow calling some IDF python tools without specifying the full path
  21. # "$IDF_PATH"/tools is already added by 'idf_tools.py export'
  22. set IDF_ADD_PATHS_EXTRAS "$IDF_PATH"/components/esptool_py/esptool
  23. set IDF_ADD_PATHS_EXTRAS "$IDF_ADD_PATHS_EXTRAS":"$IDF_PATH"/components/espcoredump
  24. set IDF_ADD_PATHS_EXTRAS "$IDF_ADD_PATHS_EXTRAS":"$IDF_PATH"/components/partition_table
  25. set IDF_ADD_PATHS_EXTRAS "$IDF_ADD_PATHS_EXTRAS":"$IDF_PATH"/components/app_update
  26. set -x PATH "$IDF_ADD_PATHS_EXTRAS":"$PATH"
  27. set added_path_variables
  28. for entry in $PATH;
  29. if not contains $entry $oldpath
  30. set -a added_path_variables $entry
  31. end
  32. end
  33. if set -q added_path_variables[1]
  34. echo "Added the following directories to PATH:"
  35. for entry in $added_path_variables;
  36. echo $entry
  37. end
  38. else
  39. echo "All paths are already set."
  40. end
  41. set uninstall ("$ESP_PYTHON" "$IDF_PATH"/tools/idf_tools.py uninstall --dry-run) || return 1
  42. if test -n "$uninstall"
  43. echo ""
  44. echo "Detected installed tools that are not currently used by active ESP-IDF version."
  45. echo "$uninstall"
  46. echo "For free up even more space, remove installation packages of those tools. Use option '$ESP_PYTHON $IDF_PATH/tools/idf_tools.py uninstall --remove-archives'."
  47. echo ""
  48. end
  49. # Clean up
  50. set -e added_path_variables
  51. set -e cmd
  52. set -e old_path
  53. set -e paths
  54. set -e path_prefix
  55. set -e path_entry
  56. set -e IDF_ADD_PATHS_EXTRAS
  57. set -e idf_exports
  58. set -e ESP_PYTHON
  59. set -e uninstall
  60. # Not unsetting IDF_PYTHON_ENV_PATH, it can be used by IDF build system
  61. # to check whether we are using a private Python environment
  62. echo "Done! You can now compile ESP-IDF projects."
  63. echo "Go to the project directory and run:"
  64. echo ""
  65. echo " idf.py build"
  66. echo ""
  67. end
  68. __main
  69. set click_version (python -c 'import click; print(click.__version__.split(".")[0])')
  70. if test $click_version -lt 8
  71. eval (env _IDF.PY_COMPLETE=source_fish idf.py)
  72. else
  73. eval (env _IDF.PY_COMPLETE=fish_source idf.py)
  74. end
  75. set -e __main