feat(tools): produce correct err code in export/install .bat scripts

Plus unify labels to begin with underscore
This commit is contained in:
Marek Fiala
2024-02-23 17:17:47 +01:00
parent d183000311
commit c21cdf0a1f
2 changed files with 49 additions and 19 deletions

View File

@@ -4,12 +4,20 @@ if defined MSYSTEM (
goto :eof
)
set SCRIPT_EXIT_CODE=0
:: Missing requirements check
set MISSING_REQUIREMENTS=
python.exe --version >NUL 2>NUL
if %errorlevel% neq 0 set "MISSING_REQUIREMENTS= python &echo\"
if %errorlevel% neq 0 (
set SCRIPT_EXIT_CODE=%errorlevel%
set "MISSING_REQUIREMENTS= python &echo\"
)
git.exe --version >NUL 2>NUL
if %errorlevel% neq 0 set "MISSING_REQUIREMENTS=%MISSING_REQUIREMENTS% git"
if %errorlevel% neq 0 (
set SCRIPT_EXIT_CODE=%errorlevel%
set "MISSING_REQUIREMENTS=%MISSING_REQUIREMENTS% git"
)
if not "%MISSING_REQUIREMENTS%" == "" goto :__error_missing_requirements
@@ -34,7 +42,10 @@ echo Adding ESP-IDF tools to PATH...
:: but that way it is impossible to get the exit code of idf_tools.py.
set "IDF_TOOLS_EXPORTS_FILE=%TEMP%\idf_export_vars.tmp"
python.exe "%IDF_PATH%\tools\idf_tools.py" export --format key-value >"%IDF_TOOLS_EXPORTS_FILE%"
if %errorlevel% neq 0 goto :__end
if %errorlevel% neq 0 (
set SCRIPT_EXIT_CODE=%errorlevel%
goto :__end
)
for /f "usebackq tokens=1,2 eol=# delims==" %%a in ("%IDF_TOOLS_EXPORTS_FILE%") do (
call set "%%a=%%b"
@@ -55,7 +66,10 @@ DOSKEY parttool.py=python.exe "%IDF_PATH%\components\partition_table\parttool.py
echo Checking if Python packages are up to date...
python.exe "%IDF_PATH%\tools\idf_tools.py" check-python-dependencies
if %errorlevel% neq 0 goto :__end
if %errorlevel% neq 0 (
set SCRIPT_EXIT_CODE=%errorlevel%
goto :__end
)
python.exe "%IDF_PATH%\tools\idf_tools.py" uninstall --dry-run > UNINSTALL_OUTPUT
SET /p UNINSTALL=<UNINSTALL_OUTPUT
@@ -110,3 +124,4 @@ set OLD_PATH=
set PATH_ADDITIONS=
set MISSING_REQUIREMENTS=
set UNINSTALL=
exit /b %SCRIPT_EXIT_CODE%