2019-04-29 10:37:02 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								# This script should be sourced, not executed.  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-08-31 16:00:57 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								__realpath( )  { 
							 
						 
					
						
							
								
									
										
										
										
											2019-07-16 15:38:40 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    wdir = " $PWD " ;  [  " $PWD "  =  "/"  ]  &&  wdir = "" 
							 
						 
					
						
							
								
									
										
										
										
											2019-07-28 10:04:36 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    arg = $1 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    case  " $arg "  in
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        /*)  scriptdir = " ${ arg } " ; ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        *)  scriptdir = " $wdir / ${ arg #./ } " ; ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-07-16 15:38:40 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    esac 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    scriptdir = " ${ scriptdir %/* } " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    echo  " $scriptdir " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-08-31 16:00:57 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								__verbose( )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-07 13:26:04 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    [  -n " ${ IDF_EXPORT_QUIET - } "  ]  &&  return 
							 
						 
					
						
							
								
									
										
										
										
											2020-08-31 16:00:57 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    echo  " $@ " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-11-08 17:55:03 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								__script_dir( ) { 
							 
						 
					
						
							
								
									
										
										
										
											2022-05-02 18:46:02 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    # shellcheck disable=SC2169,SC2169,SC2039,SC3010,SC3028  # unreachable with 'dash' 
							 
						 
					
						
							
								
									
										
										
										
											2023-10-03 13:35:06 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  [  " $( uname -s) "  =  "Darwin"  ] ;  then 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-08 17:55:03 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        # convert possibly relative path to absolute 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        script_dir = " $( __realpath " ${ self_path } " ) " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        # resolve any ../ references to make the path shorter 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        script_dir = " $( cd  " ${ script_dir } "  ||  exit  1;  pwd ) " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    else 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        # convert to full path and get the directory name of that 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        script_name = " $( readlink -f " ${ self_path } " ) " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        script_dir = " $( dirname " ${ script_name } " ) " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    fi 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  [  " $script_dir "  =  '.'  ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    then 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								       script_dir = " $( pwd ) " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    fi 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    echo  " $script_dir " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-19 21:37:16 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								__is_dir_esp_idf( ) { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  [  ! -f " $1 /tools/idf.py "  ]  ||  [  ! -f " $1 /tools/idf_tools.py "  ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    then 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        # Echo command here is not used for printing to the terminal, but as non-empty return value from function. 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        echo  "THIS DIRECTORY IS NOT ESP-IDF" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    fi 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-08-31 16:00:57 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								__main( )  { 
							 
						 
					
						
							
								
									
										
										
										
											2019-04-29 10:37:02 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								    # The file doesn't have executable permissions, so this shouldn't really happen. 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    # Doing this in case someone tries to chmod +x it and execute... 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-08 19:14:48 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-05-02 18:46:02 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    # shellcheck disable=SC2128,SC2169,SC2039,SC3054 # ignore array expansion warning 
							 
						 
					
						
							
								
									
										
										
										
											2021-02-28 23:26:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  [  -n " ${ BASH_SOURCE - } "  ]  &&  [  " ${ BASH_SOURCE [0] } "  =  " ${ 0 } "  ] 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-08 19:14:48 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    then 
							 
						 
					
						
							
								
									
										
										
										
											2019-04-29 10:37:02 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								        echo  "This script should be sourced, not executed:" 
							 
						 
					
						
							
								
									
										
										
										
											2022-05-02 18:46:02 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        # shellcheck disable=SC2039,SC3054  # reachable only with bash 
							 
						 
					
						
							
								
									
										
										
										
											2019-04-29 10:37:02 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								        echo  " .  ${ BASH_SOURCE [0] } " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return  1 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    fi 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-14 15:15:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    # If using bash or zsh, try to guess IDF_PATH from script location. 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    self_path = "" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    # shellcheck disable=SC2128  # ignore array expansion warning 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  [  -n " ${ BASH_SOURCE - } "  ] 
							 
						 
					
						
							
								
									
										
										
										
											2019-04-29 10:37:02 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								    then 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-14 15:15:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        self_path = " ${ BASH_SOURCE } " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    elif  [  -n " ${ ZSH_VERSION - } "  ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    then 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-05 11:09:52 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    # shellcheck disable=SC2296  # ignore parameter starts with '{' because it's zsh 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-14 15:15:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        self_path = " ${ (%) :- %x } " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    fi 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-08 19:14:48 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-05-02 18:46:02 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    script_dir = " $( __script_dir) " 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-19 21:37:16 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    # Since sh or dash shells can't detect script_dir correctly, check if script_dir looks like an IDF directory 
							 
						 
					
						
							
								
									
										
										
										
											2022-05-02 18:46:02 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    is_script_dir_esp_idf = $( __is_dir_esp_idf " ${ script_dir } " ) 
							 
						 
					
						
							
								
									
										
										
										
											2020-04-02 19:05:58 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-03-07 13:26:04 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  [  -z " ${ IDF_PATH - } "  ] 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-14 15:15:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    then 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        # IDF_PATH not set in the environment. 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-19 21:37:16 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  [  -n " ${ is_script_dir_esp_idf } "  ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        then 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            echo  "Could not detect IDF_PATH. Please set it before sourcing this script:" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            echo  "  export IDF_PATH=(add path here)" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            return  1 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        fi 
							 
						 
					
						
							
								
									
										
										
										
											2020-04-02 19:05:58 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        export  IDF_PATH = " ${ script_dir } " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        echo  " Setting IDF_PATH to ' ${ IDF_PATH } ' " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    else 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        # IDF_PATH came from the environment, check if the path is valid 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-19 21:37:16 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        # Set IDF_PATH to script_dir, if script_dir looks like an IDF directory 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  [  ! " ${ IDF_PATH } "  =  " ${ script_dir } "  ]  &&  [  -z " ${ is_script_dir_esp_idf } "  ] 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-08 17:55:03 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        then 
							 
						 
					
						
							
								
									
										
										
										
											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 } '  " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            export  IDF_PATH = " ${ script_dir } " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        fi 
							 
						 
					
						
							
								
									
										
										
										
											2020-04-02 19:05:58 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        # Check if this path looks like an IDF directory 
							 
						 
					
						
							
								
									
										
										
										
											2022-05-02 18:46:02 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        is_idf_path_esp_idf = $( __is_dir_esp_idf " ${ IDF_PATH } " ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-19 21:37:16 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  [  -n " ${ is_idf_path_esp_idf } "  ] 
							 
						 
					
						
							
								
									
										
										
										
											2020-04-02 19:05:58 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        then 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            echo  " IDF_PATH is set to ' ${ IDF_PATH } ', but it doesn't look like an ESP-IDF directory. " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            echo  "If you have set IDF_PATH manually, check if the path is correct." 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            return  1 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        fi 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        # The varible might have been set (rather than exported), re-export it to be sure 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        export  IDF_PATH = " ${ IDF_PATH } " 
							 
						 
					
						
							
								
									
										
										
										
											2019-04-29 10:37:02 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								    fi 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-04-02 19:05:58 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    old_path = " $PATH " 
							 
						 
					
						
							
								
									
										
										
										
											2019-04-29 10:37:02 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-02-02 13:20:09 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    echo  "Detecting the Python interpreter" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    . " ${ IDF_PATH } /tools/detect_python.sh " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											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 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    __verbose "Checking other ESP-IDF version." 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-09 18:13:29 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    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-08-31 16:00:57 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    __verbose "Adding ESP-IDF tools to PATH..." 
							 
						 
					
						
							
								
									
										
										
										
											2019-04-29 10:37:02 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								    # Call idf_tools.py to export tool paths 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    export  IDF_TOOLS_EXPORT_CMD = ${ IDF_PATH } /export.sh
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    export  IDF_TOOLS_INSTALL_CMD = ${ IDF_PATH } /install.sh
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    # Allow calling some IDF python tools without specifying the full path 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    # ${IDF_PATH}/tools is already added by 'idf_tools.py export' 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-28 21:30:53 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    IDF_ADD_PATHS_EXTRAS = " ${ IDF_PATH } /components/espcoredump " 
							 
						 
					
						
							
								
									
										
										
										
											2020-04-02 19:06:48 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    IDF_ADD_PATHS_EXTRAS = " ${ IDF_ADD_PATHS_EXTRAS } : ${ IDF_PATH } /components/partition_table " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    IDF_ADD_PATHS_EXTRAS = " ${ IDF_ADD_PATHS_EXTRAS } : ${ IDF_PATH } /components/app_update " 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-08 17:55:03 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-05-02 18:46:02 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    idf_exports = $( " $ESP_PYTHON "  " ${ IDF_PATH } /tools/idf_tools.py "  export  " --add_paths_extras= ${ IDF_ADD_PATHS_EXTRAS } " )  ||  return  1 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-08 17:55:03 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    eval  " ${ idf_exports } " 
							 
						 
					
						
							
								
									
										
										
										
											2019-04-29 10:37:02 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								    export  PATH = " ${ IDF_ADD_PATHS_EXTRAS } : ${ PATH } " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-11-08 17:55:03 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    __verbose "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-06-08 19:14:48 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  [  -n " $BASH "  ] 
							 
						 
					
						
							
								
									
										
										
										
											2019-04-29 10:37:02 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								    then 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-05 11:09:52 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        path_prefix = " ${ PATH %% " ${ old_path } " } " 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-08 19:14:48 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        # shellcheck disable=SC2169,SC2039  # unreachable with 'dash' 
							 
						 
					
						
							
								
									
										
										
										
											2020-10-09 17:40:57 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  [  -n " ${ path_prefix } "  ] ;  then 
							 
						 
					
						
							
								
									
										
										
										
											2020-08-31 16:00:57 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            __verbose "Added the following directories to PATH:" 
							 
						 
					
						
							
								
									
										
										
										
											2019-04-29 10:37:02 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								        else 
							 
						 
					
						
							
								
									
										
										
										
											2020-08-31 16:00:57 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            __verbose "All paths are already set." 
							 
						 
					
						
							
								
									
										
										
										
											2019-04-29 10:37:02 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								        fi 
							 
						 
					
						
							
								
									
										
										
										
											2020-10-09 17:40:57 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        old_ifs = " $IFS " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        IFS = ":" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        for  path_entry in ${ path_prefix } 
							 
						 
					
						
							
								
									
										
										
										
											2019-04-29 10:37:02 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								        do 
							 
						 
					
						
							
								
									
										
										
										
											2020-08-31 16:00:57 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            __verbose "    ${ path_entry } " 
							 
						 
					
						
							
								
									
										
										
										
											2019-04-29 10:37:02 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								        done 
							 
						 
					
						
							
								
									
										
										
										
											2020-10-09 17:40:57 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        IFS = " $old_ifs " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        unset  old_ifs
							 
						 
					
						
							
								
									
										
										
										
											2019-04-29 10:37:02 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								    else 
							 
						 
					
						
							
								
									
										
										
										
											2020-08-31 16:00:57 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        __verbose "Updated PATH variable:" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        __verbose "    ${ PATH } " 
							 
						 
					
						
							
								
									
										
										
										
											2019-04-29 10:37:02 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								    fi 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-12-13 16:45:11 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    uninstall = $( " $ESP_PYTHON "  " ${ IDF_PATH } /tools/idf_tools.py "  uninstall --dry-run)  ||  return  1 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  [  -n " $uninstall "  ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    then 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        __verbose "" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        __verbose "Detected installed tools that are not currently used by active ESP-IDF version." 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        __verbose " ${ uninstall } " 
							 
						 
					
						
							
								
									
										
										
										
											2022-05-02 18:46:02 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        __verbose " To free up even more space, remove installation packages of those tools. Use option ' ${ ESP_PYTHON }   ${ IDF_PATH } /tools/idf_tools.py uninstall --remove-archives'. " 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-13 16:45:11 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        __verbose "" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    fi 
							 
						 
					
						
							
								
									
										
										
										
											2020-08-17 12:08:32 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    __verbose "Done! You can now compile ESP-IDF projects." 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    __verbose "Go to the project directory and run:" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    __verbose "" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    __verbose "  idf.py build" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    __verbose "" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								__cleanup( )  { 
							 
						 
					
						
							
								
									
										
										
										
											2019-04-29 10:37:02 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								    unset  old_path
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    unset  paths
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    unset  path_prefix
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    unset  path_entry
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    unset  IDF_ADD_PATHS_EXTRAS
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    unset  idf_exports
							 
						 
					
						
							
								
									
										
										
										
											2022-08-09 18:13:29 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    unset  idf_deactivate
							 
						 
					
						
							
								
									
										
										
										
											2021-02-02 13:20:09 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    unset  ESP_PYTHON
							 
						 
					
						
							
								
									
										
										
										
											2021-10-11 14:11:09 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    unset  SOURCE_ZSH
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    unset  SOURCE_BASH
							 
						 
					
						
							
								
									
										
										
										
											2021-11-26 15:16:47 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    unset  WARNING_MSG
							 
						 
					
						
							
								
									
										
										
										
											2021-12-13 16:45:11 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    unset  uninstall
							 
						 
					
						
							
								
									
										
										
										
											2022-03-19 21:37:16 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    unset  is_idf_path_esp_idf
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    unset  is_script_dir_esp_idf
							 
						 
					
						
							
								
									
										
										
										
											2019-07-16 15:38:40 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-08-17 12:08:32 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    unset  __realpath
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    unset  __main
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    unset  __verbose
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    unset  __enable_autocomplete
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    unset  __cleanup
							 
						 
					
						
							
								
									
										
										
										
											2022-03-19 21:37:16 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    unset  __is_dir_esp_idf
							 
						 
					
						
							
								
									
										
										
										
											2020-08-17 12:08:32 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-04-29 10:37:02 +08: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 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-09-05 11:09:52 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    return  " $1 " 
							 
						 
					
						
							
								
									
										
										
										
											2019-04-29 10:37:02 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-08-17 12:08:32 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-10-06 13:48:11 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								__enable_autocomplete( )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-05-24 14:11:56 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    click_version = " $( python -c 'import click; print(click.__version__.split(".")[0])' ) " 
							 
						 
					
						
							
								
									
										
										
										
											2022-05-02 18:46:02 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  [  " ${ click_version } "  -lt 8  ] 
							 
						 
					
						
							
								
									
										
										
										
											2021-05-24 14:11:56 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    then 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        SOURCE_ZSH = source_zsh
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        SOURCE_BASH = source_bash
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    else 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        SOURCE_ZSH = zsh_source
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        SOURCE_BASH = bash_source
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    fi 
							 
						 
					
						
							
								
									
										
										
										
											2021-02-21 06:09:30 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  [  -n " ${ ZSH_VERSION - } "  ] 
							 
						 
					
						
							
								
									
										
										
										
											2020-11-02 14:11:14 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    then 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        autoload -Uz compinit &&  compinit -u
							 
						 
					
						
							
								
									
										
										
										
											2021-06-10 09:44:38 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        eval  " $( env _IDF.PY_COMPLETE= $SOURCE_ZSH  idf.py) "  ||  echo  " WARNING: Failed to load shell autocompletion for zsh version:  $ZSH_VERSION ! " 
							 
						 
					
						
							
								
									
										
										
										
											2021-02-28 23:26:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    elif  [  -n " ${ BASH_SOURCE - } "  ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    then 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-26 15:16:47 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        WARNING_MSG = " WARNING: Failed to load shell autocompletion for bash version:  $BASH_VERSION ! " 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-05 11:09:52 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        # shellcheck disable=SC3028,SC3054,SC2086,SC2169  # code block for 'bash' only 
							 
						 
					
						
							
								
									
										
										
										
											2022-05-02 18:46:02 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        [  ${ BASH_VERSINFO [0] }  -lt 4  ]  &&  {  echo  " $WARNING_MSG " ;  return ;  } 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-26 15:16:47 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        eval  " $( env LANG = en _IDF.PY_COMPLETE= $SOURCE_BASH  idf.py) "   ||  echo  " $WARNING_MSG " 
							 
						 
					
						
							
								
									
										
										
										
											2020-11-02 14:11:14 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    fi 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-10-11 14:11:09 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								__main &&  __enable_autocomplete
							 
						 
					
						
							
								
									
										
										
										
											2020-08-17 12:08:32 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								__cleanup $?