Refactor Visual Studio project configuration scripts for clarity and usability

- Updated batch and PowerShell scripts to improve the configuration process for Visual Studio projects.
- Enhanced user feedback by checking for existing solution files and verifying project references.
- Added help options in the PowerShell script to guide users on available parameters and usage examples.
- Improved messaging for success and error states to facilitate troubleshooting and user experience.
This commit is contained in:
scawful
2025-09-28 00:11:21 -04:00
parent da4057cb71
commit bec691da69
2 changed files with 62 additions and 32 deletions

View File

@@ -1,6 +1,6 @@
@echo off @echo off
REM Generate Visual Studio project files for YAZE REM Configure Visual Studio project files for YAZE
REM This script creates proper Visual Studio solution and project files REM This script configures CMake build system to work with existing Visual Studio project files
setlocal enabledelayedexpansion setlocal enabledelayedexpansion
@@ -141,31 +141,35 @@ if errorlevel 1 (
exit /b 1 exit /b 1
) )
REM Check if solution file was created REM Check if the existing solution file is present and valid
set SOLUTION_FILE=%BUILD_DIR%\YAZE.sln set EXISTING_SOLUTION_FILE=%SOURCE_DIR%\YAZE.sln
if exist "%SOLUTION_FILE%" ( if exist "%EXISTING_SOLUTION_FILE%" (
echo ✅ Visual Studio solution created: %SOLUTION_FILE% echo Using existing Visual Studio solution: %EXISTING_SOLUTION_FILE%
REM Copy solution file to root directory for convenience REM Verify the solution file references the project file
set ROOT_SOLUTION_FILE=%SOURCE_DIR%\YAZE.sln findstr /C:"YAZE.vcxproj" "%EXISTING_SOLUTION_FILE%" >nul
copy "%SOLUTION_FILE%" "%ROOT_SOLUTION_FILE%" >nul if not errorlevel 1 (
echo ✅ Solution file copied to root directory echo ✅ Solution file references YAZE.vcxproj correctly
) else (
echo ⚠️ Warning: Solution file may not reference YAZE.vcxproj properly
)
REM Try to open solution in Visual Studio REM Try to open solution in Visual Studio
where devenv >nul 2>&1 where devenv >nul 2>&1
if not errorlevel 1 ( if not errorlevel 1 (
echo Opening solution in Visual Studio... echo Opening solution in Visual Studio...
start "" devenv "%ROOT_SOLUTION_FILE%" start "" devenv "%EXISTING_SOLUTION_FILE%"
) else ( ) else (
echo Visual Studio solution ready: %ROOT_SOLUTION_FILE% echo Visual Studio solution ready: %EXISTING_SOLUTION_FILE%
) )
) else ( ) else (
echoSolution file not created. Check CMake output for errors. echoExisting solution file not found: %EXISTING_SOLUTION_FILE%
echo Please ensure YAZE.sln exists in the project root
exit /b 1 exit /b 1
) )
echo. echo.
echo 🎉 Visual Studio project generation complete! echo 🎉 Visual Studio project configuration complete!
echo. echo.
echo Next steps: echo Next steps:
echo 1. Open YAZE.sln in Visual Studio echo 1. Open YAZE.sln in Visual Studio

View File

