Refactor Windows development setup script for improved error handling and dependency checks
- Enhanced Git and Python checks to ensure proper installation before proceeding with setup. - Updated vcpkg cloning logic to verify Git availability and provide clearer error messages. - Improved project file generation and build testing sections with additional user feedback and error handling. - Removed obsolete PowerShell syntax test script to streamline the repository.
This commit is contained in:
@@ -52,13 +52,12 @@ if (-not $SkipVS) {
|
|||||||
|
|
||||||
# Check for Git
|
# Check for Git
|
||||||
Write-Host "Checking for Git..." -ForegroundColor Yellow
|
Write-Host "Checking for Git..." -ForegroundColor Yellow
|
||||||
|
$gitFound = $false
|
||||||
try {
|
try {
|
||||||
$gitVersion = & git --version 2>$null
|
$null = Get-Command git -ErrorAction Stop
|
||||||
if ($LASTEXITCODE -eq 0) {
|
$gitVersion = & git --version
|
||||||
Write-Host "✓ Git found: $gitVersion" -ForegroundColor Green
|
Write-Host "✓ Git found: $gitVersion" -ForegroundColor Green
|
||||||
} else {
|
$gitFound = $true
|
||||||
throw "Git not found"
|
|
||||||
}
|
|
||||||
} catch {
|
} catch {
|
||||||
Write-Warning "Git not found. Please install Git for Windows."
|
Write-Warning "Git not found. Please install Git for Windows."
|
||||||
Write-Host "Download from: https://git-scm.com/download/win" -ForegroundColor Yellow
|
Write-Host "Download from: https://git-scm.com/download/win" -ForegroundColor Yellow
|
||||||
@@ -66,13 +65,12 @@ try {
|
|||||||
|
|
||||||
# Check for Python
|
# Check for Python
|
||||||
Write-Host "Checking for Python..." -ForegroundColor Yellow
|
Write-Host "Checking for Python..." -ForegroundColor Yellow
|
||||||
|
$pythonFound = $false
|
||||||
try {
|
try {
|
||||||
$pythonVersion = & python --version 2>$null
|
$null = Get-Command python -ErrorAction Stop
|
||||||
if ($LASTEXITCODE -eq 0) {
|
$pythonVersion = & python --version
|
||||||
Write-Host "✓ Python found: $pythonVersion" -ForegroundColor Green
|
Write-Host "✓ Python found: $pythonVersion" -ForegroundColor Green
|
||||||
} else {
|
$pythonFound = $true
|
||||||
throw "Python not found"
|
|
||||||
}
|
|
||||||
} catch {
|
} catch {
|
||||||
Write-Warning "Python not found. Please install Python 3.8 or later."
|
Write-Warning "Python not found. Please install Python 3.8 or later."
|
||||||
Write-Host "Download from: https://www.python.org/downloads/" -ForegroundColor Yellow
|
Write-Host "Download from: https://www.python.org/downloads/" -ForegroundColor Yellow
|
||||||
@@ -84,15 +82,21 @@ if (-not $SkipVcpkg) {
|
|||||||
|
|
||||||
if (-not (Test-Path "vcpkg")) {
|
if (-not (Test-Path "vcpkg")) {
|
||||||
Write-Host "Cloning vcpkg..." -ForegroundColor Yellow
|
Write-Host "Cloning vcpkg..." -ForegroundColor Yellow
|
||||||
try {
|
if ($gitFound) {
|
||||||
& git clone https://github.com/Microsoft/vcpkg.git vcpkg
|
try {
|
||||||
if ($LASTEXITCODE -eq 0) {
|
& git clone https://github.com/Microsoft/vcpkg.git vcpkg
|
||||||
Write-Host "✓ vcpkg cloned successfully" -ForegroundColor Green
|
if ($LASTEXITCODE -eq 0) {
|
||||||
} else {
|
Write-Host "✓ vcpkg cloned successfully" -ForegroundColor Green
|
||||||
throw "Failed to clone vcpkg"
|
} else {
|
||||||
|
Write-Error "Failed to clone vcpkg"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
Write-Error "Failed to clone vcpkg: $_"
|
||||||
|
exit 1
|
||||||
}
|
}
|
||||||
} catch {
|
} else {
|
||||||
Write-Error "Failed to clone vcpkg: $_"
|
Write-Error "Git is required to clone vcpkg. Please install Git first."
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -109,7 +113,9 @@ if (-not $SkipVcpkg) {
|
|||||||
if ($LASTEXITCODE -eq 0) {
|
if ($LASTEXITCODE -eq 0) {
|
||||||
Write-Host "✓ vcpkg bootstrapped successfully" -ForegroundColor Green
|
Write-Host "✓ vcpkg bootstrapped successfully" -ForegroundColor Green
|
||||||
} else {
|
} else {
|
||||||
throw "Failed to bootstrap vcpkg"
|
Write-Error "Failed to bootstrap vcpkg"
|
||||||
|
Pop-Location
|
||||||
|
exit 1
|
||||||
}
|
}
|
||||||
Pop-Location
|
Pop-Location
|
||||||
} catch {
|
} catch {
|
||||||
@@ -139,30 +145,39 @@ if (-not $SkipVcpkg) {
|
|||||||
|
|
||||||
# Generate Visual Studio project files
|
# Generate Visual Studio project files
|
||||||
Write-Host "Generating Visual Studio project files..." -ForegroundColor Yellow
|
Write-Host "Generating Visual Studio project files..." -ForegroundColor Yellow
|
||||||
try {
|
if ($pythonFound) {
|
||||||
& python scripts/generate-vs-projects.py
|
try {
|
||||||
if ($LASTEXITCODE -eq 0) {
|
& python scripts/generate-vs-projects.py
|
||||||
Write-Host "✓ Visual Studio project files generated" -ForegroundColor Green
|
if ($LASTEXITCODE -eq 0) {
|
||||||
} else {
|
Write-Host "✓ Visual Studio project files generated" -ForegroundColor Green
|
||||||
throw "Failed to generate project files"
|
} else {
|
||||||
|
Write-Warning "Failed to generate project files"
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
Write-Warning "Failed to generate project files: $_"
|
||||||
|
Write-Host "You can manually run: python scripts/generate-vs-projects.py" -ForegroundColor Yellow
|
||||||
}
|
}
|
||||||
} catch {
|
} else {
|
||||||
Write-Warning "Failed to generate project files: $_"
|
Write-Warning "Python is required to generate project files. Please install Python first."
|
||||||
Write-Host "You can manually run: python scripts/generate-vs-projects.py" -ForegroundColor Yellow
|
Write-Host "You can manually run: python scripts/generate-vs-projects.py" -ForegroundColor Yellow
|
||||||
}
|
}
|
||||||
|
|
||||||
# Test build
|
# Test build
|
||||||
Write-Host "Testing build..." -ForegroundColor Yellow
|
Write-Host "Testing build..." -ForegroundColor Yellow
|
||||||
try {
|
if (Test-Path "scripts\build-windows.ps1") {
|
||||||
& .\scripts\build-windows.ps1 -Configuration Release -Platform x64
|
try {
|
||||||
if ($LASTEXITCODE -eq 0) {
|
& .\scripts\build-windows.ps1 -Configuration Release -Platform x64
|
||||||
Write-Host "✓ Test build successful" -ForegroundColor Green
|
if ($LASTEXITCODE -eq 0) {
|
||||||
} else {
|
Write-Host "✓ Test build successful" -ForegroundColor Green
|
||||||
Write-Warning "Test build failed, but setup is complete"
|
} else {
|
||||||
|
Write-Warning "Test build failed, but setup is complete"
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
Write-Warning "Test build failed: $_"
|
||||||
|
Write-Host "You can manually run: .\scripts\build-windows.ps1" -ForegroundColor Yellow
|
||||||
}
|
}
|
||||||
} catch {
|
} else {
|
||||||
Write-Warning "Test build failed: $_"
|
Write-Warning "Build script not found. You can manually build using Visual Studio."
|
||||||
Write-Host "You can manually run: .\scripts\build-windows.ps1" -ForegroundColor Yellow
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Write-Host "========================================" -ForegroundColor Cyan
|
Write-Host "========================================" -ForegroundColor Cyan
|
||||||
|
|||||||
@@ -1,31 +0,0 @@
|
|||||||
# Simple test script to verify PowerShell syntax
|
|
||||||
# This script tests basic PowerShell constructs used in our build scripts
|
|
||||||
|
|
||||||
Write-Host "Testing PowerShell syntax..." -ForegroundColor Green
|
|
||||||
|
|
||||||
# Test try-catch blocks
|
|
||||||
try {
|
|
||||||
Write-Host "✓ Try-catch syntax works" -ForegroundColor Green
|
|
||||||
} catch {
|
|
||||||
Write-Host "✗ Try-catch syntax failed" -ForegroundColor Red
|
|
||||||
}
|
|
||||||
|
|
||||||
# Test if-else blocks
|
|
||||||
if ($true) {
|
|
||||||
Write-Host "✓ If-else syntax works" -ForegroundColor Green
|
|
||||||
} else {
|
|
||||||
Write-Host "✗ If-else syntax failed" -ForegroundColor Red
|
|
||||||
}
|
|
||||||
|
|
||||||
# Test parameter blocks
|
|
||||||
param(
|
|
||||||
[switch]$TestParam = $false
|
|
||||||
)
|
|
||||||
|
|
||||||
Write-Host "✓ Parameter syntax works" -ForegroundColor Green
|
|
||||||
|
|
||||||
# Test string interpolation
|
|
||||||
$testVar = "PowerShell"
|
|
||||||
Write-Host "✓ String interpolation works: $testVar" -ForegroundColor Green
|
|
||||||
|
|
||||||
Write-Host "All syntax tests passed!" -ForegroundColor Green
|
|
||||||
Reference in New Issue
Block a user