Skip to content

Commit 2d90427

Browse files
committed
build config
1 parent 6799f64 commit 2d90427

4 files changed

Lines changed: 377 additions & 0 deletions

File tree

build.bat

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
@echo off
2+
echo Building SysMonitor...
3+
4+
g++ -std=c++11 -O3 ^
5+
-Iinclude -Isrc ^
6+
src/main.cpp ^
7+
src/monitor/SystemMonitor.cpp ^
8+
src/monitor/ProcessInfo.cpp ^
9+
src/visualizer/Visualizer.cpp ^
10+
src/optimizer/Optimizer.cpp ^
11+
src/utils/Config.cpp ^
12+
src/utils/Logger.cpp ^
13+
src/platform/WindowsPlatform.cpp ^
14+
-lpsapi -lpdh ^
15+
-Wl,--subsystem,console ^
16+
-o sysmonitor.exe
17+
18+
if %ERRORLEVEL% EQU 0 (
19+
echo.
20+
echo BUILD SUCCESSFUL!
21+
echo Run: sysmonitor.exe start
22+
) else (
23+
echo.
24+
echo Build failed
25+
pause
26+
)

build.ps1

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Simple PowerShell build script for SysMonitor
2+
Write-Host "Building SysMonitor..." -ForegroundColor Cyan
3+
4+
$sources = @(
5+
"src/main.cpp"
6+
"src/monitor/SystemMonitor.cpp"
7+
"src/monitor/ProcessInfo.cpp"
8+
"src/visualizer/Visualizer.cpp"
9+
"src/optimizer/Optimizer.cpp"
10+
"src/utils/Config.cpp"
11+
"src/utils/Logger.cpp"
12+
"src/platform/WindowsPlatform.cpp"
13+
)
14+
15+
# Build
16+
& g++ -std=c++11 -O3 `
17+
-Iinclude -Isrc `
18+
$sources `
19+
-lpsapi -lpdh `
20+
-Wl,--subsystem,console `
21+
-o sysmonitor.exe 2>&1
22+
23+
if ($LASTEXITCODE -eq 0) {
24+
Write-Host "`n? BUILD SUCCESSFUL!" -ForegroundColor Green
25+
Write-Host "Run: .\sysmonitor.exe start" -ForegroundColor Yellow
26+
} else {
27+
Write-Host "`n? Build failed" -ForegroundColor Red
28+
}

build_windows.bat

