Setup-Obs.ps1 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. Invoke-GitCheckout -Uri $ObsRepository -Commit $ObsHash -Path . -Branch $ObsBranch
  29. Log-Information 'Configuring OBS Studio...'
  30. $NumProcessors = (Get-CimInstance Win32_ComputerSystem).NumberOfLogicalProcessors
  31. if ( $NumProcessors -gt 1 ) {
  32. $env:UseMultiToolTask = $true
  33. $env:EnforceProcessCountAcrossBuilds = $true
  34. }
  35. $CmakeArgs = @(
  36. '-G', $script:CmakeGenerator
  37. '-DCMAKE_SYSTEM_VERSION=10.0.18363.657'
  38. "-DCMAKE_GENERATOR_PLATFORM=$(if (${script:Target} -eq "x86") { "Win32" } else { "x64" })"
  39. "-DCMAKE_BUILD_TYPE=${script:Configuration}"
  40. '-DENABLE_PLUGINS=OFF'
  41. '-DENABLE_UI=OFF'
  42. '-DENABLE_SCRIPTING=OFF'
  43. "-DCMAKE_INSTALL_PREFIX=$(Resolve-Path -Path "${ProjectRoot}/../obs-build-dependencies/plugin-deps-${Target}")"
  44. "-DCMAKE_PREFIX_PATH=$(Resolve-Path -Path "${ProjectRoot}/../obs-build-dependencies/plugin-deps-${Target}")"
  45. )
  46. Invoke-External cmake -S . -B plugin_${script:Target} @CmakeArgs
  47. Log-Information 'Building libobs and obs-frontend-api...'
  48. $CmakeArgs = @(
  49. '--config', "$( if ( $script:Configuration -eq '' ) { 'RelWithDebInfo' } else { $script:Configuration })"
  50. )
  51. if ( $VerbosePreference -eq 'Continue' ) {
  52. $CmakeArgs+=('--verbose')
  53. }
  54. Invoke-External cmake --build plugin_${script:Target} @CmakeArgs -t obs-frontend-api
  55. Invoke-External cmake --install plugin_${script:Target} @CmakeArgs --component obs_libraries
  56. Pop-Location -Stack BuildTemp
  57. }