FormatChecks (#2)
All checks were successful
Bigfoot / Build & Test Debug (Unity Build: OFF) (push) Successful in 25s
Bigfoot / Build & Test Debug (Unity Build: ON) (push) Successful in 25s
Bigfoot / Build & Test RelWithDebInfo (Unity Build: OFF) (push) Successful in 25s
Bigfoot / Build & Test RelWithDebInfo (Unity Build: ON) (push) Successful in 25s
Bigfoot / Build & Test Release (Unity Build: OFF) (push) Successful in 20s
Bigfoot / Build & Test Release (Unity Build: ON) (push) Successful in 18s
Bigfoot / Clang Format Checks (push) Successful in 10s

Reviewed-on: #2
Co-authored-by: Romain BOULLARD <romain.boullard@protonmail.com>
Co-committed-by: Romain BOULLARD <romain.boullard@protonmail.com>
This commit was merged in pull request #2.
This commit is contained in:
2026-01-28 16:41:08 +00:00
committed by Romain BOULLARD
parent 6cd9801ef7
commit e78d648178
7 changed files with 148 additions and 56 deletions

View File

@@ -1,30 +1,71 @@
@echo off
REM Variable that will hold the name of the clang-format command
SETLOCAL ENABLEDELAYEDEXPANSION
REM =========================
REM Variables
REM =========================
SET FMT=clang-format
SET MODE=
SET EXIT_CODE=0
REM Function to format files
:format
for /r %%f in (*.h *.hpp *.m *.mm *.c *.cpp) do (
echo %%~nxf | findstr /i "_generated$" >nul
if errorlevel 1 (
echo format %%f
%FMT% -i "%%f"
REM =========================
REM Parse arguments
REM =========================
:parse_args
IF "%~1"=="" GOTO end_parse_args
IF "%~1"=="--check" (
SET MODE=check
) ELSE IF "%~1"=="--fix" (
SET MODE=fix
) ELSE (
REM Accumulate directories
SET DIRS=!DIRS! "%~1"
)
SHIFT
GOTO parse_args
:end_parse_args
IF "%MODE%"=="" (
ECHO Usage: %~nx0 --check|--fix <directory> [<directory> ...]
EXIT /B 1
)
IF "%DIRS%"=="" (
ECHO Please provide at least one directory.
EXIT /B 1
)
REM =========================
REM Iterate over directories
REM =========================
FOR %%D IN (%DIRS%) DO (
IF NOT EXIST "%%~D" (
ECHO %%~D is not a valid directory.
SET EXIT_CODE=1
GOTO :continue_dirs
)
)
echo ~~~ %1 Done ~~~
exit /b
REM Check if argument is provided
if "%1"=="" (
echo Please provide a directory as an argument.
exit /b
REM Recursively find source files
FOR /R "%%~D" %%F IN (*.h *.hpp *.c *.cpp *.m *.mm) DO (
SET FILE=%%F
REM Skip *_generated* files
ECHO !FILE! | FINDSTR /I "_generated" >nul
IF ERRORLEVEL 1 (
IF "%MODE%"=="fix" (
ECHO Formatting !FILE!
%FMT% -i "!FILE!"
) ELSE (
ECHO Checking !FILE!
%FMT% --dry-run --Werror "!FILE!" 2>nul
IF ERRORLEVEL 1 (
REM clang-format will already print diagnostics
SET EXIT_CODE=1
)
)
)
)
:continue_dirs
)
REM Check if directory exists
if not exist "%1" (
echo %1 is not a valid directory.
exit /b
)
cd %1
call :format
EXIT /B %EXIT_CODE%