Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows ccache support #6

Open
wants to merge 42 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
62945d3
UI: Disable warnings emitted by Qt frameworks
PatTheMav Apr 5, 2023
d58cb47
libobs: Silence clang warnings for empty prototypes without void
PatTheMav Apr 5, 2023
ce3eb82
obs-outputs: Silence clang warning about questionable use of comma
PatTheMav Apr 5, 2023
d6aef68
UI: Wrap unreachable code in comment to fix clang warnings
PatTheMav Apr 5, 2023
7da16af
obs-scripting: Silence clang warnings about unreachable code
PatTheMav Apr 5, 2023
a033823
mac-capture: Fix clang warning about unreachable code
PatTheMav Apr 6, 2023
8d506fc
mac-videotoolbox: Remove unreachable code to fix clang warning
PatTheMav Apr 5, 2023
a80545e
mac-virtualcam: Use explicit access to object members in async block
PatTheMav Apr 5, 2023
379d961
obs-outputs: Fix clang warnings about unreachable code
PatTheMav Apr 5, 2023
3fecee1
obs-outputs: Silence all ftl-sdk warnings
PatTheMav Apr 5, 2023
abddd37
UI: Fix preventing copy elision of a temporary string object
PatTheMav Apr 5, 2023
915be76
cmake: Disable Framework code signing at build time
PatTheMav Apr 5, 2023
26abab3
cmake: Enable suggested default Xcode build settings for macOS builds
PatTheMav Apr 5, 2023
9d09819
obs-websocket: Update submodule to fix macOS build errors
PatTheMav May 9, 2023
9b4fb10
cmake: Update buildspec and presets for macOS
PatTheMav Apr 28, 2023
68bfe5c
cmake: Fix CMake policy scopes and add include guards
PatTheMav Apr 28, 2023
f405303
cmake: Update macOS compiler configuration
PatTheMav Apr 24, 2023
78ae23e
cmake: Remove Info.plist template files for macOS builds
PatTheMav May 27, 2023
c1fb419
cmake: Remove legacy files for macOS builds
PatTheMav Apr 24, 2023
c0bf562
cmake: Update Framework link definition for macOS builds
PatTheMav Apr 24, 2023
f183db4
cmake: Add separate function to set Xcode-based target properties
PatTheMav Apr 24, 2023
b34cdfe
cmake: Add Windows component to CMake build framework 3.0
PatTheMav Apr 24, 2023
3c3d742
libobs: Update search paths for modules and module data
PatTheMav Mar 28, 2023
f054aea
obs-text: Add changes for CMake build framework 3.0
PatTheMav Feb 21, 2023
df23c9b
win-capture: Add changes for CMake build framework 3.0
PatTheMav Mar 28, 2023
4ad3771
win-dshow: Add changes for CMake build framework 3.0
PatTheMav Mar 28, 2023
9ef69fc
libobs-d3d11: Add changes for CMake build framework 3.0
PatTheMav Mar 28, 2023
8b396d1
win-wasapi: Add changes for CMake build framework 3.0
PatTheMav Feb 21, 2023
4b1b579
ipc-util: Add changes for CMake build framework 3.0
PatTheMav Jan 25, 2023
5212606
libobs-winrt: Add changes for CMake build framework 3.0
PatTheMav Mar 28, 2023
fd07082
obs-ffmpeg: Add changes for CMake build framework 3.0
PatTheMav Mar 28, 2023
969c64d
obs-qsv11: Add changes for CMake build framework 3.0
PatTheMav Feb 21, 2023
919c8b8
obs-outputs: Fix compiler settings for MSVC compilation
PatTheMav Mar 28, 2023
7d0a7e1
libobs: Update OS-specific CMake configurations
PatTheMav Apr 10, 2023
650f2e4
UI: Add changes for CMake build framework 3.0
PatTheMav Mar 28, 2023
d93b45b
CI: Add new Windows build scripts
PatTheMav Apr 22, 2023
c0c72a0
CI: Remove legacy Windows build scripts
PatTheMav Apr 22, 2023
81175e3
cmake: Remove unnecessary OBS_CMAKE_VERSION guard in deps directory
PatTheMav Apr 24, 2023
75ee150
cmake: Update main CMakeLists script for Windows update
PatTheMav Apr 24, 2023
ded2193
coreaudio-encoder: Remove unnecessary compile definitions for Windows
PatTheMav Apr 24, 2023
635daa6
CI: Update Windows workflow for updated CMake build system and scripts
PatTheMav Apr 24, 2023
a1358a1
CI: Add Ccache support for GitHub Actions runs only
PatTheMav May 28, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
139 changes: 139 additions & 0 deletions .github/scripts/Build-Windows.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
[CmdletBinding()]
param(
[ValidateSet('x64')]
[string] $Target = 'x64',
[ValidateSet('Debug', 'RelWithDebInfo', 'Release', 'MinSizeRel')]
[string] $Configuration = 'RelWithDebInfo',
[switch] $SkipAll,
[switch] $SkipBuild,
[switch] $SkipDeps
)

