123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110 |
- 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
|