Lines changed: 178 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,178 @@
1+
@echo off
2+
REM ============================================================================
3+
REM FILE: build_windows.bat
4+
REM Windows Build Script for Command Prompt
5+
REM ============================================================================
6+
7+
echo ╔════════════════════════════════════════════════════════╗
8+
echo ║ SysMonitor Windows Build Script ║
9+
echo ╚════════════════════════════════════════════════════════╝
10+
echo.
11+
12+
REM Check if CMakeLists.txt exists
13+
if not exist "CMakeLists.txt" (
14+
echo ❌ Error: CMakeLists.txt not found!
15+
echo Please run this script from the sysmonitor root directory
16+
pause
17+
exit /b 1
18+
)
19+
20+
echo 📍 Current directory: %CD%
21+
echo.
22+
23+
REM Check for CMake
24+
echo 🔍 Checking for CMake...
25+
where cmake >nul 2>nul
26+
if %ERRORLEVEL% NEQ 0 (
27+
echo ❌ CMake not found!
28+
echo.
29+
echo Please install CMake:
30+
echo Option 1: choco install cmake
31+
echo Option 2: Download from https://cmake.org/download/
32+
pause
33+
exit /b 1
34+
)
35+
36+
for /f "tokens=*" %%i in ('cmake --version') do (
37+
echo ✓ Found: %%i
38+
goto :cmake_found
39+
)
40+
:cmake_found
41+
echo.
42+
43+
REM Detect build system
44+
echo 🔍 Detecting build system...
45+
46+
REM Check for MinGW
47+
where g++ >nul 2>nul
48+
if %ERRORLEVEL% EQU 0 (
49+
set BUILD_SYSTEM=MinGW
50+
set GENERATOR=MinGW Makefiles
51+
echo ✓ Found: MinGW (g++)
52+
goto :build_system_found
53+
)
54+
55+
REM Check for Visual Studio 2022
56+
where cl >nul 2>nul
57+
if %ERRORLEVEL% EQU 0 (
58+
set BUILD_SYSTEM=MSVC
59+
set GENERATOR=Visual Studio 17 2022
60+
echo ✓ Found: Visual Studio 2022
61+
goto :build_system_found
62+
)
63+
64+
REM Check for Visual Studio 2019
65+
if exist "C:\Program Files (x86)\Microsoft Visual Studio\2019" (
66+
set BUILD_SYSTEM=MSVC
67+
set GENERATOR=Visual Studio 16 2019
68+
echo ✓ Found: Visual Studio 2019
69+
goto :build_system_found
70+
)
71+
72+
REM No build system found
73+
echo ❌ No build system found!
74+
echo.
75+
echo Please install one of:
76+
echo 1. MinGW: choco install mingw
77+
echo 2. Visual Studio: https://visualstudio.microsoft.com/downloads/
78+
pause
79+
exit /b 1
80+
81+
:build_system_found
82+
echo Build System: %BUILD_SYSTEM%
83+
echo Generator: %GENERATOR%
84+
echo.
85+
86+
REM Clean build directory
87+
echo 🧹 Cleaning build directory...
88+
if exist "build" (
89+
rmdir /s /q build
90+
echo ✓ Removed old build directory
91+
)
92+
93+
mkdir build
94+
cd build
95+
echo ✓ Created fresh build directory
96+
echo.
97+
98+
REM Configure
99+
echo ⚙️ Configuring with CMake...
100+
101+
if "%BUILD_SYSTEM%"=="MinGW" (
102+
cmake .. -G "%GENERATOR%" -DCMAKE_BUILD_TYPE=Release
103+
) else (
104+
cmake .. -G "%GENERATOR%" -A x64
105+
)
106+
107+
if %ERRORLEVEL% NEQ 0 (
108+
echo ❌ CMake configuration failed!
109+
echo.
110+
echo Check the error messages above
111+
cd ..
112+
pause
113+
exit /b 1
114+
)
115+
116+
echo ✓ Configuration successful
117+
echo.
118+
119+
REM Build
120+
echo 🔨 Building SysMonitor...
121+
cmake --build . --config Release
122+
123+
if %ERRORLEVEL% NEQ 0 (
124+
echo ❌ Build failed!
125+
echo.
126+
echo Check the error messages above
127+
cd ..
128+
pause
129+
exit /b 1
130+
)
131+
132+
echo.
133+
echo ✓ Build successful!
134+
echo.
135+
136+
REM Test
137+
echo 🧪 Testing executable...
138+
139+
if "%BUILD_SYSTEM%"=="MinGW" (
140+
set EXE_PATH=bin\sysmonitor.exe
141+
) else (
142+
set EXE_PATH=bin\Release\sysmonitor.exe
143+
)
144+
145+
if exist "%EXE_PATH%" (
146+
echo ✓ Found: %EXE_PATH%
147+
echo.
148+
149+
REM Test version
150+
echo 🎯 Testing version command...
151+
"%EXE_PATH%" --version
152+
153+
if %ERRORLEVEL% EQU 0 (
154+
echo.
155+
echo ╔════════════════════════════════════════════════════════╗
156+
echo ║ 🎉 BUILD SUCCESSFUL! 🎉 ║
157+
echo ╚════════════════════════════════════════════════════════╝
158+
echo.
159+
echo To run SysMonitor:
160+
echo cd %CD%
161+
echo %EXE_PATH% start
162+
echo.
163+
echo Or with optimization (requires Administrator):
164+
echo %EXE_PATH% start -o
165+
echo.
166+
echo To install system-wide (requires Administrator):
167+
echo copy %EXE_PATH% C:\Windows\System32\
168+
echo (then run from anywhere: sysmonitor start^)
169+
echo.
170+
)
171+
) else (
172+
echo ❌ Error: sysmonitor.exe not found!
173+
echo Expected: %CD%\%EXE_PATH%
174+
dir bin /s
175+
)
176+
177+
cd ..
178+
pause

