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