Skip to content

Instantly share code, notes, and snippets.

@mdeweerd
Forked from GaryLee/build.bat
Last active March 3, 2025 15:20
Show Gist options
  • Save mdeweerd/6cbd52b4f95be062180a68fb5be1ec36 to your computer and use it in GitHub Desktop.
Save mdeweerd/6cbd52b4f95be062180a68fb5be1ec36 to your computer and use it in GitHub Desktop.
Build STM32CubeIDE project from command line.
@ECHO OFF
setlocal enabledelayedexpansion
set "STM32CUBEIDE="
for /d /r "C:\ST" %%d in ("STM32CubeIDE_*") do (
if not defined STM32CUBEIDE (
set "STM32CUBEIDE=%%~fd"
) else (
for /f "tokens=2 delims=_." %%a in ("%%~nd") do (
for /f "tokens=2 delims=_." %%b in ("!STM32CUBEIDE:_= !") do (
if %%a gtr %%b set "STM32CUBEIDE=%%~fd"
)
)
)
)
if not defined STM32CUBEIDE (
echo "STM32CubeIDE not found in C:\ST"
exit /b 1
)
set "SCRIPT_DIR=%~dp0"
for %%i in ("%SCRIPT_DIR:~0,-1%") do set "SCRIPT_DIR=%%~fi"
for %%i in ("%~dp0.") do set "SCRIPT_NAME=%%~ni"
"%STM32CUBEIDE%\STM32CubeIDE\stm32cubeidec.exe" --launcher.suppressErrors -nosplash -application org.eclipse.cdt.managedbuilder.core.headlessbuild -data "%SCRIPT_DIR%\.." -cleanBuild "%SCRIPT_NAME%"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment