Build-Windows.ps1 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. [CmdletBinding()]
  2. param(
  3. [ValidateSet('x64', 'arm64')]
  4. [string] $Target = 'x64',
  5. [ValidateSet('Debug', 'RelWithDebInfo', 'Release', 'MinSizeRel')]
  6. [string] $Configuration = 'RelWithDebInfo'
  7. )
  8. $ErrorActionPreference = 'Stop'
  9. if ( $DebugPreference -eq 'Continue' ) {
  10. $VerbosePreference = 'Continue'
  11. $InformationPreference = 'Continue'
  12. }
  13. if ( $env:CI -eq $null ) {
  14. throw "Build-Windows.ps1 requires CI environment"
  15. }
  16. if ( ! ( [System.Environment]::Is64BitOperatingSystem ) ) {
  17. throw "obs-studio requires a 64-bit system to build and run."
  18. }
  19. if ( $PSVersionTable.PSVersion -lt '7.2.0' ) {
  20. Write-Warning 'The obs-studio PowerShell build script requires PowerShell Core 7. Install or upgrade your PowerShell version: https://aka.ms/pscore6'
  21. exit 2
  22. }
  23. function Build {
  24. trap {
  25. Pop-Location -Stack BuildTemp -ErrorAction 'SilentlyContinue'
  26. Write-Error $_
  27. Log-Group
  28. exit 2
  29. }
  30. $ScriptHome = $PSScriptRoot
  31. $ProjectRoot = Resolve-Path -Path "$PSScriptRoot/../.."
  32. $BuildSpecFile = "${ProjectRoot}/buildspec.json"
  33. $UtilityFunctions = Get-ChildItem -Path $PSScriptRoot/utils.pwsh/*.ps1 -Recurse
  34. foreach($Utility in $UtilityFunctions) {
  35. Write-Debug "Loading $($Utility.FullName)"
  36. . $Utility.FullName
  37. }
  38. $BuildSpec = Get-Content -Path ${BuildSpecFile} -Raw | ConvertFrom-Json
  39. Install-BuildDependencies -WingetFile "${ScriptHome}/.Wingetfile"
  40. Push-Location -Stack BuildTemp
  41. Ensure-Location $ProjectRoot
  42. $CmakeArgs = @('--preset', "windows-ci-${Target}")
  43. # Required at the very least until OBS Studio updates to Qt 6.8+, pending review of Qt's build options for
  44. # Windows ARM64.
  45. if ( $Target -eq 'arm64' ) {
  46. $QtDependencyVersion = $BuildSpec.dependencies.qt6.version
  47. $CmakeArgs += @("-DQT_HOST_PATH=${ProjectRoot}\.deps\obs-deps-qt6-${QtDependencyVersion}-x64")
  48. }
  49. $CmakeBuildArgs = @('--build')
  50. $CmakeInstallArgs = @()
  51. if ( $DebugPreference -eq 'Continue' ) {
  52. $CmakeArgs += ('--debug-output')
  53. $CmakeBuildArgs += ('--verbose')
  54. $CmakeInstallArgs += ('--verbose')
  55. }
  56. $CmakeBuildArgs += @(
  57. '--preset', "windows-${Target}"
  58. '--config', $Configuration
  59. '--parallel'
  60. '--', '/consoleLoggerParameters:Summary', '/noLogo'
  61. )
  62. $CmakeInstallArgs += @(
  63. '--install', "build_${Target}"
  64. '--prefix', "${ProjectRoot}/build_${Target}/install"
  65. '--config', $Configuration
  66. )
  67. Log-Group "Configuring obs-studio..."
  68. Invoke-External cmake @CmakeArgs
  69. Log-Group "Building obs-studio..."
  70. Invoke-External cmake @CmakeBuildArgs
  71. Log-Group "Installing obs-studio..."
  72. Invoke-External cmake @CmakeInstallArgs
  73. Pop-Location -Stack BuildTemp
  74. Log-Group
  75. }
  76. Build