-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild_windows.bat
More file actions
178 lines (152 loc) · 4.46 KB
/
build_windows.bat
File metadata and controls
178 lines (152 loc) · 4.46 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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
@echo off
REM ============================================================================
REM FILE: build_windows.bat
REM Windows Build Script for Command Prompt
REM ============================================================================
echo ╔════════════════════════════════════════════════════════╗
echo ║ SysMonitor Windows Build Script ║
echo ╚════════════════════════════════════════════════════════╝
echo.
REM Check if CMakeLists.txt exists
if not exist "CMakeLists.txt" (
echo ❌ Error: CMakeLists.txt not found!
echo Please run this script from the sysmonitor root directory
pause
exit /b 1
)
echo 📍 Current directory: %CD%
echo.
REM Check for CMake
echo 🔍 Checking for CMake...
where cmake >nul 2>nul
if %ERRORLEVEL% NEQ 0 (
echo ❌ CMake not found!
echo.
echo Please install CMake:
echo Option 1: choco install cmake
echo Option 2: Download from https://cmake.org/download/
pause
exit /b 1
)
for /f "tokens=*" %%i in ('cmake --version') do (
echo ✓ Found: %%i
goto :cmake_found
)
:cmake_found
echo.
REM Detect build system
echo 🔍 Detecting build system...
REM Check for MinGW
where g++ >nul 2>nul
if %ERRORLEVEL% EQU 0 (
set BUILD_SYSTEM=MinGW
set GENERATOR=MinGW Makefiles
echo ✓ Found: MinGW (g++)
goto :build_system_found
)
REM Check for Visual Studio 2022
where cl >nul 2>nul
if %ERRORLEVEL% EQU 0 (
set BUILD_SYSTEM=MSVC
set GENERATOR=Visual Studio 17 2022
echo ✓ Found: Visual Studio 2022
goto :build_system_found
)
REM Check for Visual Studio 2019
if exist "C:\Program Files (x86)\Microsoft Visual Studio\2019" (
set BUILD_SYSTEM=MSVC
set GENERATOR=Visual Studio 16 2019
echo ✓ Found: Visual Studio 2019
goto :build_system_found
)
REM No build system found
echo ❌ No build system found!
echo.
echo Please install one of:
echo 1. MinGW: choco install mingw
echo 2. Visual Studio: https://visualstudio.microsoft.com/downloads/
pause
exit /b 1
:build_system_found
echo Build System: %BUILD_SYSTEM%
echo Generator: %GENERATOR%
echo.
REM Clean build directory
echo 🧹 Cleaning build directory...
if exist "build" (
rmdir /s /q build
echo ✓ Removed old build directory
)
mkdir build
cd build
echo ✓ Created fresh build directory
echo.
REM Configure
echo ⚙️ Configuring with CMake...
if "%BUILD_SYSTEM%"=="MinGW" (
cmake .. -G "%GENERATOR%" -DCMAKE_BUILD_TYPE=Release
) else (
cmake .. -G "%GENERATOR%" -A x64
)
if %ERRORLEVEL% NEQ 0 (
echo ❌ CMake configuration failed!
echo.
echo Check the error messages above
cd ..
pause
exit /b 1
)
echo ✓ Configuration successful
echo.
REM Build
echo 🔨 Building SysMonitor...
cmake --build . --config Release
if %ERRORLEVEL% NEQ 0 (
echo ❌ Build failed!
echo.
echo Check the error messages above
cd ..
pause
exit /b 1
)
echo.
echo ✓ Build successful!
echo.
REM Test
echo 🧪 Testing executable...
if "%BUILD_SYSTEM%"=="MinGW" (
set EXE_PATH=bin\sysmonitor.exe
) else (
set EXE_PATH=bin\Release\sysmonitor.exe
)
if exist "%EXE_PATH%" (
echo ✓ Found: %EXE_PATH%
echo.
REM Test version
echo 🎯 Testing version command...
"%EXE_PATH%" --version
if %ERRORLEVEL% EQU 0 (
echo.
echo ╔════════════════════════════════════════════════════════╗
echo ║ 🎉 BUILD SUCCESSFUL! 🎉 ║
echo ╚════════════════════════════════════════════════════════╝
echo.
echo To run SysMonitor:
echo cd %CD%
echo %EXE_PATH% start
echo.
echo Or with optimization (requires Administrator):
echo %EXE_PATH% start -o
echo.
echo To install system-wide (requires Administrator):
echo copy %EXE_PATH% C:\Windows\System32\
echo (then run from anywhere: sysmonitor start^)
echo.
)
) else (
echo ❌ Error: sysmonitor.exe not found!
echo Expected: %CD%\%EXE_PATH%
dir bin /s
)
cd ..
pause