Setup-Obs.ps1 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. function Setup-Obs {
  2. if ( ! ( Test-Path function:Log-Output ) ) {
  3. . $PSScriptRoot/Logger.ps1
  4. }
  5. if ( ! ( Test-Path function:Check-Git ) ) {
  6. . $PSScriptRoot/Check-Git.ps1
  7. }
  8. Check-Git
  9. if ( ! ( Test-Path function:Ensure-Location ) ) {
  10. . $PSScriptRoot/Ensure-Location.ps1
  11. }
  12. if ( ! ( Test-Path function:Invoke-GitCheckout ) ) {
  13. . $PSScriptRoot/Invoke-GitCheckout.ps1
  14. }
  15. if ( ! ( Test-Path function:Invoke-External ) ) {
  16. . $PSScriptRoot/Invoke-External.ps1
  17. }
  18. Log-Information 'Setting up OBS Studio...'
  19. $ObsVersion = $BuildSpec.dependencies.'obs-studio'.version
  20. $ObsRepository = $BuildSpec.dependencies.'obs-studio'.repository
  21. $ObsBranch = $BuildSpec.dependencies.'obs-studio'.branch
  22. $ObsHash = $BuildSpec.dependencies.'obs-studio'.hash
  23. if ( $ObsVersion -eq '' ) {
  24. throw 'No obs-studio version found in buildspec.json.'
  25. }
  26. Push-Location -Stack BuildTemp
  27. Ensure-Location -Path "$(Resolve-Path -Path "${ProjectRoot}/../")/obs-studio"
  28. if ( ! ( ( $script:SkipAll ) -or ( $script:SkipUnpack ) ) ) {
  29. Invoke-GitCheckout -Uri $ObsRepository -Commit $ObsHash -Path . -Branch $ObsBranch
  30. }
  31. if ( ! ( ( $script:SkipAll ) -or ( $script:SkipBuild ) ) ) {
  32. Log-Information 'Configuring OBS Studio...'
  33. $NumProcessors = (Get-CimInstance Win32_ComputerSystem).NumberOfLogicalProcessors
  34. if ( $NumProcessors -gt 1 ) {
  35. $env:UseMultiToolTask = $true
  36. $env:EnforceProcessCountAcrossBuilds = $true
  37. }
  38. $DepsPath = "plugin-deps-${script:DepsVersion}-qt${script:QtVersion}-${script:Target}"
  39. $CmakeArgs = @(
  40. '-G', $CmakeGenerator
  41. "-DCMAKE_SYSTEM_VERSION=${script:PlatformSDK}"
  42. "-DCMAKE_GENERATOR_PLATFORM=$(if (${script:Target} -eq "x86") { "Win32" } else { "x64" })"
  43. "-DCMAKE_BUILD_TYPE=${script:Configuration}"
  44. "-DQT_VERSION=${script:QtVersion}"
  45. '-DENABLE_PLUGINS=OFF'
  46. '-DENABLE_UI=OFF'
  47. '-DENABLE_SCRIPTING=OFF'
  48. "-DCMAKE_INSTALL_PREFIX:PATH=$(Resolve-Path -Path "${ProjectRoot}/../obs-build-dependencies/${DepsPath}")"
  49. "-DCMAKE_PREFIX_PATH:PATH=$(Resolve-Path -Path "${ProjectRoot}/../obs-build-dependencies/${DepsPath}")"
  50. )
  51. Log-Debug "Attempting to configure OBS with CMake arguments: $($CmakeArgs | Out-String)"
  52. Log-Information "Configuring OBS..."
  53. Invoke-External cmake -S . -B plugin_build_${script:Target} @CmakeArgs
  54. Log-Information 'Building libobs and obs-frontend-api...'
  55. $CmakeArgs = @(
  56. '--config', "$( if ( $script:Configuration -eq '' ) { 'RelWithDebInfo' } else { $script:Configuration })"
  57. )
  58. if ( $VerbosePreference -eq 'Continue' ) {
  59. $CmakeArgs+=('--verbose')
  60. }
  61. Invoke-External cmake --build plugin_build_${script:Target} @CmakeArgs -t obs-frontend-api
  62. Invoke-External cmake --install plugin_build_${script:Target} @CmakeArgs --component obs_libraries
  63. }
  64. Pop-Location -Stack BuildTemp
  65. }