160 lines
6.8 KiB
PowerShell
160 lines
6.8 KiB
PowerShell
#Requires -Version 7.2
|
|
<#
|
|
.SYNOPSIS
|
|
Downloads and builds the Vulcast Vertical OBS plugin DLL.
|
|
Auto-installs VS Build Tools if needed (~3GB download).
|
|
#>
|
|
$ErrorActionPreference = 'Stop'
|
|
$ProgressPreference = 'SilentlyContinue'
|
|
|
|
$OBS_VERSION = '31.1.0'
|
|
$DEPS_DATE = '2026-06-25'
|
|
$WORK = "$env:TEMP\vulcast-build"
|
|
$SRC = "$WORK\vulcast-vertical"
|
|
|
|
Write-Host "=== Vulcast Vertical Build Script ===" -ForegroundColor Cyan
|
|
Write-Host ""
|
|
|
|
# ---------- Check / Install Build Tools ----------
|
|
function Find-MSVC {
|
|
$vsWhere = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe"
|
|
if (Test-Path $vsWhere) {
|
|
$p = & $vsWhere -latest -property installationPath 2>$null
|
|
if ($p) { return $p }
|
|
}
|
|
# Check for Build Tools in common locations
|
|
foreach ($v in '2022','2019') {
|
|
$bt = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\$v\BuildTools"
|
|
if (Test-Path "$bt\VC\Auxiliary\Build\vcvarsall.bat") { return $bt }
|
|
$ent = "${env:ProgramFiles}\Microsoft Visual Studio\$v"
|
|
if (Test-Path "$ent\VC\Auxiliary\Build\vcvarsall.bat") { return $ent }
|
|
}
|
|
return $null
|
|
}
|
|
|
|
$vsPath = Find-MSVC
|
|
if (-not $vsPath) {
|
|
Write-Host "C++ Build Tools not found. Installing VS 2022 Build Tools..." -ForegroundColor Yellow
|
|
Write-Host "(This downloads ~3GB and takes 5-15 minutes)" -ForegroundColor Yellow
|
|
|
|
$installer = "$env:TEMP\vs_buildtools.exe"
|
|
Invoke-WebRequest -Uri 'https://aka.ms/vs/17/release/vs_BuildTools.exe' -OutFile $installer
|
|
|
|
# Install C++ workload silently
|
|
$proc = Start-Process -FilePath $installer -ArgumentList @(
|
|
'--quiet', '--wait', '--norestart',
|
|
'--add', 'Microsoft.VisualStudio.Workload.VCTools',
|
|
'--add', 'Microsoft.VisualStudio.Component.VC.Tools.x86.x64',
|
|
'--add', 'Microsoft.VisualStudio.Component.Windows11SDK.22621',
|
|
'--includeRecommended'
|
|
) -Wait -PassThru
|
|
|
|
if ($proc.ExitCode -ne 0 -and $proc.ExitCode -ne 3010) {
|
|
Write-Error "Build Tools install failed (exit code $($proc.ExitCode)). Install manually from https://visualstudio.microsoft.com/downloads/"
|
|
exit 1
|
|
}
|
|
|
|
$vsPath = Find-MSVC
|
|
if (-not $vsPath) {
|
|
Write-Error "Build Tools installed but not detected. Try restarting your terminal and running this script again."
|
|
exit 1
|
|
}
|
|
Write-Host "[OK] Build Tools installed at: $vsPath" -ForegroundColor Green
|
|
} else {
|
|
Write-Host "[OK] Build Tools found at: $vsPath" -ForegroundColor Green
|
|
}
|
|
|
|
# Find vcvarsall.bat
|
|
$vcvars = Get-ChildItem -Path $vsPath -Recurse -Filter 'vcvarsall.bat' -ErrorAction SilentlyContinue |
|
|
Select-Object -First 1 -ExpandProperty FullName
|
|
if (-not $vcvars) {
|
|
Write-Error "vcvarsall.bat not found under $vsPath"
|
|
exit 1
|
|
}
|
|
|
|
# Set up MSVC environment
|
|
Write-Host "Setting up MSVC x64 environment..." -ForegroundColor Yellow
|
|
$envBackup = @{}
|
|
cmd /c "`"$vcvars`" x64 >nul 2>&1 && set" | ForEach-Object {
|
|
if ($_ -match '^([^=]+)=(.*)$') {
|
|
$envBackup[$Matches[1]] = [System.Environment]::GetEnvironmentVariable($Matches[1])
|
|
[System.Environment]::SetEnvironmentVariable($Matches[1], $Matches[2])
|
|
}
|
|
}
|
|
|
|
# Verify cl.exe is available
|
|
$cl = Get-Command cl.exe -ErrorAction SilentlyContinue
|
|
if ($cl) { Write-Host "[OK] MSVC compiler: $($cl.Source)" -ForegroundColor Green }
|
|
else { Write-Warning "cl.exe not found in PATH — build may fail." }
|
|
|
|
# ---------- Clean previous build ----------
|
|
if (Test-Path $WORK) { Remove-Item $WORK -Recurse -Force }
|
|
New-Item -ItemType Directory -Path $WORK -Force | Out-Null
|
|
|
|
# Step 1: Download source
|
|
Write-Host "`n[1/5] Downloading source..." -ForegroundColor Yellow
|
|
Invoke-WebRequest -Uri 'https://vulcast.xyz/dl/vulcast-vertical-source.zip' -OutFile "$WORK\source.zip"
|
|
Expand-Archive -Path "$WORK\source.zip" -DestinationPath $WORK
|
|
|
|
# Step 2: Download OBS Studio source
|
|
Write-Host "[2/5] Downloading OBS Studio $OBS_VERSION..." -ForegroundColor Yellow
|
|
Invoke-WebRequest -Uri "https://github.com/obsproject/obs-studio/archive/refs/tags/$OBS_VERSION.zip" -OutFile "$WORK\obs.zip"
|
|
Expand-Archive -Path "$WORK\obs.zip" -DestinationPath $WORK
|
|
Rename-Item "$WORK\obs-studio-$OBS_VERSION" "$WORK\obs-studio"
|
|
|
|
# Step 3: Download OBS pre-built dependencies
|
|
Write-Host "[3/5] Downloading OBS dependencies (~60MB)..." -ForegroundColor Yellow
|
|
New-Item -ItemType Directory -Path "$WORK\deps" -Force | Out-Null
|
|
Invoke-WebRequest -Uri "https://github.com/obsproject/obs-deps/releases/download/$DEPS_DATE/windows-deps-$DEPS_DATE-x64.zip" -OutFile "$WORK\deps\deps.zip"
|
|
Expand-Archive -Path "$WORK\deps\deps.zip" -DestinationPath "$WORK\deps"
|
|
|
|
Write-Host " Downloading Qt6 (~250MB)..." -ForegroundColor Yellow
|
|
Invoke-WebRequest -Uri "https://github.com/obsproject/obs-deps/releases/download/$DEPS_DATE/windows-deps-qt6-$DEPS_DATE-x64.zip" -OutFile "$WORK\deps\qt6.zip"
|
|
Expand-Archive -Path "$WORK\deps\qt6.zip" -DestinationPath "$WORK\deps"
|
|
|
|
# Step 4: Build OBS libraries
|
|
Write-Host "[4/5] Building OBS libraries..." -ForegroundColor Yellow
|
|
Push-Location "$WORK\obs-studio"
|
|
cmake -S . -B build_x64 `
|
|
-G "Visual Studio 17 2022" -A x64 `
|
|
-DENABLE_PLUGINS=OFF `
|
|
-DENABLE_UI=OFF `
|
|
-DENABLE_SCRIPTING=OFF `
|
|
-DCMAKE_BUILD_TYPE=Release `
|
|
-DQT_VERSION=6 `
|
|
-DCMAKE_PREFIX_PATH="$WORK\deps" 2>&1 | Out-Null
|
|
|
|
cmake --build build_x64 --config Release --target libobs -- /m /consoleLoggerParameters:Summary /noLogo 2>&1 | Write-Host
|
|
cmake --build build_x64 --config Release --target obs-frontend-api -- /m /consoleLoggerParameters:Summary /noLogo 2>&1 | Write-Host
|
|
Pop-Location
|
|
|
|
# Step 5: Build the plugin
|
|
Write-Host "[5/5] Building Vulcast Vertical plugin..." -ForegroundColor Yellow
|
|
Push-Location $SRC
|
|
cmake -S . -B build `
|
|
-G "Visual Studio 17 2022" -A x64 `
|
|
-DBUILD_OUT_OF_TREE=On `
|
|
-Dlibobs_DIR="$WORK\obs-studio\build_x64\libobs" `
|
|
-Dobs-frontend-api_DIR="$WORK\obs-studio\build_x64\UI\obs-frontend-api" `
|
|
-DCMAKE_PREFIX_PATH="$WORK\deps" `
|
|
-DQT_VERSION=6 `
|
|
-DCMAKE_BUILD_TYPE=Release 2>&1 | Write-Host
|
|
|
|
cmake --build build --config Release -- /m /consoleLoggerParameters:Summary /noLogo 2>&1 | Write-Host
|
|
Pop-Location
|
|
|
|
# Copy DLL to desktop
|
|
$dllPath = Get-ChildItem -Path "$SRC\build" -Recurse -Filter "vulcast-vertical.dll" -ErrorAction SilentlyContinue | Select-Object -First 1
|
|
if ($dllPath) {
|
|
$dest = "$env:USERPROFILE\Desktop\vulcast-vertical.dll"
|
|
Copy-Item $dllPath.FullName $dest -Force
|
|
Write-Host "`n=== BUILD SUCCESSFUL ===" -ForegroundColor Green
|
|
Write-Host "DLL saved to: $dest" -ForegroundColor Green
|
|
Write-Host ""
|
|
Write-Host "To install:" -ForegroundColor Cyan
|
|
Write-Host ' Copy "' -NoNewline; Write-Host $dest -ForegroundColor Yellow -NoNewline; Write-Host '" to'
|
|
Write-Host ' "C:\Program Files\obs-studio\obs-plugins\64bit\"'
|
|
Write-Host " Then restart OBS Studio."
|
|
} else {
|
|
Write-Error "Build succeeded but DLL not found. Check build output above for errors."
|
|
}
|