-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup_windows.ps1
More file actions
204 lines (165 loc) · 6.89 KB
/
setup_windows.ps1
File metadata and controls
204 lines (165 loc) · 6.89 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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
# QR Generator - Windows Setup Script
# Skrypt automatycznej konfiguracji dla Visual Studio 2019
param(
[switch]$SkipVcpkg = $false,
[switch]$SkipBuild = $false,
[string]$VcpkgRoot = "$env:USERPROFILE\vcpkg"
)
$ErrorActionPreference = "Stop"
Write-Host "========================================" -ForegroundColor Cyan
Write-Host "QR Generator - Windows Setup" -ForegroundColor Cyan
Write-Host "========================================" -ForegroundColor Cyan
Write-Host ""
# Funkcja sprawdzająca czy komenda istnieje
function Test-Command {
param($Command)
$null -ne (Get-Command $Command -ErrorAction SilentlyContinue)
}
# Sprawdź wymagane narzędzia
Write-Host "[1/6] Sprawdzanie wymaganych narzędzi..." -ForegroundColor Yellow
if (-not (Test-Command "cmake")) {
Write-Host "BŁĄD: CMake nie jest zainstalowany!" -ForegroundColor Red
Write-Host "Pobierz z: https://cmake.org/download/" -ForegroundColor Yellow
exit 1
}
$cmakeVersion = (cmake --version | Select-String -Pattern "(\d+\.\d+\.\d+)").Matches.Groups[1].Value
Write-Host " ✓ CMake $cmakeVersion" -ForegroundColor Green
# Sprawdź Visual Studio 2019
$vsPath = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\2019"
$vsEditions = @("Enterprise", "Professional", "Community", "BuildTools")
$vsFound = $false
foreach ($edition in $vsEditions) {
$path = Join-Path $vsPath $edition
if (Test-Path $path) {
Write-Host " ✓ Visual Studio 2019 $edition" -ForegroundColor Green
$vsFound = $true
break
}
}
if (-not $vsFound) {
Write-Host "BŁĄD: Visual Studio 2019 nie jest zainstalowany!" -ForegroundColor Red
Write-Host "Pobierz z: https://visualstudio.microsoft.com/vs/older-downloads/" -ForegroundColor Yellow
Write-Host "Wymagane komponenty:" -ForegroundColor Yellow
Write-Host " - Desktop development with C++" -ForegroundColor Yellow
Write-Host " - CMake tools for Windows" -ForegroundColor Yellow
exit 1
}
# Konfiguracja vcpkg
if (-not $SkipVcpkg) {
Write-Host ""
Write-Host "[2/6] Konfiguracja vcpkg..." -ForegroundColor Yellow
if (-not (Test-Path $VcpkgRoot)) {
Write-Host " Klonowanie vcpkg do $VcpkgRoot..." -ForegroundColor Cyan
git clone https://github.com/Microsoft/vcpkg.git $VcpkgRoot
Write-Host " Bootstrapping vcpkg..." -ForegroundColor Cyan
& "$VcpkgRoot\bootstrap-vcpkg.bat"
} else {
Write-Host " ✓ vcpkg już zainstalowany w $VcpkgRoot" -ForegroundColor Green
# Aktualizacja vcpkg
Write-Host " Aktualizacja vcpkg..." -ForegroundColor Cyan
Push-Location $VcpkgRoot
git pull
Pop-Location
}
# Ustaw zmienną środowiskową
$env:VCPKG_ROOT = $VcpkgRoot
[Environment]::SetEnvironmentVariable("VCPKG_ROOT", $VcpkgRoot, "User")
Write-Host " ✓ VCPKG_ROOT = $VcpkgRoot" -ForegroundColor Green
# Instalacja zależności
Write-Host ""
Write-Host "[3/6] Instalacja zależności przez vcpkg..." -ForegroundColor Yellow
Write-Host " To może potrwać 30-60 minut przy pierwszym uruchomieniu..." -ForegroundColor Cyan
$vcpkgExe = Join-Path $VcpkgRoot "vcpkg.exe"
Write-Host " Instalacja Qt6..." -ForegroundColor Cyan
& $vcpkgExe install qtbase:x64-windows
& $vcpkgExe install qt6-tools:x64-windows
Write-Host " Instalacja OpenCV..." -ForegroundColor Cyan
& $vcpkgExe install opencv4[core,imgproc,imgcodecs,objdetect,videoio]:x64-windows
Write-Host " Instalacja libqrencode..." -ForegroundColor Cyan
& $vcpkgExe install libqrencode:x64-windows
Write-Host " ✓ Wszystkie zależności zainstalowane" -ForegroundColor Green
} else {
Write-Host ""
Write-Host "[2-3/6] Pominięto vcpkg (użyto --SkipVcpkg)" -ForegroundColor Yellow
}
# Konfiguracja CMake
Write-Host ""
Write-Host "[4/6] Konfiguracja projektu CMake..." -ForegroundColor Yellow
$buildDir = Join-Path $PSScriptRoot "build\windows-debug"
New-Item -ItemType Directory -Force -Path $buildDir | Out-Null
Push-Location $buildDir
Write-Host " Uruchamianie CMake..." -ForegroundColor Cyan
cmake ../.. `
-G "Visual Studio 16 2019" `
-A x64 `
-DCMAKE_TOOLCHAIN_FILE="$VcpkgRoot/scripts/buildsystems/vcpkg.cmake" `
-DBUILD_TESTS=ON `
-DENABLE_I18N=ON
if ($LASTEXITCODE -ne 0) {
Write-Host "BŁĄD: Konfiguracja CMake nie powiodła się!" -ForegroundColor Red
Pop-Location
exit 1
}
Write-Host " ✓ Projekt skonfigurowany" -ForegroundColor Green
Pop-Location
# Kompilacja (opcjonalnie)
if (-not $SkipBuild) {
Write-Host ""
Write-Host "[5/6] Kompilacja projektu..." -ForegroundColor Yellow
Push-Location $buildDir
Write-Host " Budowanie Debug..." -ForegroundColor Cyan
cmake --build . --config Debug --parallel
if ($LASTEXITCODE -ne 0) {
Write-Host "BŁĄD: Kompilacja nie powiodła się!" -ForegroundColor Red
Pop-Location
exit 1
}
Write-Host " ✓ Kompilacja zakończona pomyślnie" -ForegroundColor Green
Pop-Location
} else {
Write-Host ""
Write-Host "[5/6] Pominięto kompilację (użyto --SkipBuild)" -ForegroundColor Yellow
}
# Testowanie
Write-Host ""
Write-Host "[6/6] Informacje końcowe" -ForegroundColor Yellow
$solutionFile = Join-Path $buildDir "QRGenerator.sln"
$exeFile = Join-Path $buildDir "Debug\qr-generator.exe"
Write-Host ""
Write-Host "========================================" -ForegroundColor Green
Write-Host "Setup zakończony pomyślnie!" -ForegroundColor Green
Write-Host "========================================" -ForegroundColor Green
Write-Host ""
Write-Host "Następne kroki:" -ForegroundColor Cyan
Write-Host ""
Write-Host "1. Otwórz projekt w Visual Studio 2019:" -ForegroundColor White
Write-Host " $solutionFile" -ForegroundColor Yellow
Write-Host ""
Write-Host "2. Lub otwórz folder jako CMake project:" -ForegroundColor White
Write-Host " File -> Open -> Folder... -> wybierz katalog projektu" -ForegroundColor Yellow
Write-Host ""
Write-Host "3. Kompilacja z linii poleceń:" -ForegroundColor White
Write-Host " cd build\windows-debug" -ForegroundColor Yellow
Write-Host " cmake --build . --config Debug" -ForegroundColor Yellow
Write-Host ""
Write-Host "4. Uruchomienie testów:" -ForegroundColor White
Write-Host " cd build\windows-debug" -ForegroundColor Yellow
Write-Host " ctest -C Debug --output-on-failure" -ForegroundColor Yellow
Write-Host ""
Write-Host "5. Uruchomienie aplikacji:" -ForegroundColor White
if (Test-Path $exeFile) {
Write-Host " $exeFile" -ForegroundColor Yellow
} else {
Write-Host " Najpierw skompiluj projekt (krok 3)" -ForegroundColor Yellow
}
Write-Host ""
# Utworzenie skrótu do otwierania w VS
$openVsScript = @"
@echo off
echo Otwieranie projektu w Visual Studio 2019...
start "" "$solutionFile"
"@
$openVsPath = Join-Path $PSScriptRoot "open_in_vs2019.bat"
Set-Content -Path $openVsPath -Value $openVsScript -Encoding ASCII
Write-Host "Utworzono skrót: open_in_vs2019.bat" -ForegroundColor Green
Write-Host ""