build-windows.ps1 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. Param(
  2. [Switch]$Help,
  3. [Switch]$Quiet,
  4. [Switch]$Verbose,
  5. [Switch]$Package,
  6. [Switch]$SkipDependencyChecks,
  7. [Switch]$BuildInstaller,
  8. [Switch]$CombinedArchs,
  9. [String]$BuildDirectory = "build",
  10. [ValidateSet('x86', 'x64')]
  11. [String]$BuildArch = ('x86', 'x64')[[System.Environment]::Is64BitOperatingSystem],
  12. [ValidateSet("Release", "RelWithDebInfo", "MinSizeRel", "Debug")]
  13. [String]$BuildConfiguration = "RelWithDebInfo"
  14. )
  15. ##############################################################################
  16. # Windows OBS build script
  17. ##############################################################################
  18. #
  19. # This script contains all steps necessary to:
  20. #
  21. # * Build OBS with all required dependencies
  22. # * Create 64-bit and 32-bit variants
  23. #
  24. # Parameters:
  25. # -Help : Print usage help
  26. # -Quiet : Suppress most build process output
  27. # -Verbose : Enable more verbose build process output
  28. # -SkipDependencyChecks : Skip dependency checks
  29. # -BuildDirectory : Directory to use for builds
  30. # Default: build64 on 64-bit systems
  31. # build32 on 32-bit systems
  32. # -BuildArch : Build architecture to use (x86 or x64)
  33. # -BuildConfiguration : Build configuration to use
  34. # Default: RelWithDebInfo
  35. # -CombinedArchs : Create combined packages and installer
  36. # (x86 and x64) - Default: off
  37. # -Package : Prepare folder structure for installer creation
  38. #
  39. # Environment Variables (optional):
  40. # WindowsDepsVersion : Pre-compiled Windows dependencies version
  41. # WindowsQtVersion : Pre-compiled Qt version
  42. #
  43. ##############################################################################
  44. $ErrorActionPreference = "Stop"
  45. $_RunObsBuildScript = $true
  46. $ProductName = "OBS-Studio"
  47. $CheckoutDir = Resolve-Path -Path "$PSScriptRoot\.."
  48. $DepsBuildDir = "${CheckoutDir}/../obs-build-dependencies"
  49. $ObsBuildDir = "${CheckoutDir}/../obs-studio"
  50. . ${CheckoutDir}/CI/include/build_support_windows.ps1
  51. # Handle installation of build system components and build dependencies
  52. . ${CheckoutDir}/CI/windows/01_install_dependencies.ps1
  53. # Handle OBS build configuration
  54. . ${CheckoutDir}/CI/windows/02_build_obs.ps1
  55. # Handle packaging
  56. . ${CheckoutDir}/CI/windows/03_package_obs.ps1
  57. function Build-OBS-Main {
  58. Ensure-Directory ${CheckoutDir}
  59. Write-Step "Fetching version tags..."
  60. $null = git fetch origin --tags
  61. $GitBranch = git rev-parse --abbrev-ref HEAD
  62. $GitHash = git rev-parse --short HEAD
  63. $ErrorActionPreference = "SilentlyContinue"
  64. $GitTag = git describe --tags --abbrev=0
  65. $ErrorActionPreference = "Stop"
  66. if(Test-Path variable:BUILD_FOR_DISTRIBUTION) {
  67. $VersionString = "${GitTag}"
  68. } else {
  69. $VersionString = "${GitTag}-${GitHash}"
  70. }
  71. $FileName = "${ProductName}-${VersionString}"
  72. if($CombinedArchs.isPresent) {
  73. if (!(Test-Path env:obsInstallerTempDir)) {
  74. $Env:obsInstallerTempDir = "${CheckoutDir}/install_temp"
  75. }
  76. if(!($SkipDependencyChecks.isPresent)) {
  77. Install-Dependencies -BuildArch x64
  78. }
  79. Build-OBS -BuildArch x64
  80. if(!($SkipDependencyChecks.isPresent)) {
  81. Install-Dependencies -BuildArch x86
  82. }
  83. Build-OBS -BuildArch x86
  84. } else {
  85. if(!($SkipDependencyChecks.isPresent)) {
  86. Install-Dependencies
  87. }
  88. Build-OBS
  89. }
  90. if($Package.isPresent) {
  91. Package-OBS -CombinedArchs:$CombinedArchs
  92. }
  93. }
  94. ## MAIN SCRIPT FUNCTIONS ##
  95. function Print-Usage {
  96. Write-Host "build-windows.ps1 - Build script for ${ProductName}"
  97. $Lines = @(
  98. "Usage: ${_ScriptName}",
  99. "-Help : Print this help",
  100. "-Quiet : Suppress most build process output"
  101. "-Verbose : Enable more verbose build process output"
  102. "-SkipDependencyChecks : Skip dependency checks - Default: off",
  103. "-BuildDirectory : Directory to use for builds - Default: build64 on 64-bit systems, build32 on 32-bit systems",
  104. "-BuildArch : Build architecture to use (x86 or x64) - Default: local architecture",
  105. "-BuildConfiguration : Build configuration to use - Default: RelWithDebInfo",
  106. "-CombinedArchs : Create combined packages and installer (64-bit and 32-bit) - Default: off"
  107. "-Package : Prepare folder structure for installer creation"
  108. )
  109. $Lines | Write-Host
  110. }
  111. $_ScriptName = "$($MyInvocation.MyCommand.Name)"
  112. if($Help.isPresent) {
  113. Print-Usage
  114. exit 0
  115. }
  116. Build-OBS-Main