]> granicus.if.org Git - esp-idf/blob - export.bat
Merge branch 'feature/esp32s2beta_merge_fix_bootloader_ld' into 'feature/esp32s2beta'
[esp-idf] / export.bat
1 @echo off
2 if defined MSYSTEM (
3     echo This .bat file is for Windows CMD.EXE shell only. When using MSYS, run:
4     echo   . ./export.sh.
5     goto :eof
6 )
7
8 :: Infer IDF_PATH from script location
9 set IDF_PATH=%~dp0
10 set IDF_PATH=%IDF_PATH:~0,-1%
11
12 set IDF_TOOLS_PY_PATH=%IDF_PATH%\tools\idf_tools.py
13 set IDF_TOOLS_JSON_PATH=%IDF_PATH%\tools\tools.json
14 set IDF_TOOLS_EXPORT_CMD=%IDF_PATH%\export.bat
15 set IDF_TOOLS_INSTALL_CMD=%IDF_PATH%\install.bat
16 echo Setting IDF_PATH: %IDF_PATH%
17 echo.
18
19 set "OLD_PATH=%PATH%"
20 echo Adding ESP-IDF tools to PATH...
21 :: Export tool paths and environment variables.
22 :: It is possible to do this without a temporary file (running idf_tools.py from for /r command),
23 :: but that way it is impossible to get the exit code of idf_tools.py.
24 set "IDF_TOOLS_EXPORTS_FILE=%TEMP%\idf_export_vars.tmp"
25 python.exe %IDF_PATH%\tools\idf_tools.py export --format key-value >"%IDF_TOOLS_EXPORTS_FILE%"
26 if %errorlevel% neq 0 goto :end
27
28 for /f "usebackq tokens=1,2 eol=# delims==" %%a in ("%IDF_TOOLS_EXPORTS_FILE%") do (
29       call set "%%a=%%b"
30     )
31
32 :: This removes OLD_PATH substring from PATH, leaving only the paths which have been added,
33 :: and prints semicolon-delimited components of the path on separate lines
34 call set PATH_ADDITIONS=%%PATH:%OLD_PATH%=%%
35 if "%PATH_ADDITIONS%"=="" call :print_nothing_added
36 if not "%PATH_ADDITIONS%"=="" echo     %PATH_ADDITIONS:;=&echo.    %
37
38 echo Checking if Python packages are up to date...
39 python.exe %IDF_PATH%\tools\check_python_dependencies.py
40 if %errorlevel% neq 0 goto :end
41
42 echo.
43 echo Done! You can now compile ESP-IDF projects.
44 echo Go to the project directory and run:
45 echo.
46 echo   idf.py build
47 echo.
48
49 goto :end
50
51 :print_nothing_added
52     echo No directories added to PATH:
53     echo.
54     echo %PATH%
55     echo.
56     goto :eof
57
58 :end
59
60 :: Clean up
61 if not "%IDF_TOOLS_EXPORTS_FILE%"=="" (
62     del "%IDF_TOOLS_EXPORTS_FILE%" 1>nul 2>nul
63 )
64 set IDF_TOOLS_EXPORTS_FILE=
65 set IDF_TOOLS_EXPORT_CMD=
66 set IDF_TOOLS_INSTALL_CMD=
67 set IDF_TOOLS_PY_PATH=
68 set IDF_TOOLS_JSON_PATH=
69 set OLD_PATH=
70 set PATH_ADDITIONS=