build: add test build script
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
$projectFolder = "build"
|
||||
$slnName = "seallib"
|
||||
|
||||
function Initialize-Project {
|
||||
# generation
|
||||
Write-Host "Generating project"
|
||||
Set-Location $projectFolder
|
||||
|
||||
cmake .. -G "Visual Studio 17 2022" -A x64 `
|
||||
-DCMAKE_CONFIGURATION_TYPES="Debug;Release" `
|
||||
-DCMAKE_VS_PLATFORM_NAME="x64" `
|
||||
-DSEALLIB_TEST=ON
|
||||
|
||||
dotnet restore "$slnName.sln" --arch x64
|
||||
|
||||
$exitCode = $LASTEXITCODE
|
||||
|
||||
if ($exitCode -ne 0) {
|
||||
Write-Host "CMake generation failed with exit code: $exitCode" -ForegroundColor Red
|
||||
exit 1
|
||||
}
|
||||
|
||||
Set-Location ..
|
||||
|
||||
# sln open
|
||||
try {
|
||||
$slnPath = "$projectFolder\$slnName.sln"
|
||||
|
||||
$solutionFile = Get-Item -Path $slnPath -ErrorAction Stop
|
||||
$solutionFullName = $solutionFile.FullName
|
||||
|
||||
$vsProcesses = Get-CimInstance -Query "SELECT CommandLine FROM Win32_Process WHERE Name = 'devenv.exe'"
|
||||
$pattern = [Regex]::Escape($solutionFullName)
|
||||
$isOpen = $vsProcesses | Where-Object { $_.CommandLine -match $pattern }
|
||||
|
||||
if (-not $isOpen) {
|
||||
Write-Host "Starting Visual Studio..." -ForegroundColor Cyan
|
||||
Start-Process -FilePath $solutionFullName
|
||||
}
|
||||
else {
|
||||
Write-Host "Solution '$($solutionFile.Name)' is already open." -ForegroundColor Yellow
|
||||
}
|
||||
}
|
||||
catch {
|
||||
Write-Error "Failed to open solution: $($_.Exception.Message)"
|
||||
}
|
||||
}
|
||||
|
||||
if (-not (Test-Path $projectFolder)) {
|
||||
New-Item -ItemType Directory -Path $projectFolder | Out-Null
|
||||
}
|
||||
|
||||
Initialize-Project
|
||||
Reference in New Issue
Block a user