$ErrorActionPreference = 'Stop'

if ( $DebugPreference -eq 'Continue' ) {
$VerbosePreference = 'Continue'
$InformationPreference = 'Continue'
}

if ( ! ( [System.Environment]::Is64BitOperatingSystem ) ) {
throw "obs-studio requires a 64bit system to build and run."
}

if ( $PSVersionTable.PSVersion -lt '7.0.0' ) {
Write-Warning 'The obs-deps PowerShell build script requires PowerShell Core 7. Install or upgrade your PowerShell version: https://aka.ms/pscore6'
exit 2
}

function Build {
trap {
Pop-Location -Stack BuildTemp -ErrorAction 'SilentlyContinue'
Write-Error $_
Log-Group
exit 2
}

$ScriptHome = $PSScriptRoot
$ProjectRoot = Resolve-Path -Path "$PSScriptRoot/../.."
$BuildSpecFile = "${ProjectRoot}/buildspec.json"

$UtilityFunctions = Get-ChildItem -Path $PSScriptRoot/utils.pwsh/*.ps1 -Recurse

foreach($Utility in $UtilityFunctions) {
Write-Debug "Loading $($Utility.FullName)"
. $Utility.FullName
}

$BuildSpec = Get-Content -Path ${BuildSpecFile} -Raw | ConvertFrom-Json

if ( ! $SkipDeps ) {
Install-BuildDependencies -WingetFile "${ScriptHome}/.Wingetfile"
}

Push-Location -Stack BuildTemp
if ( ! ( ( $SkipAll ) -or ( $SkipBuild ) ) ) {
Ensure-Location $ProjectRoot

$CMakeArgs = @()
$CmakeBuildArgs = @('--build')
$CmakeInstallArgs = @()

if ( $VerbosePreference -eq 'Continue' ) {
$CmakeBuildArgs += ('--verbose')
$CmakeInstallArgs += ('--verbose')
}

if ( $DebugPreference -eq 'Continue' ) {
$CmakeArgs += ('--debug-output')
}

$Preset = "windows-$(if ( $Env:CI -ne $null ) { 'ci-' })${Target}"

$CmakeArgs = @(
'--preset', $Preset
)

if ( ( $Env:TWITCH_CLIENTID -ne '' ) -and ( $Env:TWITCH_HASH -ne '' ) ) {
$CmakeArgs += @(
"-DTWITCH_CLIENTID:STRING=${Env:TWITCH_CLIENTID}"
"-DTWITCH_HASH:STRING=${Env:TWITCH_HASH}"
)
}

if ( ( $Env:RESTREAM_CLIENTID -ne '' ) -and ( $Env:RESTREAM_HASH -ne '' ) ) {
$CmakeArgs += @(
"-DRESTREAM_CLIENTID:STRING=${Env:RESTREAM_CLIENTID}"
"-DRESTREAM_HASH:STRING=${Env:RESTREAM_HASH}"
)
}

if ( ( $Env:YOUTUBE_CLIENTID -ne '' ) -and ( $Env:YOUTUBE_CLIENTID_HASH -ne '' ) -and
( $Env:YOUTUBE_SECRET -ne '' ) -and ( $Env:YOUTUBE_SECRET_HASH-ne '' ) ) {
$CmakeArgs += @(
"-DYOUTUBE_CLIENTID:STRING=${Env:YOUTUBE_CLIENTID}"
"-DYOUTUBE_CLIENTID_HASH:STRING=${Env:YOUTUBE_CLIENTID_HASH}"
"-DYOUTUBE_SECRET:STRING=${Env:YOUTUBE_SECRET}"
"-DYOUTUBE_SECRET_HASH:STRING=${Env:YOUTUBE_SECRET_HASH}"
)
}

if ( $Env:GPU_PRIORITY -ne '' ) {
$CmakeArgs += @(
"-DGPU_PRIORITY_VAL:STRING=${Env:GPU_PRIORITY}"
)
}

if ( ( $Env:CI -ne $null ) -and ( $Env:CCACHE_CONFIGPATH -ne '' ) ) {
$CmakeArgs += @(
"-DDENABLE_CCACHE:BOOL=TRUE"
)
}

$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

Pop-Location -Stack BuildTemp
Log-Group
}

Build
79 changes: 79 additions & 0 deletions .github/scripts/Package-Windows.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
[CmdletBinding()]
param(
[ValidateSet('x64')]
[string] $Target = 'x64',
[ValidateSet('Debug', 'RelWithDebInfo', 'Release', 'MinSizeRel')]
[string] $Configuration = 'RelWithDebInfo',
[switch] $SkipDeps
)

$ErrorActionPreference = 'Stop'

if ( $DebugPreference -eq 'Continue' ) {
$VerbosePreference = 'Continue'
$InformationPreference = 'Continue'
}

if ( ! ( [System.Environment]::Is64BitOperatingSystem ) ) {
throw "obs-studio requires a 64-bit system to build and run."
}

if ( $PSVersionTable.PSVersion -lt '7.0.0' ) {
Write-Warning 'The obs-studio packaging script requires PowerShell Core 7. Install or upgrade your PowerShell version: https://aka.ms/pscore6'
exit 2
}

function Package {
trap {
Write-Error $_
exit 2
}

$ScriptHome = $PSScriptRoot
$ProjectRoot = Resolve-Path -Path "$PSScriptRoot/../.."
$BuildSpecFile = "${ProjectRoot}/buildspec.json"

$UtilityFunctions = Get-ChildItem -Path $PSScriptRoot/utils.pwsh/*.ps1 -Recurse

foreach( $Utility in $UtilityFunctions ) {
Write-Debug "Loading $($Utility.FullName)"
. $Utility.FullName
}

if ( ! $SkipDeps ) {
Install-BuildDependencies -WingetFile "${ScriptHome}/.Wingetfile"
}

$GitDescription = Invoke-External git describe --tags --long
$Tokens = ($GitDescription -split '-')
$CommitVersion = $Tokens[0..$($Tokens.Count - 3)] -join '-'
$CommitHash = $($Tokens[-1]).SubString(1)
$CommitDistance = $Tokens[-2]

if ( $CommitDistance -gt 0 ) {
$OutputName = "obs-studio-${CommitVersion}-${CommitHash}"
} else {
$OutputName = "obs-studio-${CommitVersion}"
}

$CpackArgs = @(
'-C', "${Configuration}"
)

if ( $VerbosePreference -eq 'Continue' ) {
$CpackArgs+=('--verbose')
}

Log-Group "Packaging obs-studio..."

Push-Location -Stack PackageTemp "build_${Target}"

cpack @CpackArgs

$Package = Get-ChildItem -filter "obs-studio-*-windows-x64.zip" -File
Move-Item -Path $Package -Destination "${OutputName}-windows-x64.zip"

Pop-Location -Stack PackageTemp
}

Package
29 changes: 29 additions & 0 deletions .github/scripts/utils.pwsh/Ensure-Location.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
function Ensure-Location {
<#
.SYNOPSIS
Ensures current location to be set to specified directory.
.DESCRIPTION
If specified directory exists, switch to it. Otherwise create it,
then switch.
.EXAMPLE
Ensure-Location "My-Directory"
Ensure-Location -Path "Path-To-My-Directory"
#>

param(
[Parameter(Mandatory)]
[string] $Path
)

if ( ! ( Test-Path $Path ) ) {
$_Params = @{
ItemType = "Directory"
Path = ${Path}
ErrorAction = "SilentlyContinue"
}

New-Item @_Params | Set-Location
} else {
Set-Location -Path ${Path}
}
}
70 changes: 70 additions & 0 deletions .github/scripts/utils.pwsh/Expand-ArchiveExt.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
function Expand-ArchiveExt {
<#
.SYNOPSIS
Expands archive files.
.DESCRIPTION
Allows extraction of zip, 7z, gz, and xz archives.
Requires tar and 7-zip to be available on the system.
Archives ending with .zip but created using LZMA compression are
expanded using 7-zip as a fallback.
.EXAMPLE
Expand-ArchiveExt -Path <Path-To-Your-Archive>
Expand-ArchiveExt -Path <Path-To-Your-Archive> -DestinationPath <Expansion-Path>
#>

param(
[Parameter(Mandatory)]
[string] $Path,
[string] $DestinationPath = [System.IO.Path]::GetFileNameWithoutExtension($Path),
[switch] $Force
)

switch ( [System.IO.Path]::GetExtension($Path) ) {
.zip {
try {
Expand-Archive -Path $Path -DestinationPath $DestinationPath -Force:$Force
} catch {
if ( Get-Command 7z ) {
Invoke-External 7z x -y $Path "-o${DestinationPath}"
} else {
throw "Fallback utility 7-zip not found. Please install 7-zip first."
}
}
break
}
{ ( $_ -eq ".7z" ) -or ( $_ -eq ".exe" ) } {
if ( Get-Command 7z ) {
Invoke-External 7z x -y $Path "-o${DestinationPath}"
} else {
throw "Extraction utility 7-zip not found. Please install 7-zip first."
}
break
}
.gz {
try {
Invoke-External tar -x -o $DestinationPath -f $Path
} catch {
if ( Get-Command 7z ) {
Invoke-External 7z x -y $Path "-o${DestinationPath}"
} else {
throw "Fallback utility 7-zip not found. Please install 7-zip first."
}
}
break
}
.xz {
try {
Invoke-External tar -x -o $DestinationPath -f $Path
} catch {
if ( Get-Command 7z ) {
Invoke-External 7z x -y $Path "-o${DestinationPath}"
} else {
throw "Fallback utility 7-zip not found. Please install 7-zip first."
}
}
}
default {
throw "Unsupported archive extension provided."
}
}
}
70 changes: 70 additions & 0 deletions .github/scripts/utils.pwsh/Install-BuildDependencies.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
function Install-BuildDependencies {
<#
.SYNOPSIS
Installs required build dependencies.
.DESCRIPTION
Additional packages might be needed for successful builds. This module contains additional
dependencies available for installation via winget and, if possible, adds their locations
to the environment path for future invocation.
.EXAMPLE
Install-BuildDependencies
#>

param(
[string] $WingetFile = "$PSScriptRoot/.Wingetfile"
)

if ( ! ( Test-Path function:Log-Warning ) ) {
. $PSScriptRoot/Logger.ps1
}

$Prefixes = @{
'x64' = ${Env:ProgramFiles}
'x86' = ${Env:ProgramFiles(x86)}
'arm64' = ${Env:ProgramFiles(arm)}
}

$Paths = $Env:Path -split [System.IO.Path]::PathSeparator

$WingetOptions = @('install', '--accept-package-agreements', '--accept-source-agreements')

if ( $script:Quiet ) {
$WingetOptions += '--silent'
}

Log-Group 'Check Windows build requirements'
Get-Content $WingetFile | ForEach-Object {
$_, $Package, $_, $Path, $_, $Binary, $_, $Version = $_ -replace ',','' -split " +(?=(?:[^\']*\'[^\']*\')*[^\']*$)" -replace "'",''

$Prefixes.GetEnumerator() | ForEach-Object {
$Prefix = $_.value
$FullPath = "${Prefix}\${Path}"
if ( ( Test-Path $FullPath ) -and ! ( $Paths -contains $FullPath ) ) {
$Paths = @($FullPath) + $Paths
$Env:Path = $Paths -join [System.IO.Path]::PathSeparator
}
}

Log-Debug "Checking for command ${Binary}"
$Found = Get-Command -ErrorAction SilentlyContinue $Binary

if ( $Found ) {
Log-Status "Found dependency ${Binary} as $($Found.Source)"
} else {
Log-Status "Installing package ${Package} $(if ( $Version -ne $null ) { "Version: ${Version}" } )"

if ( $Version -ne $null ) {
$WingGetOptions += @('--version', ${Version})
}

try {
$Params = $WingetOptions + $Package

winget @Params
} catch {
throw "Error while installing winget package ${Package}: $_"
}
}
}
Log-Group
}
Loading