diff --git a/build-vulcast-vertical.ps1 b/build-vulcast-vertical.ps1 index 37a1dc6..0cd2a01 100644 --- a/build-vulcast-vertical.ps1 +++ b/build-vulcast-vertical.ps1 @@ -1,169 +1,51 @@ -#Requires -Version 7.2 +#Requires -Version 5.1 +param() $ErrorActionPreference = 'Stop' -$ProgressPreference = 'SilentlyContinue' +$CacheDir = Join-Path $env:LOCALAPPDATA "vulcast-build" +$PluginDir = Join-Path $CacheDir "vulcast-vertical" +$PluginBuild = Join-Path $PluginDir "build" -$OBS_VERSION = '31.1.1' -$DEPS_DATE = '2025-07-11' -$WORK = "$env:LOCALAPPDATA\vulcast-build" -$SRC = "$WORK\vulcast-vertical" -$OBS_PLUGIN_DIR = "${env:ProgramFiles}\obs-studio\obs-plugins\64bit" +Write-Host "=== Vulcast Vertical Build ===" -ForegroundColor Cyan -Write-Host "=== Vulcast Vertical Build Script ===" -ForegroundColor Cyan -Write-Host "" +# 1. Find VS Build Tools +$vswhere = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" +if (!(Test-Path $vswhere)) { throw "VS Build Tools not found. Install from https://visualstudio.microsoft.com/downloads/#build-tools-for-visual-studio-2022" } +$installPath = & $vswhere -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath 2>$null +if (!$installPath) { throw "VS Build Tools not found" } +$vcvarsall = Join-Path $installPath "VC\Auxiliary\Build\vcvarsall.bat" +if (!(Test-Path $vcvarsall)) { throw "vcvarsall.bat not found" } -# ---------- 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 } - } - foreach ($v in '2022','2019') { - foreach ($ed in 'BuildTools','Community','Professional','Enterprise') { - foreach ($base in "${env:ProgramFiles(x86)}","${env:ProgramFiles}") { - $p = "$base\Microsoft Visual Studio\$v\$ed" - if (Test-Path "$p\VC\Auxiliary\Build\vcvarsall.bat") { return $p } - } - } - } - return $null -} - -$vsPath = Find-MSVC -if (-not $vsPath) { - Write-Host "Installing VS 2022 Build Tools (~3GB, 5-15 min)..." -ForegroundColor Yellow - $installer = "$env:TEMP\vs_buildtools.exe" - if (-not (Test-Path $installer)) { - Invoke-WebRequest -Uri 'https://aka.ms/vs/17/release/vs_BuildTools.exe' -OutFile $installer - } - $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 "Install failed. Get it from https://visualstudio.microsoft.com/downloads/" - exit 1 - } - $vsPath = Find-MSVC - if (-not $vsPath) { Write-Error "Restart terminal and run again."; exit 1 } - Write-Host "[OK] Installed: $vsPath`n" -ForegroundColor Green +# 2. Clone or update plugin source (deps live in .deps/ inside source - persists) +if (!(Test-Path (Join-Path $PluginDir ".git"))) { + Write-Host "[1/3] Cloning source..." -ForegroundColor Cyan + if (Test-Path $PluginDir) { Remove-Item $PluginDir -Recurse -Force } + git clone --depth 1 "ssh://git@git.216-75-142-55.sslip.io:2222/wawadmin/vulcast-vertical.git" $PluginDir } else { - Write-Host "[OK] Build Tools: $vsPath`n" -ForegroundColor Green + Write-Host "[1/3] Pulling updates..." -ForegroundColor Cyan + git -C $PluginDir pull } -$vcvars = Get-ChildItem -Path $vsPath -Recurse -Filter 'vcvarsall.bat' -ErrorAction SilentlyContinue | - Select-Object -First 1 -ExpandProperty FullName -Write-Host "Setting up MSVC x64..." -ForegroundColor Yellow -cmd /c "`"$vcvars`" x64 >nul 2>&1 && set" | ForEach-Object { - if ($_ -match '^([^=]+)=(.*)$') { - [System.Environment]::SetEnvironmentVariable($Matches[1], $Matches[2]) - } -} -if (Get-Command cl.exe -ErrorAction SilentlyContinue) { Write-Host "[OK] cl.exe ready`n" -ForegroundColor Green } +# 3. Build plugin (incremental - cmake caches deps in .deps/) +Write-Host "[2/3] Configuring cmake..." -ForegroundColor Cyan +New-Item -ItemType Directory -Path $PluginBuild -Force | Out-Null -# ---------- Directories ---------- -New-Item -ItemType Directory -Path $WORK -Force | Out-Null -$DEPS = "$WORK\deps" -$OBS = "$WORK\obs-studio" +cmd /c "call `"$vcvarsall`" x64 && cmake -S `"$PluginDir`" -B `"$PluginBuild`" -G `"Visual Studio 17 2022`" -A x64 -DCMAKE_BUILD_TYPE=Release" +if ($LASTEXITCODE -ne 0) { throw "cmake configure failed" } -# ---------- Step 1: Source ---------- -Write-Host "[1/5] Source code" -ForegroundColor Cyan -if (-not (Test-Path "$SRC\CMakeLists.txt")) { - Write-Host " Downloading..." -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 -Force +Write-Host "[3/3] Building DLL..." -ForegroundColor Cyan +cmd /c "call `"$vcvarsall`" x64 && cmake --build `"$PluginBuild`" --config Release -- /p:BuildInParallel=true" +if ($LASTEXITCODE -ne 0) { throw "Build failed" } + +# Find and install DLL +$dll = Get-ChildItem -Path $PluginBuild -Recurse -Filter "vulcast-vertical.dll" -ErrorAction SilentlyContinue | Select-Object -First 1 +if (!$dll) { $dll = Get-ChildItem -Path $PluginBuild -Recurse -Filter "vertical-canvas.dll" -ErrorAction SilentlyContinue | Select-Object -First 1 } +if (!$dll) { $dll = Get-ChildItem -Path $PluginBuild -Recurse -Filter "*.dll" -ErrorAction SilentlyContinue | Where-Object { $_.FullName -notmatch "Qt6|obs" } | Select-Object -First 1 } + +if ($dll) { + $pluginsDir = Join-Path $env:ProgramFiles "obs-studio\obs-plugins\64bit" + if (!(Test-Path $pluginsDir)) { $pluginsDir = Join-Path $CacheDir "obs-plugins"; New-Item -ItemType Directory -Path $pluginsDir -Force | Out-Null } + Copy-Item $dll.FullName $pluginsDir -Force + Write-Host "`nDone! DLL: $pluginsDir\$($dll.Name)" -ForegroundColor Green } else { - Write-Host " Source (cached)" -ForegroundColor DarkGray + throw "DLL not found" } - -# ---------- Step 2: OBS source ---------- -Write-Host "[2/5] OBS Studio source" -ForegroundColor Cyan -if (-not (Test-Path "$OBS\CMakeLists.txt")) { - Write-Host " Downloading..." -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 -Force - if (Test-Path "$WORK\obs-studio-$OBS_VERSION") { Rename-Item "$WORK\obs-studio-$OBS_VERSION" $OBS } -} else { - Write-Host " OBS source (cached)" -ForegroundColor DarkGray -} - -# ---------- Step 3: Dependencies ---------- -Write-Host "[3/5] OBS pre-built dependencies" -ForegroundColor Cyan -New-Item -ItemType Directory -Path $DEPS -Force | Out-Null -if (-not (Test-Path "$DEPS\include\obs\obs.h")) { - Write-Host " Downloading deps (~60MB)..." -ForegroundColor Yellow - Invoke-WebRequest -Uri "https://github.com/obsproject/obs-deps/releases/download/$DEPS_DATE/windows-deps-$DEPS_DATE-x64.zip" -OutFile "$DEPS\deps.zip" - Expand-Archive -Path "$DEPS\deps.zip" -DestinationPath $DEPS -Force -} else { - Write-Host " Deps (cached)" -ForegroundColor DarkGray -} -if (-not (Test-Path "$DEPS\lib\cmake\Qt6\Qt6Config.cmake")) { - 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 "$DEPS\qt6.zip" - Expand-Archive -Path "$DEPS\qt6.zip" -DestinationPath $DEPS -Force -} else { - Write-Host " Qt6 (cached)" -ForegroundColor DarkGray -} - -# ---------- Step 4: Build OBS ---------- -Write-Host "[4/5] Building OBS libraries" -ForegroundColor Cyan -$obsBuild = "$OBS\build_x64" -if (-not (Test-Path "$obsBuild\libobs\Release\obs.lib")) { - cmake -S $OBS -B $obsBuild ` - -G "Visual Studio 17 2022" -A x64 ` - -DENABLE_PLUGINS=OFF ` - -DENABLE_UI=OFF ` - -DENABLE_SCRIPTING=OFF ` - -DCMAKE_PREFIX_PATH="$DEPS" 2>&1 | Write-Host - - cmake --build $obsBuild --config Debug --target obs-frontend-api -- /m /noLogo 2>&1 | Write-Host - cmake --build $obsBuild --config Release --target obs-frontend-api -- /m /noLogo 2>&1 | Write-Host - cmake --install $obsBuild --component Development --config Debug --prefix "$DEPS" 2>&1 | Write-Host - cmake --install $obsBuild --component Development --config Release --prefix "$DEPS" 2>&1 | Write-Host -} else { - Write-Host " OBS libs (cached)" -ForegroundColor DarkGray -} - -# ---------- Step 5: Build plugin ---------- -Write-Host "[5/5] Building Vulcast Vertical" -ForegroundColor Cyan -Push-Location $SRC - -if (-not (Test-Path "build\CMakeCache.txt")) { - cmake -S . -B build ` - -G "Visual Studio 17 2022" -A x64 ` - -DBUILD_OUT_OF_TREE=On ` - -DCMAKE_PREFIX_PATH="$DEPS" ` - -DQT_VERSION=6 ` - -DCMAKE_BUILD_TYPE=Release ` - -DFETCHCONTENT_FULLY_DISCONNECTED=ON 2>&1 | Write-Host -} -cmake --build build --config Release -- /m /noLogo 2>&1 | Write-Host -Pop-Location - -# ---------- Install to OBS ---------- -$dll = Get-ChildItem -Path "$SRC\build" -Recurse -Filter "*.dll" -ErrorAction SilentlyContinue | - Where-Object { $_.Name -notmatch 'Qt6|obs-' } | Select-Object -First 1 - -if (-not $dll) { - Write-Error "DLL not found. Check output above." - exit 1 -} - -if (-not (Test-Path $OBS_PLUGIN_DIR)) { - Write-Warning "OBS not found at default path. Searching..." - $OBS_PLUGIN_DIR = Get-ChildItem -Path "C:\Program Files","C:\Program Files (x86)" -Recurse -Filter "obs-plugins" -Directory -ErrorAction SilentlyContinue | - Where-Object { $_.Parent.Name -eq 'obs-studio' } | Select-Object -First 1 -ExpandProperty FullName - if (-not $OBS_PLUGIN_DIR) { - Write-Error "Can't find OBS plugins folder. Copy manually:" - Write-Error " $($dll.FullName)" - exit 1 - } -} - -Copy-Item $dll.FullName "$OBS_PLUGIN_DIR\vulcast-vertical.dll" -Force -Write-Host "`n=== BUILD SUCCESSFUL ===" -ForegroundColor Green -Write-Host "Installed: $OBS_PLUGIN_DIR\vulcast-vertical.dll" -ForegroundColor Green -Write-Host "`nRestart OBS Studio to load the plugin."