From 6979433dbd8e49ada0eadba2357bcdc085a161bc Mon Sep 17 00:00:00 2001 From: Marek Fiala Date: Tue, 9 Mar 2021 12:53:11 +0100 Subject: [PATCH] Human-readable error if Git or Python are missing. When user forgot to add git.exe or python to the PATH, there was a not very helpful error message. This improves the error with which tool is misssing and shows a link to the espressif installer tool. --- export.bat | 28 ++++++++++++++++++++++++++++ install.bat | 22 ++++++++++++++++++++++ 2 files changed, 50 insertions(+) diff --git a/export.bat b/export.bat index 51a3965ce6..cba8e4206d 100644 --- a/export.bat +++ b/export.bat @@ -5,6 +5,22 @@ if defined MSYSTEM ( goto :eof ) +:: Missing requirements check +set MISSING_REQUIREMENTS= +python.exe --version >NUL 2>NUL +if %errorlevel% neq 0 set "MISSING_REQUIREMENTS= python &echo\" +git.exe --version >NUL 2>NUL +if %errorlevel% neq 0 set "MISSING_REQUIREMENTS=%MISSING_REQUIREMENTS% git" + +if not "%MISSING_REQUIREMENTS%" == "" goto :error_missing_requirements + +set PREFIX=python.exe %IDF_PATH% +DOSKEY idf.py=%PREFIX%\tools\idf.py $* +DOSKEY esptool.py=%PREFIX%\components\esptool_py\esptool\esptool.py $* +DOSKEY espefuse.py=%PREFIX%\components\esptool_py\esptool\espefuse.py $* +DOSKEY otatool.py=%PREFIX%\components\app_update\otatool.py $* +DOSKEY parttool.py=%PREFIX%\components\partition_table\parttool.py $* + :: Infer IDF_PATH from script location set IDF_PATH=%~dp0 set IDF_PATH=%IDF_PATH:~0,-1% @@ -55,6 +71,17 @@ goto :end echo. goto :eof +:error_missing_requirements + echo. + echo Error^: The following tools are not installed in your environment. + echo. + echo %MISSING_REQUIREMENTS% + echo. + echo Please use the Windows Tool installer for setting up your environment. + echo Download link: https://dl.espressif.com/dl/esp-idf/ + echo For more details please visit our website: https://docs.espressif.com/projects/esp-idf/en/latest/esp32/get-started/windows-setup.html + goto :end + :end :: Clean up @@ -68,3 +95,4 @@ set IDF_TOOLS_PY_PATH= set IDF_TOOLS_JSON_PATH= set OLD_PATH= set PATH_ADDITIONS= +set MISSING_REQUIREMENTS= diff --git a/install.bat b/install.bat index 784fd850cd..8b0958d8f4 100644 --- a/install.bat +++ b/install.bat @@ -4,6 +4,16 @@ if defined MSYSTEM ( echo ./install.sh. goto end ) + +:: Missing requirements check +set MISSING_REQUIREMENTS= +python.exe --version >NUL 2>NUL +if %errorlevel% neq 0 set "MISSING_REQUIREMENTS= python &echo\" +git.exe --version >NUL 2>NUL +if %errorlevel% neq 0 set "MISSING_REQUIREMENTS=%MISSING_REQUIREMENTS% git" + +if not "%MISSING_REQUIREMENTS%" == "" goto :error_missing_requirements + :: Infer IDF_PATH from script location set IDF_PATH=%~dp0 set IDF_PATH=%IDF_PATH:~0,-1% @@ -18,5 +28,17 @@ if %errorlevel% neq 0 goto :end echo All done! You can now run: echo export.bat +goto :end + +:error_missing_requirements + echo. + echo Error^: The following tools are not installed in your environment. + echo. + echo %MISSING_REQUIREMENTS% + echo. + echo Please use the Windows Tool installer for setting up your environment. + echo Download link: https://dl.espressif.com/dl/esp-idf/ + echo For more details please visit our website: https://docs.espressif.com/projects/esp-idf/en/latest/esp32/get-started/windows-setup.html + goto :end :end