build_windows.sh

Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
#!/bin/bash
2+
# ============================================================================
3+
# FILE: build_windows.sh
4+
# Windows Build Script for MinGW/Git Bash
5+
# ============================================================================
6+
7+
echo "╔════════════════════════════════════════════════════════╗"
8+
echo "║ SysMonitor Windows Build Script (MinGW) ║"
9+
echo "╚════════════════════════════════════════════════════════╝"
10+
echo ""
11+
12+
# Colors
13+
RED='\033[0;31m'
14+
GREEN='\033[0;32m'
15+
YELLOW='\033[1;33m'
16+
NC='\033[0m' # No Color
17+
18+
# Check if we're in the right directory
19+
if [ ! -f "CMakeLists.txt" ]; then
20+
echo -e "${RED}❌ Error: CMakeLists.txt not found!${NC}"
21+
echo "Please run this script from the sysmonitor root directory"
22+
exit 1
23+
fi
24+
25+
echo "📍 Current directory: $(pwd)"
26+
echo ""
27+
28+
# Check for g++
29+
echo "🔍 Checking for g++ (MinGW)..."
30+
if ! command -v g++ &> /dev/null; then
31+
echo -e "${RED}❌ g++ not found!${NC}"
32+
echo ""
33+
echo "Please install MinGW-w64:"
34+
echo " Option 1: choco install mingw"
35+
echo " Option 2: Download from https://www.mingw-w64.org/downloads/"
36+
exit 1
37+
fi
38+
39+
GCC_VERSION=$(g++ --version | head -n1)
40+
echo -e "${GREEN}✓ Found: $GCC_VERSION${NC}"
41+
echo ""
42+
43+
# Check for CMake
44+
echo "🔍 Checking for CMake..."
45+
if ! command -v cmake &> /dev/null; then
46+
echo -e "${RED}❌ CMake not found!${NC}"
47+
echo ""
48+
echo "Please install CMake:"
49+
echo " Option 1: choco install cmake"
50+
echo " Option 2: Download from https://cmake.org/download/"
51+
exit 1
52+
fi
53+
54+
CMAKE_VERSION=$(cmake --version | head -n1)
55+
echo -e "${GREEN}✓ Found: $CMAKE_VERSION${NC}"
56+
echo ""
57+
58+
# Clean build directory
59+
echo "🧹 Cleaning build directory..."
60+
if [ -d "build" ]; then
61+
rm -rf build
62+
echo -e "${GREEN}✓ Removed old build directory${NC}"
63+
fi
64+
65+
mkdir build
66+
cd build
67+
echo -e "${GREEN}✓ Created fresh build directory${NC}"
68+
echo ""
69+
70+
# Configure
71+
echo "⚙️ Configuring with CMake (MinGW Makefiles)..."
72+
cmake .. -G "MinGW Makefiles" \
73+
-DCMAKE_C_COMPILER=gcc \
74+
-DCMAKE_CXX_COMPILER=g++ \
75+
-DCMAKE_BUILD_TYPE=Release
76+
77+
if [ $? -ne 0 ]; then
78+
echo -e "${RED}❌ CMake configuration failed!${NC}"
79+
echo ""
80+
echo "Troubleshooting tips:"
81+
echo " 1. Ensure MinGW is in your PATH"
82+
echo " 2. Try running: export PATH=/mingw64/bin:\$PATH"
83+
echo " 3. Check CMakeCache.txt for errors"
84+
exit 1
85+
fi
86+
87+
echo -e "${GREEN}✓ Configuration successful${NC}"
88+
echo ""
89+
90+
# Build
91+
echo "🔨 Building SysMonitor..."
92+
cmake --build . --config Release
93+
94+
if [ $? -ne 0 ]; then
95+
echo -e "${RED}❌ Build failed!${NC}"
96+
echo ""
97+
echo "Check the error messages above for details"
98+
exit 1
99+
fi
100+
101+
echo ""
102+
echo -e "${GREEN}✓ Build successful!${NC}"
103+
echo ""
104+
105+
# Test
106+
echo "🧪 Testing executable..."
107+
if [ -f "bin/sysmonitor.exe" ]; then
108+
echo -e "${GREEN}✓ Found: bin/sysmonitor.exe${NC}"
109+
echo ""
110+
111+
# Get file size
112+
SIZE=$(du -h bin/sysmonitor.exe | cut -f1)
113+
echo "📦 Size: $SIZE"
114+
echo ""
115+
116+
# Test version
117+
echo "🎯 Testing version command..."
118+
./bin/sysmonitor.exe --version
119+
120+
if [ $? -eq 0 ]; then
121+
echo ""
122+
echo -e "${GREEN}╔════════════════════════════════════════════════════════╗${NC}"
123+
echo -e "${GREEN}║ 🎉 BUILD SUCCESSFUL! 🎉 ║${NC}"
124+
echo -e "${GREEN}╚════════════════════════════════════════════════════════╝${NC}"
125+
echo ""
126+
echo "To run SysMonitor:"
127+
echo " cd $(pwd)"
128+
echo " ./bin/sysmonitor.exe start"
129+
echo ""
130+
echo "Or with optimization (requires Administrator):"
131+
echo " ./bin/sysmonitor.exe start -o"
132+
echo ""
133+
echo "To install system-wide:"
134+
echo " cp bin/sysmonitor.exe /c/Windows/System32/"
135+
echo " (then run from anywhere: sysmonitor start)"
136+
echo ""
137+
else
138+
echo -e "${YELLOW}⚠ Warning: Executable exists but version test failed${NC}"
139+
fi
140+
else
141+
echo -e "${RED}❌ Error: sysmonitor.exe not found in bin/${NC}"
142+
echo "Expected: $(pwd)/bin/sysmonitor.exe"
143+
ls -la bin/ 2>/dev/null || echo "bin/ directory doesn't exist"
144+
exit 1
145+
fi

0 commit comments

Comments
 (0)