2020-03-16 14:22:43 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								# This script should be sourced, not executed.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-08-09 18:13:29 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								# `idf_tools.py export --deactivate` create statement, with keyword unset, but fish shell support only `set --erase variable`
 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-08 17:55:03 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								function  unset 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    set  --erase  $argv 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								end 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-10-06 13:48:11 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								function  __main 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-31 14:38:24 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    set  script_dir  ( dirname  ( realpath  ( status  -f ) ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2020-03-16 14:22:43 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								    if  not  set  -q  IDF_PATH 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-31 02:03:48 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        set  -gx  IDF_PATH  $script_dir 
							 
						 
					
						
							
								
									
										
										
										
											2022-06-22 14:50:16 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        echo  " Setting IDF_PATH to ' $IDF_PATH ' " 
							 
						 
					
						
							
								
									
										
										
										
											2020-03-16 14:22:43 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								    end 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-11-08 17:55:03 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    if  test  " $IDF_PATH "  !=  " $script_dir " 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-14 15:15:35 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        # Change IDF_PATH is important when there are 2 ESP-IDF versions in different directories.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        # Sourcing this script without change, would cause sourcing wrong export script.
 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-08 17:55:03 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        echo  " Resetting IDF_PATH from ' $IDF_PATH ' to ' $script_dir ' " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        set  IDF_PATH  " $script_dir " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    end 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-03-16 14:22:43 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								    set  oldpath  =  $PATH 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-02-02 13:20:09 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    echo  "Detecting the Python interpreter" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    source  " $IDF_PATH " /tools/detect_python.fish 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-02-15 18:36:46 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    echo  "Checking Python compatibility" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    " $ESP_PYTHON "  " $IDF_PATH " /tools/python_version_checker.py
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-11-08 17:55:03 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    echo  "Checking other ESP-IDF version." 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-09 18:13:29 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    set  idf_deactivate  ( " $ESP_PYTHON "  " $IDF_PATH " /tools/idf_tools.py export --deactivate )  ||  return  1 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    eval  " $idf_deactivate " 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-08 17:55:03 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-03-16 14:22:43 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								    echo  "Adding ESP-IDF tools to PATH..." 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    # Call idf_tools.py to export tool paths
 
							 
						 
					
						
							
								
									
										
										
										
											2022-06-22 14:50:16 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    set  -gx  IDF_TOOLS_EXPORT_CMD  " $IDF_PATH " /export.fish 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    set  -gx  IDF_TOOLS_INSTALL_CMD  " $IDF_PATH " /install.fish 
							 
						 
					
						
							
								
									
										
										
										
											2020-03-16 14:22:43 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								    # Allow calling some IDF python tools without specifying the full path
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    # "$IDF_PATH"/tools is already added by 'idf_tools.py export'
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    set  IDF_ADD_PATHS_EXTRAS  " $IDF_PATH " /components/esptool_py/esptool
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    set  IDF_ADD_PATHS_EXTRAS  " $IDF_ADD_PATHS_EXTRAS " :" $IDF_PATH " /components/espcoredump
							 
						 
					
						
							
								
									
										
										
										
											2020-04-02 19:06:48 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    set  IDF_ADD_PATHS_EXTRAS  " $IDF_ADD_PATHS_EXTRAS " :" $IDF_PATH " /components/partition_table
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    set  IDF_ADD_PATHS_EXTRAS  " $IDF_ADD_PATHS_EXTRAS " :" $IDF_PATH " /components/app_update
							 
						 
					
						
							
								
									
										
										
										
											2021-11-08 17:55:03 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    set  idf_exports  ( " $ESP_PYTHON "  " $IDF_PATH " /tools/idf_tools.py export --add_paths_extras = " $IDF_ADD_PATHS_EXTRAS " )  ||  return  1 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    eval  " $idf_exports " 
							 
						 
					
						
							
								
									
										
										
										
											2020-03-16 14:22:43 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								    set  -x  PATH  " $IDF_ADD_PATHS_EXTRAS " :" $PATH " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-11-08 17:55:03 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    echo  "Checking if Python packages are up to date..." 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-08 10:51:07 +10:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    " $ESP_PYTHON "  " $IDF_PATH " /tools/idf_tools.py check-python-dependencies ||  return  1 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-08 17:55:03 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-03-16 14:22:43 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								    set  added_path_variables 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    for  entry  in  $PATH ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        if  not  contains  $entry  $oldpath 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            set  -a  added_path_variables  $entry 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        end 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    end 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    if  set  -q  added_path_variables [ 1 ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        echo  "Added the following directories to PATH:" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        for  entry  in  $added_path_variables ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            echo  $entry 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        end 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    else 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        echo  "All paths are already set." 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    end 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-12-13 16:45:11 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    set  uninstall  ( " $ESP_PYTHON "  " $IDF_PATH " /tools/idf_tools.py uninstall --dry-run )  ||  return  1 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    if  test  -n  " $uninstall " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        echo  "" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        echo  "Detected installed tools that are not currently used by active ESP-IDF version." 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        echo  " $uninstall " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        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'. " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        echo  "" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    end 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-03-16 14:22:43 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								    # Clean up
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    set  -e  added_path_variables 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    set  -e  cmd 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    set  -e  old_path 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    set  -e  paths 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    set  -e  path_prefix 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    set  -e  path_entry 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    set  -e  IDF_ADD_PATHS_EXTRAS 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    set  -e  idf_exports 
							 
						 
					
						
							
								
									
										
										
										
											2021-02-02 13:20:09 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    set  -e  ESP_PYTHON 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-13 16:45:11 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    set  -e  uninstall 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-08 17:55:03 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    set  -e  script_dir 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-09 18:13:29 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    set  -e  idf_deactivate 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-08 17:55:03 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-03-16 14:22:43 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    # Not unsetting IDF_PYTHON_ENV_PATH, it can be used by IDF build system
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    # to check whether we are using a private Python environment
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    echo  "Done! You can now compile ESP-IDF projects." 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    echo  "Go to the project directory and run:" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    echo  "" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    echo  "  idf.py build" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    echo  "" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								end 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-10-06 13:48:11 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								__main 
							 
						 
					
						
							
								
									
										
										
										
											2020-03-16 14:22:43 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-05-24 14:11:56 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								set  click_version  ( python  -c  'import click; print(click.__version__.split(".")[0])' ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								if  test  $click_version  -lt  8 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    eval  ( env  _IDF.PY_COMPLETE = source_fish idf .py) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								else 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    eval  ( env  _IDF.PY_COMPLETE = fish_source idf .py) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								end 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-02 14:11:14 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-10-06 13:48:11 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								set  -e  __main