$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") }