Skip to content

Commit

Permalink
feat(obs): Migrate building scripts to OBS28
Browse files Browse the repository at this point in the history
* follow obs upgrade
* Update signal signature to feat Qt6.
* Add github actions script.
* Add ci packaging.

Signed-off-by: Yibai Zhang <xm1994@gmail.com>
  • Loading branch information
summershrimp authored Nov 5, 2022
1 parent 602aecb commit adff00b
Show file tree
Hide file tree
Showing 19 changed files with 541 additions and 241 deletions.
80 changes: 80 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
name: 'BUILD'

on:
push:
paths-ignore: ['**.md']
branches:
- master
- 'release/**'
- 'ci-test'
tags: ['*']
pull_request:
paths-ignore: ['**.md']
branches: [master]

env:
CACHE_REVISION: '006'
QT_VERSION_MAC: '6.3.1'
QT_HASH_MAC_X86_64: 'a83f72a11023b03b6cb2dc365f0a66ad9df31163bbb4fe2df32d601856a9fad3'
QT_HASH_MAC_ARM64: '2f30af90c049670a5660656adbb440668aa1b0567f75a5f29e1def9108928403'
QT_HASH_MAC_UNIVERSAL: '252e6684f43ab9c6f262c73af739e2296ce391b998da2c4ee04c254aaa07db18'
QT_VERSION_WIN: '6.3.1'
DEPS_VERSION_MAC: '2022-08-02'
DEPS_HASH_MAC_X86_64: '7637e52305e6fc53014b5aabd583f1a4490b1d97450420e977cae9a336a29525'
DEPS_HASH_MAC_ARM64: '755e0fa69b17a3ae444e1befa9d91d77e3cafe628fbd1c6333686091826595cd'
DEPS_VERSION_WIN: '2022-09-12'
OBS_STUDIO_VERSION: '28.0.1'

jobs:
windows_build:
name: 'Windows Build'
runs-on: [windows-2022]
env:
CMAKE_GENERATOR: 'Visual Studio 17 2022'
CMAKE_SYSTEM_VERSION: '10.0.18363.657'
defaults:
run:
working-directory: 'obs-auto-subtitle'
steps:
- name: 'Checkout'
uses: actions/checkout@v3
with:
submodules: 'recursive'
path: 'obs-auto-subtitle'
fetch-depth: 0

- name: 'Add msbuild to PATH'
uses: microsoft/setup-msbuild@v1.1

- name: 'Restore OBS dependency from cache'
id: obs-dep-cache
uses: actions/cache@v3
env:
CACHE_NAME: 'obs-dep-cache'
with:
path: ${{ github.workspace }}/obs-build-dependencies
key: ${{ runner.os }}-pr-${{ env.CACHE_NAME }}-${{ env.OBS_STUDIO_VERSION }}-${{ env.CACHE_REVISION }}

- name: 'Restore OBS-Studio from cache'
id: obs-cache
uses: actions/cache@v3
env:
CACHE_NAME: 'obs-cache'
with:
path: ${{ github.workspace }}/obs-studio
key: ${{ runner.os }}-pr-${{ env.CACHE_NAME }}-${{ env.OBS_STUDIO_VERSION }}-${{ env.CACHE_REVISION }}

- name: 'Build OBS'
run: CI/build-windows.ps1 -Component "obs" -OBSTag "${{ env.OBS_STUDIO_VERSION }}"

- name: 'Build Plugin'
run: CI/build-windows.ps1 -Component "plugin" -Package

- name: 'Package Plugin'
run: CI/package-windows.cmd

- name: 'Upload Artifact'
uses: actions/upload-artifact@v3
with:
name: 'obs-auto-subtitle-windows'
path: '${{ github.workspace }}/obs-auto-subtitle/package'
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@
.idea
.vs
.vscode
installer/obs-ssp.pkgproj
installer/installer.iss
124 changes: 124 additions & 0 deletions CI/build-windows.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
param (
[string]$Component = "all",
[string]$OBSTag = "28.0.1",
[Switch]$Package
)

$ErrorActionPreference = "Stop"

$_RunObsBuildScript = $true
$ProductName = "OBS-Studio"

$CheckoutDir = Resolve-Path -Path "$PSScriptRoot\.."
$DepsBuildDir = "${CheckoutDir}/../obs-build-dependencies"
$ObsBuildDir = "${CheckoutDir}/../obs-studio"
$PlugBuildDir = "${CheckoutDir}"
$BuildArch = "x64"
$BuildDirectory = "build"
$BuildConfiguration = "RelWithDebInfo"

. ${CheckoutDir}/CI/windows/build_support_windows.ps1
. ${CheckoutDir}/CI/windows/checkout-obs-windows.ps1
. ${CheckoutDir}/CI/windows/build-obs-windows.ps1


