forked from cppcheck-opensource/simplecpp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrunastyle.bat
More file actions
53 lines (46 loc) · 1.56 KB
/
runastyle.bat
File metadata and controls
53 lines (46 loc) · 1.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
@ECHO off
REM Script to run AStyle on the sources
REM The version check in this script is used to avoid commit battles
REM between different developers that use different astyle versions as
REM different versions might have different output (this has happened in
REM the past).
REM Get the directory of the script
SET SCRIPT_DIR=%~dp0
REM Change to that directory
CD /d %SCRIPT_DIR%
REM To require a newer astyle version, update ASTYLE_VERSION below.
REM ASTYLE_VERSION_STR is then constructed to match the beginning of the
REM version string reported by "astyle --version".
SET ASTYLE_VERSION="3.4.13"
SET ASTYLE_VERSION_STR="Artistic Style Version %ASTYLE_VERSION%"
REM Prefer system astyle; else try uvx; else pipx
SET "ASTYLE=astyle"
where astyle >nul 2>nul
IF %errorlevel% neq 0 (
where uvx >nul 2>nul
IF %errorlevel% eq 0 (
SET "ASTYLE=uvx --quiet astyle==%ASTYLE_VERSION%"
) ELSE (
where pipx >nul 2>nul
IF %errorlevel% eq 0 (
SET "ASTYLE=pipx run --quiet astyle==%ASTYLE_VERSION%"
) ELSE (
ECHO ERROR: Neither astyle, uvx, nor pipx found in PATH.
GOTO EXIT_ERROR
)
)
)
SET DETECTED_VERSION_STR=""
FOR /F "tokens=*" %%i IN ('%ASTYLE% --version') DO SET DETECTED_VERSION_STR=%%i
ECHO %DETECTED_VERSION_STR% | FINDSTR /B /C:%ASTYLE_VERSION_STR% > nul && (
ECHO "%DETECTED_VERSION_STR%" matches %ASTYLE_VERSION_STR%
) || (
ECHO You should use: %ASTYLE_VERSION_STR%
ECHO Detected: "%DETECTED_VERSION_STR%"
GOTO EXIT_ERROR
)
REM Run astyle with the project config
%ASTYLE% --project *.h,*.cpp
GOTO :EOF
:EXIT_ERROR
EXIT /b 1