本地工具路径DTU_*环境变量改造落地:10处调用点去硬编码+变量优先解析,本机全链路验证通过,文档同步收口,requirements补pre-commit

This commit is contained in:
2026-10-02 22:14:49 +08:00
parent b96d649e62
commit 33a4aa4945
30 changed files with 4074 additions and 2917 deletions
+31 -4
View File
@@ -1,11 +1,38 @@
@echo off
setlocal
set STLINK=C:\Program Files (x86)\STMicroelectronics\STM32 ST-LINK Utility\ST-LINK Utility\ST-LINK_CLI.exe
if not exist "%STLINK%" (
echo RESET_FAIL: ST-LINK_CLI not found at "%STLINK%"
exit /b 2
:: ST-LINK CLI location: env var DTU_STLINK_CLI = full path of ST-LINK_CLI.exe.
:: Explicit value is used as-is (invalid value = hard error, no silent fallback);
:: when unset, fall back to PATH (where ST-LINK_CLI.exe).
set "STLINK="
if defined DTU_STLINK_CLI goto stlink_check
where ST-LINK_CLI.exe >nul 2>&1
if errorlevel 1 goto stlink_missing
for /f "delims=" %%i in ('where ST-LINK_CLI.exe 2^>nul') do (
if not defined STLINK set "STLINK=%%i"
)
if not defined STLINK goto stlink_missing
goto stlink_done
:stlink_check
if exist "%DTU_STLINK_CLI%" goto stlink_done
echo ENV_ERROR: DTU_STLINK_CLI is set but does not exist: "%DTU_STLINK_CLI%"
echo Fix the variable value. No fallback to PATH or other installs is attempted.
exit /b 2
:stlink_missing
echo ENV_ERROR: ST-LINK_CLI.exe not found (DTU_STLINK_CLI unset and not on PATH)
echo Set it to the full path of ST-LINK_CLI.exe, e.g.:
echo [Environment]::SetEnvironmentVariable('DTU_STLINK_CLI', 'C:\Tools\STLink\ST-LINK_CLI.exe', 'User')
exit /b 2
:stlink_done
if not defined STLINK set "STLINK=%DTU_STLINK_CLI%"
if exist "%STLINK%" goto stlink_ready
echo RESET_FAIL: ST-LINK_CLI not found at "%STLINK%"
exit /b 2
:stlink_ready
if "%~1"=="" goto :reset_run
if /i "%~1"=="hard" goto :hard