Function Configure {
Ensure-Directory "${PlugBuildDir}"
Write-Status "Configuration of OBS Autosub build system..."

$NumProcessors = (Get-CimInstance Win32_ComputerSystem).NumberOfLogicalProcessors

if ( $NumProcessors -gt 1 ) {
$env:UseMultiToolTask = $true
$env:EnforceProcessCountAcrossBuilds = $true
}

# TODO: Clean up archive and directory naming across dependencies
$CmakePrefixPath = Resolve-Path -Path "${CheckoutDir}/../obs-build-dependencies/windows-deps-${WindowsDepsVersion}-${BuildArch}"
$BuildDirectoryActual = "${BuildDirectory}$(if (${BuildArch} -eq "x64") { "64" } else { "32" })"
$GeneratorPlatform = "$(if (${BuildArch} -eq "x64") { "x64" } else { "Win32" })"

$CmakeCommand = @(
"-G", "${CmakeGenerator}"
"-DCMAKE_GENERATOR_PLATFORM=`"${GeneratorPlatform}`"",
"-DCMAKE_SYSTEM_VERSION=`"${CmakeSystemVersion}`"",
"-DCMAKE_PREFIX_PATH:PATH=`"${CmakePrefixPath}`"",
"-Dw32-pthreads_DIR=`"${ObsBuildDir}\${BuildDirectoryActual}\deps\w32-pthreads`"",
"-DLibObs_DIR=`"${ObsBuildDir}\${BuildDirectoryActual}\libobs`"",
"-Dobs-frontend-api_DIR=`"${ObsBuildDir}\${BuildDirectoryActual}\UI\obs-frontend-api`"",
"-DCMAKE_INSTALL_PREFIX=`"${CheckoutDir}/release`""
"$(if (Test-Path Variable:$Quiet) { "-Wno-deprecated -Wno-dev --log-level=ERROR" })"
)
# "-DW32_PTHREADS_LIB=`"${ObsBuildDir}\${BuildDirectoryActual}\w32-pthreads\%build_config%\w32-pthreads.lib`"",
# "-DLIBOBS_INCLUDE_DIR=`"%OBSPath%\libobs`"",
# "-DLIBOBS_LIB=`"%OBSPath%\build64\libobs\%build_config%\obs.lib`""

Invoke-External cmake -S . -B "${BuildDirectoryActual}" @CmakeCommand

Ensure-Directory ${PlugBuildDir}
}


function Build {
Param(
[String]$BuildDirectory = $(if (Test-Path variable:BuildDirectory) { "${BuildDirectory}" }),
[String]$BuildArch = $(if (Test-Path variable:BuildArch) { "${BuildArch}" }),
[String]$BuildConfiguration = $(if (Test-Path variable:BuildConfiguration) { "${BuildConfiguration}" })
)

$NumProcessors = (Get-CimInstance Win32_ComputerSystem).NumberOfLogicalProcessors

if ( $NumProcessors -gt 1 ) {
$env:UseMultiToolTask = $true
$env:EnforceProcessCountAcrossBuilds = $true
}

Write-Status "Build OBS Autosub"

Configure

Ensure-Directory ${CheckoutDir}
Write-Step "Build OBS targets..."

$BuildDirectoryActual = "${BuildDirectory}$(if (${BuildArch} -eq "x64") { "64" } else { "32" })"

Invoke-External cmake --build "${BuildDirectoryActual}" --config ${BuildConfiguration}
}

function Package {
Write-Step "Install Plugin..."
Invoke-Expression "cmake --build `"${BuildDirectory}64`" --config ${BuildConfiguration} -t install"
}

function Build-OBS-Autosub-Main {
$build_obs = $false
$build_plugin = $false
$package_plugin = $false
if ($Component -eq "all") {
$build_obs = $true
$build_plugin = $true
} elseif ($Component -eq "obs") {
$build_obs = $true
} elseif ($Component -eq "plugin") {
$build_plugin = $true
if ($Package.IsPresent) {
$package_plugin = $true
}
} else {
Write-Error "Invalid component: $Component"
}

if($build_obs) {
Checkout-OBS-Repo -Tag $OBSTag
Patch-OBS-QTDeps
Build-OBS
}
if($build_plugin) {
Build
if($package_plugin) {
Package
}
}
}

Build-OBS-Autosub-Main
5 changes: 0 additions & 5 deletions CI/package-windows.cmd
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
copy %QTDIR64%\bin\Qt5Network.dll release\bin\64bit\Qt5Network.dll
copy %QTDIR64%\bin\Qt5WebSockets.dll release\bin\64bit\Qt5WebSockets.dll
copy %QtBaseDir%\Tools\OpenSSL\Win_x64\bin\libcrypto-1_1-x64.dll release\bin\64bit\libcrypto-1_1-x64.dll
copy %QtBaseDir%\Tools\OpenSSL\Win_x64\bin\libssl-1_1-x64.dll release\bin\64bit\libssl-1_1-x64.dll

mkdir package
cd package

Expand Down
14 changes: 14 additions & 0 deletions CI/windows/build-obs-windows.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Function Patch-OBS-QTDeps {

(Get-Content "${ObsBuildDir}/CI/windows/01_install_dependencies.ps1") `
-replace "github.com/obsproject/obs-deps","github.com/summershrimp/obs-deps" |
Out-File "${ObsBuildDir}/CI/windows/01_install_dependencies.ps1"

(Get-Content "${ObsBuildDir}/.github/workflows/main.yml") `
-replace "DEPS_VERSION_WIN: .*","DEPS_VERSION_WIN: '2022-09-12'" |
Out-File "${ObsBuildDir}/.github/workflows/main.yml"
}

Function Build-OBS {
& $ObsBuildDir/CI/build-windows.ps1
}
Loading

0 comments on commit adff00b

Please sign in to comment.