CI: Simplify build scripts for CI-only use

This commit is contained in:
PatTheMav
2023-07-06 04:38:17 +02:00
committed by Ryan Foster
parent 914392fcc0
commit cf8a8cce72
23 changed files with 255 additions and 708 deletions

View File

@@ -3,10 +3,7 @@ param(
[ValidateSet('x64')]
[string] $Target = 'x64',
[ValidateSet('Debug', 'RelWithDebInfo', 'Release', 'MinSizeRel')]
[string] $Configuration = 'RelWithDebInfo',
[switch] $SkipAll,
[switch] $SkipBuild,
[switch] $SkipDeps
[string] $Configuration = 'RelWithDebInfo'
)
$ErrorActionPreference = 'Stop'
@@ -16,6 +13,10 @@ if ( $DebugPreference -eq 'Continue' ) {
$InformationPreference = 'Continue'
}
if ( $env:CI -eq $null ) {
throw "Build-Windows.ps1 requires CI environment"
}
if ( ! ( [System.Environment]::Is64BitOperatingSystem ) ) {
throw "obs-studio requires a 64-bit system to build and run."
}
@@ -46,57 +47,40 @@ function Build {
$BuildSpec = Get-Content -Path ${BuildSpecFile} -Raw | ConvertFrom-Json
if ( ! $SkipDeps ) {
Install-BuildDependencies -WingetFile "${ScriptHome}/.Wingetfile"
}
Install-BuildDependencies -WingetFile "${ScriptHome}/.Wingetfile"
Push-Location -Stack BuildTemp
if ( ! ( ( $SkipAll ) -or ( $SkipBuild ) ) ) {
Ensure-Location $ProjectRoot
Ensure-Location $ProjectRoot
$Preset = "windows-$(if ( $env:CI -ne $null ) { 'ci-' })${Target}"
$CmakeArgs = @(
'--preset', $Preset
)
$CmakeArgs = @('--preset', "windows-ci-${Target}")
$CmakeBuildArgs = @('--build')
$CmakeInstallArgs = @()
$CmakeBuildArgs = @('--build')
$CmakeInstallArgs = @()
if ( ( $env:CI -ne $null ) -and ( $env:CCACHE_CONFIGPATH -ne $null ) ) {
$CmakeArgs += @(
"-DENABLE_CCACHE:BOOL=TRUE"
)
}
if ( $VerbosePreference -eq 'Continue' ) {
$CmakeBuildArgs += ('--verbose')
$CmakeInstallArgs += ('--verbose')
}
if ( $DebugPreference -eq 'Continue' ) {
$CmakeArgs += ('--debug-output')
}
$CmakeBuildArgs += @(
'--preset', "windows-${Target}"
'--config', $Configuration
'--parallel'
'--', '/consoleLoggerParameters:Summary', '/noLogo'
)
$CmakeInstallArgs += @(
'--install', "build_${Target}"
'--prefix', "${ProjectRoot}/build_${Target}/install"
'--config', $Configuration
)
Log-Group "Configuring obs-studio..."
Invoke-External cmake @CmakeArgs
Log-Group "Building obs-studio..."
Invoke-External cmake @CmakeBuildArgs
if ( $DebugPreference -eq 'Continue' ) {
$CmakeArgs += ('--debug-output')
$CmakeBuildArgs += ('--verbose')
$CmakeInstallArgs += ('--verbose')
}
$CmakeBuildArgs += @(
'--preset', "windows-${Target}"
'--config', $Configuration
'--parallel'
'--', '/consoleLoggerParameters:Summary', '/noLogo'
)
$CmakeInstallArgs += @(
'--install', "build_${Target}"
'--prefix', "${ProjectRoot}/build_${Target}/install"
'--config', $Configuration
)
Log-Group "Configuring obs-studio..."
Invoke-External cmake @CmakeArgs
Log-Group "Building obs-studio..."
Invoke-External cmake @CmakeBuildArgs
Log-Group "Installing obs-studio..."
Invoke-External cmake @CmakeInstallArgs