mirror of
https://github.com/obsproject/obs-studio.git
synced 2024-09-20 04:42:18 +02:00
CI: Add Invoke-External functions for Powershell
Forward-port from obs-plugintemplate to restore cmake output during the configuration step.
This commit is contained in:
parent
23fcc02747
commit
48091adc04
@ -101,6 +101,43 @@ function Ensure-Directory {
|
||||
Set-Location -Path $Directory
|
||||
}
|
||||
|
||||
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.'
|
||||
}
|
||||
|
||||
$Command = $args[0]
|
||||
$CommandArgs = @()
|
||||
|
||||
if ( $args.Count -gt 1) {
|
||||
$CommandArgs = $args[1..($args.Count - 1)]
|
||||
}
|
||||
|
||||
$_EAP = $ErrorActionPreference
|
||||
$ErrorActionPreference = "Continue"
|
||||
|
||||
Write-Debug "Invoke-External: ${Command} ${CommandArgs}"
|
||||
|
||||
& $command $commandArgs
|
||||
$Result = $LASTEXITCODE
|
||||
|
||||
$ErrorActionPreference = $_EAP
|
||||
|
||||
if ( $Result -ne 0 ) {
|
||||
throw "${Command} ${CommandArgs} exited with non-zero code ${Result}."
|
||||
}
|
||||
}
|
||||
|
||||
$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 })"
|
||||
|
@ -43,7 +43,7 @@ function Build-OBS {
|
||||
|
||||
$BuildDirectoryActual = "${BuildDirectory}$(if (${BuildArch} -eq "x64") { "64" } else { "32" })"
|
||||
|
||||
Invoke-Expression "cmake --build ${BuildDirectoryActual} --config ${BuildConfiguration}"
|
||||
Invoke-External cmake --build "${BuildDirectoryActual}" --config ${BuildConfiguration}
|
||||
}
|
||||
|
||||
function Configure-OBS {
|
||||
@ -64,8 +64,7 @@ function Configure-OBS {
|
||||
$GeneratorPlatform = "$(if (${BuildArch} -eq "x64") { "x64" } else { "Win32" })"
|
||||
|
||||
$CmakeCommand = @(
|
||||
"-S . -B `"${BuildDirectoryActual}`"",
|
||||
"-G `"${CmakeGenerator}`"",
|
||||
"-G", ${CmakeGenerator}
|
||||
"-DCMAKE_GENERATOR_PLATFORM=`"${GeneratorPlatform}`"",
|
||||
"-DCMAKE_SYSTEM_VERSION=`"${CmakeSystemVersion}`"",
|
||||
"-DCMAKE_PREFIX_PATH:PATH=`"${CmakePrefixPath}`"",
|
||||
@ -90,7 +89,7 @@ function Configure-OBS {
|
||||
"$(if (Test-Path Variable:$Quiet) { "-Wno-deprecated -Wno-dev --log-level=ERROR" })"
|
||||
)
|
||||
|
||||
Invoke-Expression "cmake ${CmakeCommand}"
|
||||
Invoke-External cmake -S . -B "${BuildDirectoryActual}" @CmakeCommand
|
||||
|
||||
Ensure-Directory ${CheckoutDir}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user