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:
@@ -1,6 +1,6 @@
|
||||
@echo off
|
||||
REM Generate Visual Studio project files for YAZE
|
||||
REM This script creates proper Visual Studio solution and project files
|
||||
REM Configure Visual Studio project files for YAZE
|
||||
REM This script configures CMake build system to work with existing Visual Studio project files
|
||||
|
||||
setlocal enabledelayedexpansion
|
||||
|
||||
@@ -141,31 +141,35 @@ if errorlevel 1 (
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
REM Check if solution file was created
|
||||
set SOLUTION_FILE=%BUILD_DIR%\YAZE.sln
|
||||
if exist "%SOLUTION_FILE%" (
|
||||
echo ✅ Visual Studio solution created: %SOLUTION_FILE%
|
||||
REM Check if the existing solution file is present and valid
|
||||
set EXISTING_SOLUTION_FILE=%SOURCE_DIR%\YAZE.sln
|
||||
if exist "%EXISTING_SOLUTION_FILE%" (
|
||||
echo ✅ Using existing Visual Studio solution: %EXISTING_SOLUTION_FILE%
|
||||
|
||||
REM Copy solution file to root directory for convenience
|
||||
set ROOT_SOLUTION_FILE=%SOURCE_DIR%\YAZE.sln
|
||||
copy "%SOLUTION_FILE%" "%ROOT_SOLUTION_FILE%" >nul
|
||||
echo ✅ Solution file copied to root directory
|
||||
REM Verify the solution file references the project file
|
||||
findstr /C:"YAZE.vcxproj" "%EXISTING_SOLUTION_FILE%" >nul
|
||||
if not errorlevel 1 (
|
||||
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
|
||||
where devenv >nul 2>&1
|
||||
if not errorlevel 1 (
|
||||
echo Opening solution in Visual Studio...
|
||||
start "" devenv "%ROOT_SOLUTION_FILE%"
|
||||
start "" devenv "%EXISTING_SOLUTION_FILE%"
|
||||
) else (
|
||||
echo Visual Studio solution ready: %ROOT_SOLUTION_FILE%
|
||||
echo Visual Studio solution ready: %EXISTING_SOLUTION_FILE%
|
||||
)
|
||||
) else (
|
||||
echo ❌ Solution file not created. Check CMake output for errors.
|
||||
echo ❌ Existing solution file not found: %EXISTING_SOLUTION_FILE%
|
||||
echo Please ensure YAZE.sln exists in the project root
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
echo.
|
||||
echo 🎉 Visual Studio project generation complete!
|
||||
echo 🎉 Visual Studio project configuration complete!
|
||||
echo.
|
||||
echo Next steps:
|
||||
echo 1. Open YAZE.sln in Visual Studio
|
||||
|
||||
@@ -1,12 +1,34 @@
|
||||
# Generate Visual Studio project files for YAZE
|
||||
# This script creates proper Visual Studio solution and project files
|
||||
# Configure Visual Studio project files for YAZE
|
||||
# This script configures CMake build system to work with existing Visual Studio project files
|
||||
|
||||
param(
|
||||
[string]$Configuration = "Debug",
|
||||
[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
|
||||
$ValidArchitectures = @("x64", "x86", "ARM64")
|
||||
if ($Architecture -notin $ValidArchitectures) {
|
||||
@@ -160,8 +182,8 @@ if ($UseVcpkg) {
|
||||
)
|
||||
}
|
||||
|
||||
# Run CMake configuration
|
||||
Write-Host "Configuring CMake..." -ForegroundColor Yellow
|
||||
# Configure CMake to generate build files (but don't overwrite existing project files)
|
||||
Write-Host "Configuring CMake for build system..." -ForegroundColor Yellow
|
||||
Write-Host "Command: cmake $($CmakeArgs -join ' ')" -ForegroundColor Gray
|
||||
|
||||
& cmake @CmakeArgs $SourceDir
|
||||
@@ -171,33 +193,37 @@ if ($LASTEXITCODE -ne 0) {
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Check if solution file was created
|
||||
$SolutionFile = Join-Path $BuildDir "YAZE.sln"
|
||||
if (Test-Path $SolutionFile) {
|
||||
Write-Host "✅ Visual Studio solution created: $SolutionFile" -ForegroundColor Green
|
||||
# Check if the existing solution file is present and valid
|
||||
$ExistingSolutionFile = Join-Path $SourceDir "YAZE.sln"
|
||||
if (Test-Path $ExistingSolutionFile) {
|
||||
Write-Host "✅ Using existing Visual Studio solution: $ExistingSolutionFile" -ForegroundColor Green
|
||||
|
||||
# Copy solution file to root directory for convenience
|
||||
$RootSolutionFile = Join-Path $SourceDir "YAZE.sln"
|
||||
Copy-Item $SolutionFile $RootSolutionFile -Force
|
||||
Write-Host "✅ Solution file copied to root directory" -ForegroundColor Green
|
||||
# Verify the solution file is properly structured
|
||||
$SolutionContent = Get-Content $ExistingSolutionFile -Raw
|
||||
if ($SolutionContent -match "YAZE\.vcxproj") {
|
||||
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
|
||||
if (Get-Command "devenv" -ErrorAction SilentlyContinue) {
|
||||
Write-Host "Opening solution in Visual Studio..." -ForegroundColor Yellow
|
||||
& devenv $RootSolutionFile
|
||||
& devenv $ExistingSolutionFile
|
||||
} elseif (Get-Command "code" -ErrorAction SilentlyContinue) {
|
||||
Write-Host "Opening solution in VS Code..." -ForegroundColor Yellow
|
||||
& code $RootSolutionFile
|
||||
& code $ExistingSolutionFile
|
||||
} else {
|
||||
Write-Host "Visual Studio solution ready: $RootSolutionFile" -ForegroundColor Cyan
|
||||
Write-Host "Visual Studio solution ready: $ExistingSolutionFile" -ForegroundColor Cyan
|
||||
}
|
||||
} 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
|
||||
}
|
||||
|
||||
Write-Host ""
|
||||
Write-Host "🎉 Visual Studio project generation complete!" -ForegroundColor Green
|
||||
Write-Host "🎉 Visual Studio project configuration complete!" -ForegroundColor Green
|
||||
Write-Host ""
|
||||
Write-Host "Next steps:" -ForegroundColor Cyan
|
||||
Write-Host "1. Open YAZE.sln in Visual Studio" -ForegroundColor White
|
||||
|
||||
Reference in New Issue
Block a user