Procházet zdrojové kódy

CI: Add Powershell-based scripts for Windows

PatTheMav před 3 roky
rodič
revize
518b288558

+ 3 - 0
.github/scripts/.Wingetfile

@@ -0,0 +1,3 @@
+package '7zip.7zip', path: '7-zip', bin: '7z'
+package 'cmake', path: 'Cmake\bin', bin: 'cmake'
+package 'innosetup', path: 'Inno Setup 6', bin: 'iscc'

+ 84 - 0
.github/scripts/Build-Windows.ps1

@@ -0,0 +1,84 @@
+[CmdletBinding()]
+param(
+    [ValidateSet('Debug', 'RelWithDebInfo', 'Release', 'MinSizeRel')]
+    [string] $Configuration = 'RelWithDebInfo',
+    [ValidateSet('x86', 'x64')]
+    [string] $Target,
+    [ValidateSet('Visual Studio 17 2022', 'Visual Studio 16 2019')]
+    [string] $CMakeGenerator = 'Visual Studio 16 2019'
+)
+
+$ErrorActionPreference = 'Stop'
+
+if ( $DebugPreference -eq 'Continue' ) {
+    $VerbosePreference = 'Continue'
+    $InformationPreference = 'Continue'
+}
+
+if ( $PSVersionTable.PSVersion -lt '7.0.0' ) {
+    Write-Warning 'The obs-deps PowerShell build script requires PowerShell Core 7. Install or upgrade your PowerShell version: https://aka.ms/pscore6'
+    exit 2
+}
+
+function Build {
+    trap {
+        Pop-Location -Stack BuildTemp
+        Write-Error $_
+        exit 2
+    }
+
+    $ScriptHome = $PSScriptRoot
+    $ProjectRoot = Resolve-Path -Path "$PSScriptRoot/../.."
+    $BuildSpecFile = "${ProjectRoot}/buildspec.json"
+
+    $UtilityFunctions = Get-ChildItem -Path $PSScriptRoot/utils.pwsh/*.ps1 -Recurse
+
+    foreach($Utility in $UtilityFunctions) {
+        Write-Debug "Loading $($Utility.FullName)"
+        . $Utility.FullName
+    }
+
+    $BuildSpec = Get-Content -Path ${BuildSpecFile} -Raw | ConvertFrom-Json
+    $ProductName = $BuildSpec.name
+    $ProductVersion = $BuildSpec.version
+
+    Setup-Host
+
+    (Get-Content -Path ${ProjectRoot}/CMakeLists.txt -Raw) `
+        -replace "project\((.*) VERSION (.*)\)", "project(${ProductName} VERSION ${ProductVersion})" `
+        | Out-File -Path ${ProjectRoot}/CMakeLists.txt
+
+    Setup-Obs
+
+    Push-Location -Stack BuildTemp
+
+    Ensure-Location $ProjectRoot
+
+    $CmakeArgs = @(
+        '-G', $CmakeGenerator
+        '-DCMAKE_SYSTEM_VERSION=10.0.18363.657'
+        "-DCMAKE_GENERATOR_PLATFORM=$(if (${script:Target} -eq "x86") { "Win32" } else { "x64" })"
+        "-DCMAKE_BUILD_TYPE=${Configuration}"
+        "-DCMAKE_PREFIX_PATH=$(Resolve-Path -Path "${ProjectRoot}/../obs-build-dependencies/plugin-deps-${Target}")"
+    )
+
+    Log-Information "Configuring ${ProductName}..."
+    Invoke-External cmake -S . -B build_${script:Target} @CmakeArgs
+
+    $CmakeArgs = @(
+        '--config', "${Configuration}"
+    )
+
+    if ( $VerbosePreference -eq 'Continue' ) {
+        $CmakeArgs+=('--verbose')
+    }
+
+    Log-Information "Building ${ProductName}..."
+    Invoke-External cmake --build "build_${script:Target}" @CmakeArgs
+    Log-Information "Install ${ProductName}..."
+    Invoke-External cmake --install "build_${script:Target}" --prefix "${ProjectRoot}/release" @CmakeArgs
+
+    Pop-Location -Stack BuildTemp
+}
+
+Build

+ 92 - 0
.github/scripts/Package-Windows.ps1

@@ -0,0 +1,92 @@
+[CmdletBinding()]
+param(
+    [ValidateSet('Debug', 'RelWithDebInfo', 'Release', 'MinSizeRel')]
+    [string] $Configuration = 'RelWithDebInfo',
+    [ValidateSet('x86', 'x64', 'x86+x64')]
+    [string] $Target,
+    [switch] $BuildInstaller = $false
+)
+
+$ErrorActionPreference = 'Stop'
+
+if ( $DebugPreference -eq 'Continue' ) {
+    $VerbosePreference = 'Continue'
+    $InformationPreference = 'Continue'
+}
+
+if ( $PSVersionTable.PSVersion -lt '7.0.0' ) {
+    Write-Warning 'The obs-deps PowerShell build script requires PowerShell Core 7. Install or upgrade your PowerShell version: https://aka.ms/pscore6'
+    exit 2
+}
+
+function Package {
+    trap {
+        Write-Error $_
+        exit 2
+    }
+
+    $ScriptHome = $PSScriptRoot
+    $ProjectRoot = Resolve-Path -Path "$PSScriptRoot/../.."
+    $BuildSpecFile = "${ProjectRoot}/buildspec.json"
+
+    $UtilityFunctions = Get-ChildItem -Path $PSScriptRoot/utils.pwsh/*.ps1 -Recurse
+
+    foreach( $Utility in $UtilityFunctions ) {
+        Write-Debug "Loading $($Utility.FullName)"
+        . $Utility.FullName
+    }
+
+    $BuildSpec = Get-Content -Path ${BuildSpecFile} -Raw | ConvertFrom-Json
+    $ProductName = $BuildSpec.name
+    $ProductVersion = $BuildSpec.version
+
+    $OutputName = "${ProductName}-${ProductVersion}-windows-${Target}"
+
+    Install-BuildDependencies -WingetFile "${ScriptHome}/.Wingetfile"
+
+    Log-Information "Packaging ${ProductName}..."
+
+    $RemoveArgs = @{
+        ErrorAction = 'SilentlyContinue'
+        Path = @(
+            "${ProjectRoot}/release/${ProductName}-${ProductVersion}-windows-*.zip"
+            "${ProjectRoot}/release/${ProductName}-${ProductVersion}-windows-*.exe"
+        )
+    }
+
+    Remove-Item @RemoveArgs
+
+    if ( ( $BuildInstaller ) ) {
+        if ( $Target -eq 'x86+x64' ) {
+            $IsccCandidates = Get-ChildItem -Recurse -Path '*.iss'
+
+            if ( $IsccCandidates.length -gt 0 ) {
+                $IsccFile = $IsccCandidates[0].FullName
+            } else {
+                $IsccFile = ''
+            }
+        } else {
+            $IsccFile = "${ProjectRoot}/build_${Target}/installer-Windows.generated.iss"
+        }
+
+        if ( ! ( Test-Path -Path $IsccFile ) ) {
+            throw 'InnoSetup install script not found. Run the build script or the CMake build and install procedures first.'
+        }
+
+        Log-Information 'Creating InnoSetup installer...'
+        Push-Location -Stack BuildTemp
+        Ensure-Location -Path "${ProjectRoot}/release"
+        Invoke-External iscc ${IsccFile} /O. /F"${OutputName}-Installer"
+        Pop-Location -Stack BuildTemp
+    }
+
+    $CompressArgs = @{
+        Path = (Get-ChildItem -Path "${ProjectRoot}/release" -Exclude "${OutputName}*.*")
+        CompressionLevel = 'Optimal'
+        DestinationPath = "${ProjectRoot}/release/${OutputName}.zip"
+    }
+
+    Compress-Archive -Force @CompressArgs
+}
+
+Package

+ 25 - 0
.github/scripts/utils.pwsh/Check-Git.ps1

@@ -0,0 +1,25 @@
+function Check-Git {
+    <#
+        .SYNOPSIS
+            Ensures available git executable on host system.
+        .DESCRIPTION
+            Checks whether a git command is available on the host system. If none is found,
+            Git is installed via winget.
+        .EXAMPLE
+            Check-Git
+    #>
+
+    if ( ! ( Test-Path function:Log-Info ) ) {
+        . $PSScriptRoot/Logger.ps1
+    }
+
+    Log-Information 'Checking for Git executable...'
+
+    if ( ! ( Get-Command git ) ) {
+        Log-Warning 'No Git executable found. Will try to install via winget.'
+        winget install git
+    } else {
+        Log-Debug "Git found at $(Get-Command git)."
+        Log-Status "Git found."
+    }
+}

+ 29 - 0
.github/scripts/utils.pwsh/Ensure-Location.ps1

@@ -0,0 +1,29 @@
+function Ensure-Location {
+    <#
+        .SYNOPSIS
+            Ensures current location to be set to specified directory.
+        .DESCRIPTION
+            If specified directory exists, switch to it. Otherwise create it,
+            then switch.
+        .EXAMPLE
+            Ensure-Location "My-Directory"
+            Ensure-Location -Path "Path-To-My-Directory"
+    #>
+
+    param(
+        [Parameter(Mandatory)]
+        [string] $Path
+    )
+
+    if ( ! ( Test-Path $Path ) ) {
+        $_Params = @{
+            ItemType = "Directory"
+            Path = ${Path}
+            ErrorAction = "SilentlyContinue"
+        }
+
+        New-Item @_Params | Set-Location
+    } else {
+        Set-Location -Path ${Path}
+    }
+}

+ 70 - 0
.github/scripts/utils.pwsh/Expand-ArchiveExt.ps1

@@ -0,0 +1,70 @@
+function Expand-ArchiveExt {
+    <#
+        .SYNOPSIS
+            Expands archive files.
+        .DESCRIPTION
+            Allows extraction of zip, 7z, gz, and xz archives.
+            Requires tar and 7-zip to be available on the system.
+            Archives ending with .zip but created using LZMA compression are
+            expanded using 7-zip as a fallback.
+        .EXAMPLE
+            Expand-ArchiveExt -Path <Path-To-Your-Archive>
+            Expand-ArchiveExt -Path <Path-To-Your-Archive> -DestinationPath <Expansion-Path>
+    #>
+
+    param(
+        [Parameter(Mandatory)]
+        [string] $Path,
+        [string] $DestinationPath = [System.IO.Path]::GetFileNameWithoutExtension($Path),
+        [switch] $Force
+    )
+
+    switch ( [System.IO.Path]::GetExtension($Path) ) {
+        .zip {
+            try {
+                Expand-Archive -Path $Path -DestinationPath $DestinationPath -Force:$Force
+            } catch {
+                if ( Get-Command 7z ) {
+                    Invoke-External 7z x -y $Path "-o${DestinationPath}"
+                } else {
+                    throw 'Fallback utility 7-zip not found. Please install 7-zip first.'
+                }
+            }
+            break
+        }
+        .7z {
+            if ( Get-Command 7z ) {
+                Invoke-External 7z x -y $Path "-o${DestinationPath}"
+            } else {
+                throw 'Extraction utility 7-zip not found. Please install 7-zip first.'
+            }
+            break
+        }
+        .gz {
+            try {
+                Invoke-External tar -x -o $DestinationPath -f $Path
+            } catch {
+                if ( Get-Command 7z ) {
+                    Invoke-External 7z x -y $Path "-o${DestinationPath}"
+                } else {
+                    throw 'Fallback utility 7-zip not found. Please install 7-zip first.'
+                }
+            }
+            break
+        }
+        .xz {
+            try {
+                Invoke-External tar -x -o $DestinationPath -f $Path
+            } catch {
+                if ( Get-Command 7z ) {
+                    Invoke-External 7z x -y $Path "-o${DestinationPath}"
+                } else {
+                    throw 'Fallback utility 7-zip not found. Please install 7-zip first.'
+                }
+            }
+        }
+        default {
+            throw 'Unsupported archive extension provided.'
+        }
+    }
+}

+ 60 - 0
.github/scripts/utils.pwsh/Install-BuildDependencies.ps1

@@ -0,0 +1,60 @@
+function Install-BuildDependencies {
+    <#
+        .SYNOPSIS
+            Installs required build dependencies.
+        .DESCRIPTION
+            Additional packages might be needed for successful builds. This module contains additional
+            dependencies available for installation via winget and, if possible, adds their locations
+            to the environment path for future invocation.
+        .EXAMPLE
+            Install-BuildDependencies
+    #>
+
+    param(
+        [string] $WingetFile = "$PSScriptRoot/.Wingetfile"
+    )
+
+    if ( ! ( Test-Path function:Log-Warning ) ) {
+        . $PSScriptRoot/Logger.ps1
+    }
+    
+    $Host64Bit = [System.Environment]::Is64BitOperatingSystem
+
+    $Paths = $Env:Path -split [System.IO.Path]::PathSeparator
+
+    $WingetOptions = @('install', '--accept-package-agreements', '--accept-source-agreements')
+
+    if ( $script:Quiet ) {
+        $WingetOptions += '--silent'
+    }
+
+    Get-Content $WingetFile | ForEach-Object {
+        $_, $Package, $_, $Path, $_, $Binary = ([regex]::Split($_, " (?=(?:[^']|'[^']*')*$)")) -replace ',', '' -replace "'",''
+
+        (${Env:ProgramFiles(x86)}, $Env:ProgramFiles) | ForEach-Object {
+            $Prefix = $_
+            $FullPath = "${Prefix}\${Path}"
+            if ( ( Test-Path $FullPath  ) -and ! ( $Paths -contains $FullPath ) ) {
+                $Paths += $FullPath
+                $Env:Path = $Paths -join [System.IO.Path]::PathSeparator
+            }
+        }
+
+        Log-Debug "Checking for command ${Binary}"
+        $Found = Get-Command -ErrorAction SilentlyContinue $Binary
+
+        if ( $Found ) {
+            Log-Status "Found dependency ${Binary} as $($Found.Source)"
+        } else {
+            Log-Status "Installing package ${Package}"
+
+            try {
+                $Params = $WingetOptions + $Package
+
+                winget @Params
+            } catch {
+                throw "Error while installing winget package ${Package}: $_"
+            }
+        }
+    }
+}

+ 40 - 0
.github/scripts/utils.pwsh/Invoke-External.ps1

@@ -0,0 +1,40 @@
+function Invoke-External {
+    <#
+        .SYNOPSIS
+            Invokes a non-PowerShell command.
+        .DESCRIPTION
+            Runs a non-PowerShell command, and captures its return code.
+            Throws an exception if the command returns non-zero.
+        .EXAMPLE
+            Invoke-External 7z x $MyArchive
+    #>
+
+    if ( $args.Count -eq 0 ) {
+        throw 'Invoke-External called without arguments.'
+    }
+
+    if ( ! ( Test-Path function:Log-Information ) ) {
+        . $PSScriptRoot/Utils-Logger.ps1
+    }
+
+    $Command = $args[0]
+    $CommandArgs = @()
+
+    if ( $args.Count -gt 1) {
+        $CommandArgs = $args[1..($args.Count - 1)]
+    }
+
+    $_EAP = $ErrorActionPreference
+    $ErrorActionPreference = "Continue"
+
+    Log-Debug "Invoke-External: ${Command} ${CommandArgs}"
+
+    & $command $commandArgs
+    $Result = $LASTEXITCODE
+
+    $ErrorActionPreference = $_EAP
+
+    if ( $Result -ne 0 ) {
+        throw "${Command} ${CommandArgs} exited with non-zero code ${Result}."
+    }
+}

+ 117 - 0
.github/scripts/utils.pwsh/Invoke-GitCheckout.ps1

@@ -0,0 +1,117 @@
+function Set-GitConfig {
+    <#
+        .SYNOPSIS
+            Sets a git config value.
+        .DESCRIPTION
+            Allows setting single or multiple config values in a PowerShell-friendly fashion.
+        .EXAMPLE
+            Set-GitConfig advice.detachedHead false
+    #>
+
+    if ( $args.Count -lt 2 ) {
+        throw 'Set-GitConfig called without required arguments <OPTION> <VALUE>.'
+    }
+
+    Invoke-External git config @args
+}
+
+function Invoke-GitCheckout {
+    <#
+        .SYNOPSIS
+            Checks out a specified git repository.
+        .DESCRIPTION
+            Wraps the git executable with PowerShell syntax to check out
+            a specified Git repository with a given commit hash and branch,
+            or a GitHub pull request ID.
+        .EXAMPLE
+            Invoke-GitCheckout -Uri "My-Repo-Uri" -Commit "My-Commit-Hash"
+            Invoke-GitCheckout -Uri "My-Repo-Uri" -Commit "My-Commit-Hash" -Branch "main"
+            Invoke-GitCheckout -Uri "My-Repo-Uri" -Commit "My-Commit-Hash" -PullRequest 250
+    #>
+
+    param(
+        [Parameter(Mandatory)]
+        [string] $Uri,
+        [Parameter(Mandatory)]
+        [string] $Commit,
+        [string] $Path,
+        [string] $Branch = "master",
+        [string] $PullRequest
+    )
+
+    if ( ! ( $Uri -like "*github.com*" ) -and ( $PullRequest -ne "" ) ) {
+        throw 'Fetching pull requests is only supported with GitHub-based repositories.'
+    }
+
+    if ( ! ( Test-Path function:Log-Information ) ) {
+        . $PSScriptRoot/Utils-Logger.ps1
+    }
+
+    if ( ! ( Test-Path function:Invoke-External ) ) {
+        . $PSScriptRoot/Invoke-External.ps1
+    }
+
+    $RepositoryName = [System.IO.Path]::GetFileNameWithoutExtension($Uri)
+
+    if ( $Path -eq "" ) {
+        $Path = "$(Get-Location | Convert-Path)\${RepositoryName}"
+    }
+
+    Push-Location -Stack GitCheckoutTemp
+
+    if ( Test-Path $Path/.git ) {
+        Write-Information "Repository ${RepositoryName} found in ${Path}"
+
+        Set-Location $Path
+
+        Set-GitConfig advice.detachedHead false
+        Set-GitConfig remote.origin.url $Uri
+        Set-GitConfig remote.origin.tapOpt --no-tags
+
+        $Ref = "+refs/heads/{0}:refs/remotes/origin/{0}" -f $Branch
+
+        Set-GitConfig --replace-all remote.origin.fetch $Ref
+
+        if ( $PullRequest -ne "" ) {
+            try {
+                Invoke-External git show-ref --quiet --verify refs/heads/pr-$PullRequest
+            } catch {
+                Invoke-External git fetch origin $("pull/{0}/head:pull-{0}" -f $PullRequest)
+            } finally {
+                Invoke-External git checkout -f "pull-${PullRequest}"
+            }
+        }
+
+        try {
+            $null = Invoke-External git rev-parse -q --verify "${Commit}^{commit}"
+        } catch {
+            Invoke-External git fetch origin
+        }
+
+        Invoke-External git checkout -f $Commit -- | Log-Information
+    } else {
+        Invoke-External git clone $Uri $Path
+
+        Set-Location $Path
+
+        Set-GitConfig advice.detachedHead false
+
+        if ( $PullRequest -ne "" ) {
+            $Ref = "pull/{0}/head:pull-{0}" -f $PullRequest
+            $Branch = "pull-${PullRequest}"
+            Invoke-External git fetch origin $Ref
+            Invoke-External git checkout $Branch
+        }
+
+        Invoke-External git checkout -f $Commit
+    }
+
+    Log-Information "Checked out commit ${Commit} on branch ${Branch}"
+
+    if ( Test-Path ${Path}/.gitmodules ) {
+        Invoke-External git submodule foreach --recursive git submodule sync
+        Invoke-External git submodule update --init --recursive
+    }
+
+    Pop-Location -Stack GitCheckoutTemp
+}

+ 123 - 0
.github/scripts/utils.pwsh/Logger.ps1

@@ -0,0 +1,123 @@
+function Log-Debug {
+    [CmdletBinding()]
+    param(
+        [Parameter(Mandatory,ValueFromPipeline)]
+        [ValidateNotNullOrEmpty()]
+        [string[]] $Message
+    )
+
+    Process {
+        foreach($m in $Message) {
+            Write-Debug $m
+        }
+    }
+}
+
+function Log-Verbose {
+    [CmdletBinding()]
+    param(
+        [Parameter(Mandatory,ValueFromPipeline)]
+        [ValidateNotNullOrEmpty()]
+        [string[]] $Message
+    )
+
+    Process {
+        foreach($m in $Message) {
+            Write-Verbose $m
+        }
+    }
+}
+
+function Log-Warning {
+    [CmdletBinding()]
+    param(
+        [Parameter(Mandatory,ValueFromPipeline)]
+        [ValidateNotNullOrEmpty()]
+        [string[]] $Message
+    )
+
+    Process {
+        foreach($m in $Message) {
+            Write-Warning $m
+        }
+    }
+}
+
+function Log-Error {
+    [CmdletBinding()]
+    param(
+        [Parameter(Mandatory,ValueFromPipeline)]
+        [ValidateNotNullOrEmpty()]
+        [string[]] $Message
+    )
+
+    Process {
+        foreach($m in $Message) {
+            Write-Error $m
+        }
+    }
+}
+
+function Log-Information {
+    [CmdletBinding()]
+    param(
+        [Parameter(Mandatory,ValueFromPipeline)]
+        [ValidateNotNullOrEmpty()]
+        [string[]] $Message
+    )
+
+    Process {
+        if ( ! ( $script:Quiet ) ) {
+            $StageName = $( if ( $script:StageName -ne $null ) { $script:StageName } else { '' })
+            $Icon = ' =>'
+
+            foreach($m in $Message) {
+                Write-Host -NoNewLine -ForegroundColor Blue "  ${StageName} $($Icon.PadRight(5)) "
+                Write-Host "${m}"
+            }
+        }
+    }
+}
+
+function Log-Status {
+    [CmdletBinding()]
+    param(
+        [Parameter(Mandatory,ValueFromPipeline)]
+        [ValidateNotNullOrEmpty()]
+        [string[]] $Message
+    )
+
+    Process {
+        if ( ! ( $script:Quiet ) ) {
+            $StageName = $( if ( $StageName -ne $null ) { $StageName } else { '' })
+            $Icon = '  >'
+
+            foreach($m in $Message) {
+                Write-Host -NoNewLine -ForegroundColor Green "  ${StageName} $($Icon.PadRight(5)) "
+                Write-Host "${m}"
+            }
+        }
+    }
+}
+
+function Log-Output {
+    [CmdletBinding()]
+    param(
+        [Parameter(Mandatory,ValueFromPipeline)]
+        [ValidateNotNullOrEmpty()]
+        [string[]] $Message
+    )
+
+    Process {
+        if ( ! ( $script:Quiet ) ) {
+            $StageName = $( if ( $script:StageName -ne $null ) { $script:StageName } else { '' })
+            $Icon = ''
+
+            foreach($m in $Message) {
+                Write-Output "  ${StageName} $($Icon.PadRight(5)) ${m}"
+            }
+        }
+    }
+}
+
+$Columns = (Get-Host).UI.RawUI.WindowSize.Width - 5

+ 110 - 0
.github/scripts/utils.pwsh/Setup-Host.ps1

@@ -0,0 +1,110 @@
+function Setup-Host {
+    if ( ! ( Test-Path function:Log-Output ) ) {
+        . $PSScriptRoot/Logger.ps1
+    }
+
+    if ( ! ( Test-Path function:Ensure-Location ) ) {
+        . $PSScriptRoot/Ensure-Location.ps1
+    }
+
+    if ( ! ( Test-Path function:Install-BuildDependencies ) ) {
+        . $PSScriptRoot/Install-BuildDependencies.ps1
+    }
+
+    Install-BuildDependencies -WingetFile "${ScriptHome}/.Wingetfile"
+
+    if ( $script:Target -eq '' ) { $script:Target = $script:HostArchitecture }
+
+    Push-Location -Stack BuildTemp
+    Log-Information 'Setting up obs-deps...'
+    $DepsVersion = $BuildSpec.dependencies.'obs-deps'."windows-${script:Target}".version
+    $DepsHash = $BuildSpec.dependencies.'obs-deps'."windows-${script:Target}".hash
+
+    if ( ${DepsVersion} -eq '' ) {
+        throw 'No obs-deps version found in buildspec.json.'
+    }
+    Log-Status 'Found obs-deps specification.'
+
+    Ensure-Location -Path "$(Resolve-Path -Path "${ProjectRoot}/..")/obs-build-dependencies"
+
+    if ( ! ( Test-Path -Path "windows-deps-${DepsVersion}-${script:Target}.zip" ) ) {
+        $Params = @{
+            UserAgent = 'NativeHost'
+            Uri = "https://github.com/obsproject/obs-deps/releases/download/win-${DepsVersion}/windows-deps-${DepsVersion}-${script:Target}.zip"
+            OutFile = "windows-deps-${DepsVersion}-${script:Target}.zip"
+            UseBasicParsing = $true
+            ErrorAction = 'Stop'
+        }
+
+        Invoke-WebRequest @Params
+        Log-Status "Downloaded obs-deps for ${script:Target}."
+    } else {
+        Log-Status 'Found downloaded obs-deps.'
+    }
+
+    $FileHash = Get-FileHash -Path "windows-deps-${DepsVersion}-${script:Target}.zip" -Algorithm SHA256
+
+    if ( $FileHash.Hash.ToLower() -ne $DepsHash ) {
+        throw "Checksum mismatch of obs-deps download. Expected '${DepsHash}', found '$(${FileHash}.Hash.ToLower())'"
+    }
+    Log-Status 'Checksum of downloaded obs-deps matches.'
+
+    Ensure-Location -Path "plugin-deps-${Target}"
+
+    if ( ! ( Test-Path function:Expand-ArchiveExt ) ) {
+        . $PSScriptRoot/Expand-ArchiveExt.ps1
+    }
+
+    Log-Information 'Extracting obs-deps...'
+    Expand-ArchiveExt -Path "../windows-deps-${DepsVersion}-${script:Target}.zip" -DestinationPath . -Force
+    Pop-Location -Stack BuildTemp
+
+    Push-Location -Stack BuildTemp
+    Log-Information 'Setting up Qt...'
+    $QtVersion = $BuildSpec.dependencies.'obs-deps-qt'."windows-${script:Target}".version
+    $QtHash = $BuildSpec.dependencies.'obs-deps-qt'."windows-${script:Target}".hash
+
+    if ( ${QtVersion} -eq '' ) {
+        throw 'No Qt version found in buildspec.json.'
+    }
+    Log-Status 'Found Qt specification.'
+
+    Ensure-Location -Path "$(Resolve-Path -Path "${ProjectRoot}/..")/obs-build-dependencies"
+
+    if ( ! ( Test-Path -Path "windows-deps-qt-${DepsVersion}-${script:Target}.zip" ) ) {
+        $Params = @{
+            UserAgent = 'NativeHost'
+            Uri = "https://cdn-fastly.obsproject.com/downloads/windows-deps-qt-${DepsVersion}-${script:Target}.zip"
+            OutFile = "windows-deps-qt-${DepsVersion}-${script:Target}.zip"
+            UseBasicParsing = $true
+            ErrorAction = 'Stop'
+        }
+
+        Invoke-WebRequest @Params
+        Log-Status "Downloaded Qt for ${script:Target}."
+    } else {
+        Log-Status 'Found downloaded Qt.'
+    }
+
+    $FileHash = Get-FileHash -Path "windows-deps-qt-${DepsVersion}-${script:Target}.zip" -Algorithm SHA256
+
+    if ( $FileHash.Hash.ToLower() -ne ${QtHash} ) {
+        throw "Checksum mismatch of Qt download. Expected '${QtHash}', found '$(${FileHash}.Hash.ToLower())'"
+    }
+    Log-Status 'Checksum of downloaded Qt matches.'
+
+    Ensure-Location -Path "plugin-deps-${Target}"
+
+    Log-Information 'Extracting Qt...'
+    Expand-ArchiveExt -Path "../windows-deps-qt-${DepsVersion}-${script:Target}.zip" -DestinationPath . -Force
+    Pop-Location -Stack BuildTemp
+}
+
+function Get-HostArchitecture {
+    $Host64Bit = [System.Environment]::Is64BitOperatingSystem
+    $HostArchitecture = ('x86', 'x64')[$Host64Bit]
+
+    return $HostArchitecture
+}
+
+$script:HostArchitecture = Get-HostArchitecture

+ 77 - 0
.github/scripts/utils.pwsh/Setup-Obs.ps1

@@ -0,0 +1,77 @@
+function Setup-Obs {
+    if ( ! ( Test-Path function:Log-Output ) ) {
+        . $PSScriptRoot/Logger.ps1
+    }
+
+    if ( ! ( Test-Path function:Check-Git ) ) {
+        . $PSScriptRoot/Check-Git.ps1
+    }
+
+    Check-Git
+
+    if ( ! ( Test-Path function:Ensure-Location ) ) {
+        . $PSScriptRoot/Ensure-Location.ps1
+    }
+
+    if ( ! ( Test-Path function:Invoke-GitCheckout ) ) {
+        . $PSScriptRoot/Invoke-GitCheckout.ps1
+    }
+
+    if ( ! ( Test-Path function:Invoke-External ) ) {
+        . $PSScriptRoot/Invoke-External.ps1
+    }
+
+    Log-Information 'Setting up OBS Studio...'
+
+    $ObsVersion = $BuildSpec.dependencies.'obs-studio'.version
+    $ObsRepository = $BuildSpec.dependencies.'obs-studio'.repository
+    $ObsBranch = $BuildSpec.dependencies.'obs-studio'.branch
+    $ObsHash = $BuildSpec.dependencies.'obs-studio'.hash
+
+    if ( $ObsVersion -eq '' ) {
+        throw 'No obs-studio version found in buildspec.json.'
+    }
+
+    Push-Location -Stack BuildTemp
+    Ensure-Location -Path "$(Resolve-Path -Path "${ProjectRoot}/../")/obs-studio"
+
+    Invoke-GitCheckout -Uri $ObsRepository -Commit $ObsHash -Path . -Branch $ObsBranch
+
+    Log-Information 'Configuring OBS Studio...'
+
+    $NumProcessors = (Get-CimInstance Win32_ComputerSystem).NumberOfLogicalProcessors
+
+    if ( $NumProcessors -gt 1 ) {
+        $env:UseMultiToolTask = $true
+        $env:EnforceProcessCountAcrossBuilds = $true
+    }
+
+    $CmakeArgs = @(
+        '-G', $script:CmakeGenerator
+        '-DCMAKE_SYSTEM_VERSION=10.0.18363.657'
+        "-DCMAKE_GENERATOR_PLATFORM=$(if (${script:Target} -eq "x86") { "Win32" } else { "x64" })"
+        "-DCMAKE_BUILD_TYPE=${script:Configuration}"
+        '-DENABLE_PLUGINS=OFF'
+        '-DENABLE_UI=OFF'
+        '-DENABLE_SCRIPTING=OFF'
+        "-DCMAKE_INSTALL_PREFIX=$(Resolve-Path -Path "${ProjectRoot}/../obs-build-dependencies/plugin-deps-${Target}")"
+        "-DCMAKE_PREFIX_PATH=$(Resolve-Path -Path "${ProjectRoot}/../obs-build-dependencies/plugin-deps-${Target}")"
+    )
+
+    Invoke-External cmake -S . -B plugin_${script:Target} @CmakeArgs
+
+    Log-Information 'Building libobs and obs-frontend-api...'
+
+    $CmakeArgs = @(
+        '--config', "$( if ( $script:Configuration -eq '' ) { 'RelWithDebInfo' } else { $script:Configuration })"
+    )
+
+    if ( $VerbosePreference -eq 'Continue' ) {
+        $CmakeArgs+=('--verbose')
+    }
+
+    Invoke-External cmake --build plugin_${script:Target} @CmakeArgs -t obs-frontend-api
+    Invoke-External cmake --install plugin_${script:Target} @CmakeArgs --component obs_libraries
+
+    Pop-Location -Stack BuildTemp
+}

+ 0 - 132
CI/build-windows.ps1

@@ -1,132 +0,0 @@
-Param(
-    [Switch]$Help,
-    [Switch]$Quiet,
-    [Switch]$Verbose,
-    [Switch]$NoChoco,
-    [Switch]$SkipDependencyChecks,
-    [Switch]$BuildInstaller,
-    [Switch]$CombinedArchs,
-    [String]$BuildDirectory = "build",
-    [String]$BuildArch = (Get-CimInstance CIM_OperatingSystem).OSArchitecture,
-    [String]$BuildConfiguration = "RelWithDebInfo"
-)
-
-##############################################################################
-# Windows plugin build script
-##############################################################################
-#
-# This script contains all steps necessary to:
-#
-#   * Build libobs and obs-frontend-api with all required dependencies
-#   * Build your plugin
-#   * Create 64-bit or 32-bit packages
-#   * Create 64-bit or 32-bit installation packages
-#   * Create combined installation packages
-#
-# Parameters:
-#   -Help                   : Print usage help
-#   -NoChco                 : Skip automatic dependency installation
-#                             via Chocolatey
-#   -SkipDependencyChecks   : Skips dependency checks
-#   -BuildDirectory         : Directory to use for builds
-#                             Default: Win64 on 64-bit systems
-#                                      Win32 on 32-bit systems
-#  -BuildArch               : Build architecture to use (32bit or 64bit)
-#  -BuildConfiguration      : Build configuration to use
-#                             Default: RelWithDebInfo
-#  -BuildInstaller          : Build InnoSetup installer - Default: off"
-#  -CombinedArchs           : Create combined packages and installer
-#                             (64-bit and 32-bit) - Default: off"
-#
-# Environment Variables (optional):
-#  WindowsDepsVersion       : Pre-compiled Windows dependencies version
-#  WindowsQtVersion         : Pre-compiled Qt version
-#  ObsVersion               : OBS Version
-#
-##############################################################################
-
-$ErrorActionPreference = "Stop"
-
-$_RunObsBuildScript = $true
-
-$CheckoutDir = git rev-parse --show-toplevel
-
-$DepsBuildDir = "${CheckoutDir}/../obs-build-dependencies"
-$ObsBuildDir = "${CheckoutDir}/../obs-studio"
-
-if (Test-Path ${CheckoutDir}/CI/include/build_environment.ps1) {
-    . ${CheckoutDir}/CI/include/build_environment.ps1
-}
-
-. ${CheckoutDir}/CI/include/build_support_windows.ps1
-
-## DEPENDENCY INSTALLATION ##
-. ${CheckoutDir}/CI/windows/01_install_dependencies.ps1
-
-## OBS LIBRARY BUILD ##
-. ${CheckoutDir}/CI/windows/02_build_obs_libs.ps1
-
-## PLUGIN BUILD ##
-. ${CheckoutDir}/CI/windows/03_build_plugin.ps1
-
-## PLUGIN PACKAGE AND NOTARIZE ##
-. ${CheckoutDir}/CI/windows/04_package_plugin.ps1
-
-## MAIN SCRIPT FUNCTIONS ##
-function Build-Obs-Plugin-Main {
-    Ensure-Directory ${CheckoutDir}
-    Write-Step "Fetching version tags..."
-    & git fetch origin --tags
-    $GitBranch = git rev-parse --abbrev-ref HEAD
-    $GitHash = git rev-parse --short HEAD
-    $ErrorActionPreference = "SilentlyContiue"
-    $GitTag = git describe --tags --abbrev=0
-    $ErrorActionPreference = "Stop"
-
-    if ($GitTag -eq $null) {
-        $GitTag=$ProductVersion
-    }
-
-    $FileName = "${ProductName}-${GitTag}-${GitHash}"
-
-    if(!($SkipDependencyChecks.isPresent)) {
-        Install-Dependencies -NoChoco:$NoChoco
-    }
-
-    if($CombinedArchs.isPresent) {
-        Build-OBS-Libs -BuildArch 64-bit
-        Build-OBS-Libs -BuildArch 32-bit
-        Build-OBS-Plugin -BuildArch 64-bit
-        Build-OBS-Plugin -BuildArch 32-bit
-    } else {
-        Build-OBS-Libs
-        Build-OBS-Plugin
-    }
-
-    Package-OBS-Plugin
-}
-
-function Print-Usage {
-    Write-Host "build-windows.ps1 - Build script for ${ProductName}"
-    $Lines = @(
-        "Usage: ${MyInvocation.MyCommand.Name}",
-        "-Help                    : Print this help",
-        "-Quiet                   : Suppress most build process output"
-        "-Verbose                 : Enable more verbose build process output"
-        "-NoChoco                 : Skip automatic dependency installation via Chocolatey - Default: on",
-        "-SkipDependencyChecks    : Skips dependency checks - Default: off",
-        "-BuildDirectory          : Directory to use for builds - Default: build64 on 64-bit systems, build32 on 32-bit systems",
-        "-BuildArch               : Build architecture to use (32bit or 64bit) - Default: local architecture",
-        "-BuildConfiguration      : Build configuration to use - Default: RelWithDebInfo",
-        "-BuildInstaller          : Build InnoSetup installer - Default: off",
-        "-CombinedArchs           : Create combined packages and installer (64-bit and 32-bit) - Default: off"
-    )
-    $Lines | Write-Host
-}
-
-if($Help.isPresent) {
-    Print-Usage
-    exit 0
-}
-
-Build-Obs-Plugin-Main

+ 0 - 2
CI/include/build_environment.ps1.in

@@ -1,2 +0,0 @@
-$ProductName = "@CMAKE_PROJECT_NAME@"
-$ProductVersion = "@CMAKE_PROJECT_VERSION@"

+ 0 - 139
CI/include/build_support_windows.ps1

@@ -1,139 +0,0 @@
-$CIWorkflow = "${CheckoutDir}/.github/workflows/main.yml"
-
-$CIDepsVersion = Get-Content ${CIWorkflow} | Select-String "[ ]+DEPS_VERSION_WIN: '([0-9\-]+)'" | ForEach-Object{$_.Matches.Groups[1].Value}
-$CIQtVersion = Get-Content ${CIWorkflow} | Select-String "[ ]+QT_VERSION_WIN: '([0-9\.]+)'" | ForEach-Object{$_.Matches.Groups[1].Value}
-$CIObsVersion = Get-Content ${CIWorkflow} | Select-String "[ ]+OBS_VERSION: '([0-9\.]+)'" | ForEach-Object{$_.Matches.Groups[1].Value}
-
-function Write-Status {
-    param(
-        [parameter(Mandatory=$true)]
-        [string] $output
-    )
-
-    if (!($Quiet.isPresent)) {
-        if (Test-Path env:CI) {
-            Write-Host "[${ProductName}] ${output}"
-        } else {
-            Write-Host -ForegroundColor blue "[${ProductName}] ${output}"
-        }
-    }
-}
-
-function Write-Info {
-    param(
-        [parameter(Mandatory=$true)]
-        [string] $output
-    )
-
-    if (!($Quiet.isPresent)) {
-        if (Test-Path env:CI) {
-            Write-Host " + ${output}"
-        } else {
-            Write-Host -ForegroundColor DarkYellow " + ${output}"
-        }
-    }
-}
-
-function Write-Step {
-    param(
-        [parameter(Mandatory=$true)]
-        [string] $output
-    )
-
-    if (!($Quiet.isPresent)) {
-        if (Test-Path env:CI) {
-            Write-Host " + ${output}"
-        } else {
-            Write-Host -ForegroundColor green " + ${output}"
-        }
-    }
-}
-
-function Write-Error {
-    param(
-        [parameter(Mandatory=$true)]
-        [string] $output
-    )
-
-    if (Test-Path env:CI) {
-        Write-Host " + ${output}"
-    } else {
-        Write-Host -ForegroundColor red " + ${output}"
-    }
-}
-
-function Test-CommandExists {
-    param(
-        [parameter(Mandatory=$true)]
-        [string] $Command
-    )
-
-    $CommandExists = $false
-    $OldActionPref = $ErrorActionPreference
-    $ErrorActionPreference = "stop"
-
-    try {
-        if (Get-Command $Command) {
-            $CommandExists = $true
-        }
-    } Catch {
-        $CommandExists = $false
-    } Finally {
-        $ErrorActionPreference = $OldActionPref
-    }
-
-    return $CommandExists
-}
-
-function Ensure-Directory {
-    param(
-        [parameter(Mandatory=$true)]
-        [string] $Directory
-    )
-
-    if (!(Test-Path $Directory)) {
-        $null = New-Item -ItemType Directory -Force -Path $Directory
-    }
-
-    Set-Location -Path $Directory
-}
-
-$BuildDirectory = "$(if (Test-Path Env:BuildDirectory) { $env:BuildDirectory } else { $BuildDirectory })"
-$BuildConfiguration = "$(if (Test-Path Env:BuildConfiguration) { $env:BuildConfiguration } else { $BuildConfiguration })"
-$BuildArch = "$(if (Test-Path Env:BuildArch) { $env:BuildArch } else { $BuildArch })"
-$OBSBranch = "$(if (Test-Path Env:OBSBranch) { $env:OBSBranch } else { $OBSBranch })"
-$WindowsDepsVersion = "$(if (Test-Path Env:WindowsDepsVersion ) { $env:WindowsDepsVersion } else { $CIDepsVersion })"
-$WindowsQtVersion = "$(if (Test-Path Env:WindowsQtVersion ) { $env:WindowsQtVersion } else { $CIQtVersion }")
-$CmakeSystemVersion = "$(if (Test-Path Env:CMAKE_SYSTEM_VERSION) { $Env:CMAKE_SYSTEM_VERSION } else { "10.0.18363.657" })"
-$OBSVersion = "$(if ( Test-Path Env:OBSVersion ) { $env:ObsVersion } else { $CIObsVersion })"
-
-function Install-Windows-Dependencies {
-    Write-Status "Checking Windows build dependencies"
-
-    $ObsBuildDependencies = @(
-        @("7z", "7zip"),
-        @("cmake", "cmake --install-arguments 'ADD_CMAKE_TO_PATH=System'"),
-        @("iscc", "innosetup")
-    )
-
-    if(!(Test-CommandExists "choco")) {
-        Set-ExecutionPolicy AllSigned
-        Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
-    }
-
-    Foreach($Dependency in $ObsBuildDependencies) {
-        if($Dependency -is [system.array]) {
-            $Command = $Dependency[0]
-            $ChocoName = $Dependency[1]
-        } else {
-            $Command = $Dependency
-            $ChocoName = $Dependency
-        }
-
-        if(!(Test-CommandExists "${Command}")) {
-            Invoke-Expression "choco install -y ${ChocoName}"
-        }
-    }
-
-    $env:Path = [System.Environment]::GetEnvironmentVariable("Path", "Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path", "User")
-}

+ 0 - 158
CI/windows/01_install_dependencies.ps1

@@ -1,158 +0,0 @@
-Param(
-    [Switch]$Help = $(if (Test-Path variable:Help) { $Help }),
-    [Switch]$Quiet = $(if (Test-Path variable:Quiet) { $Quiet }),
-    [Switch]$Verbose = $(if (Test-Path variable:Verbose) { $Verbose }),
-    [Switch]$NoChoco = $(if (Test-Path variable:NoChoco) { $true } else { $false }),
-    [String]$BuildArch = $(if (Test-Path variable:BuildArch) { "${BuildArch}" } else { (Get-CimInstance CIM_OperatingSystem).OSArchitecture }),
-    [String]$ProductName = $(if (Test-Path variable:ProductName) { "${ProductName}" } else { "obs-plugin" })
-)
-
-##############################################################################
-# Windows dependency management function
-##############################################################################
-#
-# This script file can be included in build scripts for Windows or run
-# directly
-#
-##############################################################################
-
-$ErrorActionPreference = "Stop"
-
-Function Install-obs-deps {
-    Param(
-        [Parameter(Mandatory=$true)]
-        [String]$Version
-    )
-
-    Write-Status "Setup for pre-built Windows OBS dependencies v${Version}"
-    Ensure-Directory $DepsBuildDir
-
-    if (!(Test-Path $DepsBuildDir/dependencies${Version})) {
-        Write-Status "Setting up pre-built Windows OBS dependencies v${Version}"
-
-        Write-Step "Download..."
-        $ProgressPreference = $(if ($Quiet.isPresent) { "SilentlyContinue" } else { "Continue" })
-        Invoke-WebRequest -Uri "https://cdn-fastly.obsproject.com/downloads/dependencies${Version}.zip" -UseBasicParsing -OutFile "dependencies${Version}.zip"
-        $ProgressPreference = 'Continue'
-
-        Write-Step "Unpack..."
-
-        Expand-Archive -Path "dependencies${Version}.zip"
-    } else {
-        Write-Step "Found existing pre-built dependencies..."
-
-    }
-}
-
-function Install-qt-deps {
-    Param(
-        [Parameter(Mandatory=$true)]
-        [String]$Version
-    )
-
-    Write-Status "Setup for pre-built dependency Qt v${Version}"
-    Ensure-Directory $DepsBuildDir
-
-    if (!(Test-Path $DepsBuildDir/Qt_${Version})) {
-        Write-Status "Setting up OBS dependency Qt v${Version}"
-
-        Write-Step "Download..."
-        $ProgressPreference = $(if ($Quiet.isPresent) { 'SilentlyContinue' } else { 'Continue' })
-        Invoke-WebRequest -Uri "https://cdn-fastly.obsproject.com/downloads/Qt_${Version}.7z" -UseBasicParsing -OutFile "Qt_${Version}.7z"
-        $ProgressPreference = 'Continue'
-        
-        Write-Step "Unpack..."
-
-        # TODO: Replace with zip and properly package Qt to share directory with other deps
-        & 7z x Qt_${Version}.7z
-        & mv ${Version} "Qt_${Version}"
-    } else {
-        Write-Step "Found existing pre-built Qt..."
-    }
-}
-
-function Install-obs-studio {
-    Param(
-        [parameter(Mandatory=$true)]
-        [string]$Version
-    )
-
-    $CheckoutRef = "$(if (!(Test-Path variable:OBSBranch)) { ${OBSBranch} } else { "tags/${OBSVersion}" })"
-
-    Write-Status "Setup for OBS Studio v${CheckoutRef}"
-    Ensure-Directory ${ObsBuildDir}
-
-    if (!(Test-Path "${ObsBuildDir}/.git")) {
-        & git clone --recursive https://github.com/obsproject/obs-studio "${pwd}"
-        & git fetch origin --tags
-        & git checkout ${CheckoutRef} -b obs-plugin-build
-    } else {
-        $BranchExists = &git show-ref --verify --quiet refs/heads/obs-plugin-build
-
-        if ($BranchExists -Eq $false) {
-            & git checkout ${CheckoutRef} -b obs-plugin-build
-        } else {
-            & git checkout obs-plugin-build
-        }
-    }
-}
-
-function Install-Dependencies {
-    if(!($NoChoco.isPresent)) {
-        Install-Windows-Dependencies
-    }
-
-    $BuildDependencies = @(
-        @('obs-deps', $WindowsDepsVersion),
-        @('qt-deps', $WindowsQtVersion),
-        @('obs-studio', $OBSVersion)
-    )
-
-    Foreach($Dependency in ${BuildDependencies}) {
-        $DependencyName = $Dependency[0]
-        $DependencyVersion = $Dependency[1]
-
-        $FunctionName = "Install-${DependencyName}"
-        & $FunctionName -Version $DependencyVersion
-    }
-
-    Ensure-Directory ${CheckoutDir}
-}
-
-function Install-Dependencies-Standalone {
-    $CheckoutDir = git rev-parse --show-toplevel
-
-    if (Test-Path ${CheckoutDir}/CI/include/build_environment.ps1) {
-        . ${CheckoutDir}/CI/include/build_environment.ps1
-    }
-
-    $DepsBuildDir = "${CheckoutDir}/../obs-build-dependencies"
-    $ObsBuildDir = "${CheckoutDir}/../obs-studio"
-
-    . ${CheckoutDir}/CI/include/build_support_windows.ps1
-
-    Write-Status "Setting up plugin build dependencies"
-    Install-Dependencies
-}
-
-function Print-Usage {
-    $Lines = @(
-        "Usage: ${MyInvocation.MyCommand.Name}",
-        "-Help                    : Print this help",
-        "-Quiet                   : Suppress most build process output",
-        "-Verbose                 : Enable more verbose build process output",
-        "-NoChoco                 : Skip automatic dependency installation via Chocolatey - Default: on"
-        "-BuildArch               : Build architecture to use (32bit or 64bit) - Default: local architecture"
-    )
-
-    $Lines | Write-Host
-}
-
-if(!(Test-Path variable:_RunObsBuildScript)) {
-    if ($Help.isPresent) {
-        Print-Usage
-        exit 0
-    }
-
-    Install-Dependencies-Standalone
-}

+ 0 - 102
CI/windows/02_build_obs_libs.ps1

@@ -1,102 +0,0 @@
-Param(
-    [Switch]$Help = $(if (Test-Path variable:Help) { $Help }),
-    [Switch]$Quiet = $(if (Test-Path variable:Quiet) { $Quiet }),
-    [Switch]$Verbose = $(if (Test-Path variable:Verbose) { $Verbose }),
-    [String]$ProductName = $(if (Test-Path variable:ProductName) { "${ProductName}" } else { "obs-plugin" }),
-    [String]$BuildDirectory = $(if (Test-Path variable:BuildDirectory) { "${BuildDirectory}" } else { "build" }),
-    [String]$BuildArch = $(if (Test-Path variable:BuildArch) { "${BuildArch}" } else { (Get-WmiObject Win32_OperatingSystem).OSArchitecture}),
-    [String]$BuildConfiguration = $(if (Test-Path variable:BuildConfiguration) { "${BuildConfiguration}" } else { "RelWithDebInfo" })
-)
-
-##############################################################################
-# Windows libobs library build function
-##############################################################################
-#
-# This script file can be included in build scripts for Windows or run
-# directly
-#
-##############################################################################
-
-$ErrorActionPreference = "Stop"
-
-function Build-OBS-Libs {
-    Param(
-        [String]$BuildDirectory = $(if (Test-Path variable:BuildDirectory) { "${BuildDirectory}" }),
-        [String]$BuildArch = $(if (Test-Path variable:BuildArch) { "${BuildArch}" }),
-        [String]$BuildConfiguration = $(if (Test-Path variable:BuildConfiguration) { "${BuildConfiguration}" })
-    )
-
-    Write-Status "Build libobs and obs-frontend-api"
-
-    Ensure-Directory ${ObsBuildDir}
-
-    if ($BuildArch -eq "64-bit") {
-        $QtDirectory = "${CheckoutDir}/../obs-build-dependencies/Qt_${WindowsQtVersion}/msvc2019_64"
-        $DepsDirectory = "${CheckoutDir}/../obs-build-dependencies/dependencies${WindowsDepsVersion}/win64"
-        $Env:CMAKE_PREFIX_PATH="${QtDirectory};${DepsDirectory}/bin;${DepsDirectory}"
-
-        cmake -S . -B "plugin_${BuildDirectory}64" -G "Visual Studio 16 2019" `
-            -DCMAKE_SYSTEM_VERSION="${CmakeSystemVersion}" `
-            -DCMAKE_GENERATOR_PLATFORM=x64 `
-            -DENABLE_PLUGINS=OFF `
-            -DENABLE_UI=ON `
-            -DENABLE_SCRIPTING=OFF `
-            "$(if (Test-Path Variable:$Quiet) { "-Wno-deprecated -Wno-dev --log-level=ERROR" })"
-
-        cmake --build "plugin_${BuildDirectory}64" -t obs-frontend-api --config ${BuildConfiguration}
-    } else {
-        $QtDirectory = "${CheckoutDir}/../obs-build-dependencies/Qt_${WindowsQtVersion}/msvc2019"
-        $DepsDirectory = "${CheckoutDir}/../obs-build-dependencies/dependencies${WindowsDepsVersion}/win32"
-        $Env:CMAKE_PREFIX_PATH="${QtDirectory};${DepsDirectory}/bin;${DepsDirectory}"
-
-        cmake -S . -B "plugin_${BuildDirectory}32" -G "Visual Studio 16 2019" `
-            -DCMAKE_SYSTEM_VERSION="${CmakeSystemVersion}" `
-            -DCMAKE_GENERATOR_PLATFORM=Win32 `
-            -DENABLE_PLUGINS=OFF `
-            -DENABLE_UI=ON `
-            -DENABLE_SCRIPTING=OFF `
-            "$(if (Test-Path Variable:$Quiet) { "-Wno-deprecated -Wno-dev --log-level=ERROR" })"
-
-        cmake --build "plugin_${BuildDirectory}32" -t obs-frontend-api --config ${BuildConfiguration}
-    }
-
-    Ensure-Directory ${CheckoutDir}
-}
-
-
-function Build-OBS-Libs-Standalone {
-    $CheckoutDir = git rev-parse --show-toplevel
-
-    if (Test-Path ${CheckoutDir}/CI/include/build_environment.ps1) {
-        . ${CheckoutDir}/CI/include/build_environment.ps1
-    }
-
-    $ObsBuildDir = "${CheckoutDir}/../obs-studio"
-
-    . ${CheckoutDir}/CI/include/build_support_windows.ps1
-
-    Build-OBS-Libs
-}
-
-function Print-Usage {
-    $Lines = @(
-        "Usage: ${MyInvocation.MyCommand.Name}",
-        "-Help                    : Print this help",
-        "-Quiet                   : Suppress most build process output",
-        "-Verbose                 : Enable more verbose build process output",
-        "-BuildDirectory          : Directory to use for builds - Default: build64 on 64-bit systems, build32 on 32-bit systems",
-        "-BuildArch               : Build architecture to use (32bit or 64bit) - Default: local architecture",
-        "-BuildConfiguration      : Build configuration to use - Default: RelWithDebInfo"
-    )
-
-    $Lines | Write-Host
-}
-
-if(!(Test-Path variable:_RunObsBuildScript)) {
-    if($Help.isPresent) {
-        Print-Usage
-        exit 0
-    }
-
-    Build-OBS-Libs-Standalone
-}

+ 0 - 92
CI/windows/03_build_plugin.ps1

@@ -1,92 +0,0 @@
-Param(
-    [Switch]$Help = $(if (Test-Path variable:Help) { $Help }),
-    [Switch]$Quiet = $(if (Test-Path variable:Quiet) { $Quiet }),
-    [Switch]$Verbose = $(if (Test-Path variable:Verbose) { $Verbose }),
-    [String]$ProductName = $(if (Test-Path variable:ProductName) { "${ProductName}" } else { "obs-plugin" }),
-    [String]$BuildDirectory = $(if (Test-Path variable:BuildDirectory) { "${BuildDirectory}" } else { "build" }),
-    [String]$BuildArch = $(if (Test-Path variable:BuildArch) { "${BuildArch}" } else { (Get-WmiObject Win32_OperatingSystem).OSArchitecture}),
-    [String]$BuildConfiguration = $(if (Test-Path variable:BuildConfiguration) { "${BuildConfiguration}" } else { "RelWithDebInfo" })
-)
-
-##############################################################################
-# Windows libobs plugin build function
-##############################################################################
-#
-# This script file can be included in build scripts for Windows or run
-# directly
-#
-##############################################################################
-
-$ErrorActionPreference = "Stop"
-
-function Build-OBS-Plugin {
-    Param(
-        [String]$BuildDirectory = $(if (Test-Path variable:BuildDirectory) { "${BuildDirectory}" }),
-        [String]$BuildArch = $(if (Test-Path variable:BuildArch) { "${BuildArch}" }),
-        [String]$BuildConfiguration = $(if (Test-Path variable:BuildConfiguration) { "${BuildConfiguration}" })
-    )
-
-    Write-Status "Build plugin ${ProductName}"
-    Ensure-Directory ${CheckoutDir}
-
-    if ($BuildArch -eq "64-bit") {
-        $QtFolder = "${CheckoutDir}/../obs-build-dependencies/Qt_${WindowsQtVersion}/msvc2019_64"
-        $DepsFolder = "${CheckoutDir}/../obs-build-dependencies/dependencies${WindowsDepsVersion}/win64"
-        $Env:CMAKE_PREFIX_PATH="${QtFolder};${DepsFolder}/bin;${DepsFolder}"
-
-        cmake -S . -B "${BuildDirectory}64" -G "Visual Studio 16 2019" `
-            -DCMAKE_GENERATOR_PLATFORM=x64 `
-            -DCMAKE_SYSTEM_VERSION="${CmakeSystemVersion}" `
-            "$(if (Test-Path Variable:$Quiet) { "-Wno-deprecated -Wno-dev --log-level=ERROR" })"
-
-        cmake --build "${BuildDirectory}64" --config ${BuildConfiguration}
-    } else {
-        $QtFolder = "${CheckoutDir}/../obs-build-dependencies/Qt_${WindowsQtVersion}/msvc2019"
-        $DepsFolder = "${CheckoutDir}/../obs-build-dependencies/dependencies${WindowsDepsVersion}/win32"
-        $Env:CMAKE_PREFIX_PATH="${QtFolder};${DepsFolder}/bin;${DepsFolder}"
-
-        cmake -S . -B "${BuildDirectory}32" -G "Visual Studio 16 2019" `
-            -DCMAKE_GENERATOR_PLATFORM=Win32 `
-            -DCMAKE_SYSTEM_VERSION="${CmakeSystemVersion}" `
-            "$(if (Test-Path Variable:$Quiet) { "-Wno-deprecated -Wno-dev --log-level=ERROR" })"
-
-        cmake --build "${BuildDirectory}32" --config ${BuildConfiguration}
-    }
-
-    Ensure-Directory ${CheckoutDir}
-}
-
-function Build-Plugin-Standalone {
-    $CheckoutDir = git rev-parse --show-toplevel
-
-    if (Test-Path ${CheckoutDir}/CI/include/build_environment.ps1) {
-        . ${CheckoutDir}/CI/include/build_environment.ps1
-    }
-
-    . ${CheckoutDir}/CI/include/build_support_windows.ps1
-
-    Build-OBS-Plugin
-}
-
-function Print-Usage {
-    $Lines = @(
-        "Usage: ${MyInvocation.MyCommand.Name}",
-        "-Help                    : Print this help",
-        "-Quiet                   : Suppress most build process output",
-        "-Verbose                 : Enable more verbose build process output",
-        "-BuildDirectory          : Directory to use for builds - Default: build64 on 64-bit systems, build32 on 32-bit systems",
-        "-BuildArch               : Build architecture to use (32bit or 64bit) - Default: local architecture",
-        "-BuildConfiguration      : Build configuration to use - Default: RelWithDebInfo"
-    )
-
-    $Lines | Write-Host
-}
-
-if(!(Test-Path variable:_RunObsBuildScript)) {
-    if($Help.isPresent) {
-        Print-Usage
-        exit 0
-    }
-
-    Build-Plugin-Standalone
- }

+ 0 - 141
CI/windows/04_package_plugin.ps1

@@ -1,141 +0,0 @@
-Param(
-    [Switch]$Help = $(if (Test-Path variable:Help) { $Help }),
-    [Switch]$Quiet = $(if (Test-Path variable:Quiet) { $Quiet }),
-    [Switch]$Verbose = $(if (Test-Path variable:Verbose) { $Verbose }),
-    [Switch]$BuildInstaller = $(if ($BuildInstaller.isPresent) { $true }),
-    [String]$ProductName = $(if (Test-Path variable:ProductName) { "${ProductName}" } else { "obs-plugin" }),
-    [Switch]$CombinedArchs = $(if ($CombinedArchs.isPresent) { $true }),
-    [String]$BuildDirectory = $(if (Test-Path variable:BuildDirectory) { "${BuildDirectory}" } else { "build" }),
-    [String]$BuildArch = $(if (Test-Path variable:BuildArch) { "${BuildArch}" } else { (Get-WmiObject Win32_OperatingSystem).OSArchitecture}),
-    [String]$BuildConfiguration = $(if (Test-Path variable:BuildConfiguration) { "${BuildConfiguration}" } else { "RelWithDebInfo" })
-)
-
-##############################################################################
-# Windows libobs plugin package function
-##############################################################################
-#
-# This script file can be included in build scripts for Windows or run
-# directly with the -Standalone switch
-#
-##############################################################################
-
-$ErrorActionPreference = "Stop"
-
-function Package-OBS-Plugin {
-    Param(
-        [String]$BuildDirectory = $(if (Test-Path variable:BuildDirectory) { "${BuildDirectory}" }),
-        [String]$BuildArch = $(if (Test-Path variable:BuildArch) { "${BuildArch}" }),
-        [String]$BuildConfiguration = $(if (Test-Path variable:BuildConfiguration) { "${BuildConfiguration}" })
-    )
-
-    Write-Status "Package plugin ${ProductName}"
-    Ensure-Directory ${CheckoutDir}
-
-    if ($CombinedArchs.isPresent) {
-        if (!(Test-Path ${CheckoutDir}/release/obs-plugins/64bit)) {
-            cmake --build ${BuildDirectory}64 --config ${BuildConfiguration} -t install
-        }
-
-        if (!(Test-Path ${CheckoutDir}/release/obs-plugins/32bit)) {
-            cmake --build ${BuildDirectory}32 --config ${BuildConfiguration} -t install
-        }
-
-        $CompressVars = @{
-            Path = "${CheckoutDir}/release/*"
-            CompressionLevel = "Optimal"
-            DestinationPath = "${FileName}-Windows.zip"
-        }
-
-        Write-Step "Creating zip archive..."
-
-        Compress-Archive -Force @CompressVars
-        if(($BuildInstaller.isPresent) -And (Test-CommandExists "iscc")) {
-            Write-Step "Creating installer..."
-            & iscc ${CheckoutDir}/installer/installer-Windows.generated.iss /O. /F"${FileName}-Windows-Installer"
-        }
-    } elseif ($BuildArch -eq "64-bit") {
-        cmake --build ${BuildDirectory}64 --config ${BuildConfiguration} -t install
-
-        $CompressVars = @{
-            Path = "${CheckoutDir}/release/*"
-            CompressionLevel = "Optimal"
-            DestinationPath = "${FileName}-Win64.zip"
-        }
-
-        Write-Step "Creating zip archive..."
-
-        Compress-Archive -Force @CompressVars
-
-        if(($BuildInstaller.isPresent) -And (Test-CommandExists "iscc")) {
-            Write-Step "Creating installer..."
-            & iscc ${CheckoutDir}/installer/installer-Windows.generated.iss /O. /F"${FileName}-Win64-Installer"
-        }
-    } elseif ($BuildArch -eq "32-bit") {
-        cmake --build ${BuildDirectory}32 --config ${BuildConfiguration} -t install
-
-        $CompressVars = @{
-            Path = "${CheckoutDir}/release/*"
-            CompressionLevel = "Optimal"
-            DestinationPath = "${FileName}-Win32.zip"
-        }
-
-        Write-Step "Creating zip archive..."
-
-        Compress-Archive -Force @CompressVars
-
-        if(($BuildInstaller.isPresent) -And (Test-CommandExists "iscc")) {
-            Write-Step "Creating installer..."
-            & iscc ${CheckoutDir}/installer/installer-Windows.generated.iss /O. /F"${FileName}-Win32-Installer"
-        }
-    }
-}
-
-function Package-Plugin-Standalone {
-    $CheckoutDir = git rev-parse --show-toplevel
-
-    if (Test-Path ${CheckoutDir}/CI/include/build_environment.ps1) {
-        . ${CheckoutDir}/CI/include/build_environment.ps1
-    }
-
-    . ${CheckoutDir}/CI/include/build_support_windows.ps1
-
-    Ensure-Directory ${CheckoutDir}
-    $GitBranch = git rev-parse --abbrev-ref HEAD
-    $GitHash = git rev-parse --short HEAD
-    $ErrorActionPreference = "SilentlyContiue"
-    $GitTag = git describe --tags --abbrev=0
-    $ErrorActionPreference = "Stop"
-
-    if ($GitTag -eq $null) {
-        $GitTag=$ProductVersion
-    }
-
-    $FileName = "${ProductName}-${GitTag}-${GitHash}"
-
-    Package-OBS-Plugin
-}
-
-function Print-Usage {
-    $Lines = @(
-        "Usage: ${MyInvocation.MyCommand.Name}",
-        "-Help                    : Print this help",
-        "-Quiet                   : Suppress most build process output",
-        "-Verbose                 : Enable more verbose build process output",
-        "-CombinedArchs           : Create combined architecture package",
-        "-BuildDirectory          : Directory to use for builds - Default: build64 on 64-bit systems, build32 on 32-bit systems",
-        "-BuildArch               : Build architecture to use (32bit or 64bit) - Default: local architecture",
-        "-BuildConfiguration      : Build configuration to use - Default: RelWithDebInfo"
-    )
-
-    $Lines | Write-Host
-}
-
-
-if(!(Test-Path variable:_RunObsBuildScript)) {
-    if($Help.isPresent) {
-        Print-Usage
-        exit 0
-    }
-
-    Package-Plugin-Standalone
-}