@@ -1,12 +1,34 @@
# Generate Visual Studio project files for YAZE # Configure Visual Studio project files for YAZE
# This script creates proper Visual Studio solution and project files # This script configures CMake build system to work with existing Visual Studio project files
param( param(
[string]$Configuration = "Debug", [string]$Configuration = "Debug",
[string]$Architecture = "x64", [string]$Architecture = "x64",
[switch]$Clean = $false [switch]$Clean = $false,
[switch]$UseVcpkg = $false,
[switch]$Help = $false
) )
# Show help if requested
if ($Help) {
Write-Host "Usage: .\generate-vs-projects.ps1 [options]"
Write-Host ""
Write-Host "Options:"
Write-Host " -Configuration <config> Build configuration (Debug, Release, RelWithDebInfo, MinSizeRel)"
Write-Host " -Architecture <arch> Target architecture (x64, x86, ARM64)"
Write-Host " -Clean Clean build directory before configuring"
Write-Host " -UseVcpkg Use vcpkg for dependency management"
Write-Host " -Help Show this help message"
Write-Host ""
Write-Host "Examples:"
Write-Host " .\generate-vs-projects.ps1 # Default: Debug x64"
Write-Host " .\generate-vs-projects.ps1 -Configuration Release -Architecture x86"
Write-Host " .\generate-vs-projects.ps1 -Clean -UseVcpkg"
Write-Host ""
Write-Host "Note: This script configures CMake to work with existing YAZE.sln and YAZE.vcxproj files"
exit 0
}
# Validate architecture parameter # Validate architecture parameter
$ValidArchitectures = @("x64", "x86", "ARM64") $ValidArchitectures = @("x64", "x86", "ARM64")
if ($Architecture -notin $ValidArchitectures) { if ($Architecture -notin $ValidArchitectures) {
@@ -160,8 +182,8 @@ if ($UseVcpkg) {
) )
} }
# Run CMake configuration # Configure CMake to generate build files (but don't overwrite existing project files)
Write-Host "Configuring CMake..." -ForegroundColor Yellow Write-Host "Configuring CMake for build system..." -ForegroundColor Yellow
Write-Host "Command: cmake $($CmakeArgs -join ' ')" -ForegroundColor Gray Write-Host "Command: cmake $($CmakeArgs -join ' ')" -ForegroundColor Gray
& cmake @CmakeArgs $SourceDir & cmake @CmakeArgs $SourceDir
@@ -171,33 +193,37 @@ if ($LASTEXITCODE -ne 0) {
exit 1 exit 1
} }
# Check if solution file was created # Check if the existing solution file is present and valid
$SolutionFile = Join-Path $BuildDir "YAZE.sln" $ExistingSolutionFile = Join-Path $SourceDir "YAZE.sln"
if (Test-Path $SolutionFile) { if (Test-Path $ExistingSolutionFile) {
Write-Host "✅ Visual Studio solution created: $SolutionFile" -ForegroundColor Green Write-Host " Using existing Visual Studio solution: $ExistingSolutionFile" -ForegroundColor Green
# Copy solution file to root directory for convenience # Verify the solution file is properly structured
$RootSolutionFile = Join-Path $SourceDir "YAZE.sln" $SolutionContent = Get-Content $ExistingSolutionFile -Raw
Copy-Item $SolutionFile $RootSolutionFile -Force if ($SolutionContent -match "YAZE\.vcxproj") {
Write-Host "✅ Solution file copied to root directory" -ForegroundColor Green Write-Host "✅ Solution file references YAZE.vcxproj correctly" -ForegroundColor Green
} else {
Write-Host "⚠️ Warning: Solution file may not reference YAZE.vcxproj properly" -ForegroundColor Yellow
}
# Open solution in Visual Studio if available # Open solution in Visual Studio if available
if (Get-Command "devenv" -ErrorAction SilentlyContinue) { if (Get-Command "devenv" -ErrorAction SilentlyContinue) {
Write-Host "Opening solution in Visual Studio..." -ForegroundColor Yellow Write-Host "Opening solution in Visual Studio..." -ForegroundColor Yellow
& devenv $RootSolutionFile & devenv $ExistingSolutionFile
} elseif (Get-Command "code" -ErrorAction SilentlyContinue) { } elseif (Get-Command "code" -ErrorAction SilentlyContinue) {
Write-Host "Opening solution in VS Code..." -ForegroundColor Yellow Write-Host "Opening solution in VS Code..." -ForegroundColor Yellow
& code $RootSolutionFile & code $ExistingSolutionFile
} else { } else {
Write-Host "Visual Studio solution ready: $RootSolutionFile" -ForegroundColor Cyan Write-Host "Visual Studio solution ready: $ExistingSolutionFile" -ForegroundColor Cyan
} }
} else { } else {
Write-Host "Solution file not created. Check CMake output for errors." -ForegroundColor Red Write-Host "Existing solution file not found: $ExistingSolutionFile" -ForegroundColor Red
Write-Host "Please ensure YAZE.sln exists in the project root" -ForegroundColor Yellow
exit 1 exit 1
} }
Write-Host "" Write-Host ""
Write-Host "🎉 Visual Studio project generation complete!" -ForegroundColor Green Write-Host "🎉 Visual Studio project configuration complete!" -ForegroundColor Green
Write-Host "" Write-Host ""
Write-Host "Next steps:" -ForegroundColor Cyan Write-Host "Next steps:" -ForegroundColor Cyan
Write-Host "1. Open YAZE.sln in Visual Studio" -ForegroundColor White Write-Host "1. Open YAZE.sln in Visual Studio" -ForegroundColor White