1@echo off
2if defined MSYSTEM (
3	echo This .bat file is for Windows CMD.EXE shell only. When using MSYS, run:
4	echo   ./install.sh.
5	goto end
6)
7
8:: Missing requirements check
9set MISSING_REQUIREMENTS=
10python.exe --version >NUL 2>NUL
11if %errorlevel% neq 0 set "MISSING_REQUIREMENTS=  python &echo\"
12git.exe --version >NUL 2>NUL
13if %errorlevel% neq 0 set "MISSING_REQUIREMENTS=%MISSING_REQUIREMENTS%  git"
14
15if not "%MISSING_REQUIREMENTS%" == "" goto :error_missing_requirements
16
17:: Infer IDF_PATH from script location
18set IDF_PATH=%~dp0
19set IDF_PATH=%IDF_PATH:~0,-1%
20
21set TARGETS="all"
22if NOT "%1"=="" set TARGETS=%*
23
24echo Installing ESP-IDF tools
25python.exe "%IDF_PATH%\tools\idf_tools.py" install --targets=%TARGETS%
26if %errorlevel% neq 0 goto :end
27
28echo Setting up Python environment
29python.exe "%IDF_PATH%\tools\idf_tools.py" install-python-env
30if %errorlevel% neq 0 goto :end
31
32echo All done! You can now run:
33echo    export.bat
34goto :end
35
36:error_missing_requirements
37    echo.
38    echo Error^: The following tools are not installed in your environment.
39    echo.
40    echo %MISSING_REQUIREMENTS%
41    echo.
42    echo Please use the Windows Tool installer for setting up your environment.
43    echo Download link: https://dl.espressif.com/dl/esp-idf/
44    echo For more details please visit our website: https://docs.espressif.com/projects/esp-idf/en/latest/esp32/get-started/windows-setup.html
45    goto :end
46
47:end
48