-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.bat
More file actions
152 lines (119 loc) · 2.69 KB
/
build.bat
File metadata and controls
152 lines (119 loc) · 2.69 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
@echo off
setlocal EnableExtensions EnableDelayedExpansion
REM Defaults
set "EXEC_NAME=sessionstealer"
set "BUILD_TYPE=Release"
set "RUN_EXEC=0"
set "RUN_ARGS="
REM Argument parsing
:parse_args
if "%~1"=="" goto build
if /I "%~1"=="-d" (
set "BUILD_TYPE=Debug"
shift
goto parse_args
)
if /I "%~1"=="-r" (
set "RUN_EXEC=1"
shift
goto collect_run_args
)
if /I "%~1"=="-c" (
set "CHECK_ONLY=1"
goto code_check
)
REM Unknown argument
echo Unknown argument: %~1
goto usage
REM Collect remaining args for runtime
:collect_run_args
if "%~1"=="" goto build
if defined RUN_ARGS (
set "RUN_ARGS=!RUN_ARGS! %~1"
) else (
set "RUN_ARGS=%~1"
)
shift
goto collect_run_args
REM Build
:build
if not defined VCPKG_ROOT (
echo ERROR: VCPKG_ROOT is not set
exit /b 1
)
set "BUILD_DIR=build"
if not exist "%BUILD_DIR%" mkdir "%BUILD_DIR%"
echo.
echo Configuring (%BUILD_TYPE%)...
cmake -S . -B "%BUILD_DIR%" ^
-DCMAKE_TOOLCHAIN_FILE="%VCPKG_ROOT%\scripts\buildsystems\vcpkg.cmake" ^
-DCMAKE_BUILD_TYPE=%BUILD_TYPE% ^
-DEXECUTABLE_OUTPUT_NAME=%EXEC_NAME%
if errorlevel 1 (
echo.
echo [ERROR] CMake configuration failed.
exit /b 1
)
echo.
echo Building...
cmake --build "%BUILD_DIR%" --config %BUILD_TYPE%
if errorlevel 1 (
echo.
echo [ERROR] Build failed.
exit /b 1
)
REM Run tests automatically in Debug
if "%BUILD_TYPE%"=="Debug" (
echo.
echo Running tests...
ctest --test-dir "%BUILD_DIR%" -C %BUILD_TYPE% --output-on-failure
if errorlevel 1 (
echo.
echo [ERROR] Tests failed.
exit /b 1
)
)
REM Run
if "%RUN_EXEC%"=="1" (
echo.
echo Running "%BUILD_DIR%\bin\%BUILD_TYPE%\%EXEC_NAME%.exe" %RUN_ARGS%
"%BUILD_DIR%\bin\%BUILD_TYPE%\%EXEC_NAME%.exe" %RUN_ARGS%
)
endlocal
exit /b 0
REM --------------------------
:usage
echo.
echo Usage: %~nx0 [-d] [-r [args]]
echo.
echo -d Build in Debug mode (default is Release), automatically runs tests
echo -r [args] Run the executable after build with optional arguments
echo -c Run Cppcheck only, do not build
echo.
exit /b 1
REM --------------------------
:code_check
where cppcheck >nul 2>&1
if errorlevel 1 (
echo Cppcheck not found
exit /b 1
)
cppcheck ^
--enable=all ^
--inconclusive ^
--force ^
--inline-suppr ^
--std=c++23 ^
--quiet ^
--suppress=missingIncludeSystem ^
--suppress=unusedFunction:*_exports.c ^
--suppress=unusedFunction:dlls/chromium/* ^
-I"%CD%\include" ^
-I"%CD%\include\dlls" ^
"%CD%\src" ^
"%CD%\dlls" ^
"%CD%\shared" ^
"%CD%\tests"
set "CPPCHECK_EXIT=%ERRORLEVEL%"
echo Cppcheck finished with exit code %CPPCHECK_EXIT%
exit /b %CPPCHECK_EXIT%