use new plugin template (#1)

This commit is contained in:
Exeldro 2024-06-13 17:17:25 +02:00
parent e35607bb5c
commit e00f065534
108 changed files with 4362 additions and 3072 deletions

40
.cmake-format.json Normal file
View File

@ -0,0 +1,40 @@
{
"format": {
"line_width": 120,
"tab_size": 2,
"enable_sort": true,
"autosort": true
},
"additional_commands": {
"find_qt": {
"flags": [],
"kwargs": {
"COMPONENTS": "+",
"COMPONENTS_WIN": "+",
"COMPONENTS_MACOS": "+",
"COMPONENTS_LINUX": "+"
}
},
"set_target_properties_obs": {
"pargs": 1,
"flags": [],
"kwargs": {
"PROPERTIES": {
"kwargs": {
"PREFIX": 1,
"OUTPUT_NAME": 1,
"FOLDER": 1,
"VERSION": 1,
"SOVERSION": 1,
"AUTOMOC": 1,
"AUTOUIC": 1,
"AUTORCC": 1,
"AUTOUIC_SEARCH_PATHS": 1,
"BUILD_RPATH": 1,
"INSTALL_RPATH": 1
}
}
}
}
}
}

106
.github/actions/build-plugin/action.yaml vendored Normal file
View File

@ -0,0 +1,106 @@
name: 'Set up and build plugin'
description: 'Builds the plugin for specified architecture and build config'
inputs:
target:
description: 'Target architecture for dependencies'
required: true
config:
description: 'Build configuration'
required: false
default: 'RelWithDebInfo'
codesign:
description: 'Enable codesigning (macOS only)'
required: false
default: 'false'
codesignIdent:
description: 'Developer ID for application codesigning (macOS only)'
required: false
default: '-'
workingDirectory:
description: 'Working directory for packaging'
required: false
default: ${{ github.workspace }}
runs:
using: composite
steps:
- name: Run macOS Build
if: runner.os == 'macOS'
shell: zsh --no-rcs --errexit --pipefail {0}
working-directory: ${{ inputs.workingDirectory }}
env:
CODESIGN_IDENT: ${{ inputs.codesignIdent }}
CODESIGN_TEAM: ${{ inputs.codesignTeam }}
run: |
: Run macOS Build
local -a build_args=(--config ${{ inputs.config }})
if (( ${+RUNNER_DEBUG} )) build_args+=(--debug)
if [[ '${{ inputs.codesign }}' == 'true' ]] build_args+=(--codesign)
.github/scripts/build-macos ${build_args}
- name: Install Dependencies 🛍️
if: runner.os == 'Linux'
shell: bash
run: |
: Install Dependencies 🛍️
echo ::group::Install Dependencies
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
echo "/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin" >> $GITHUB_PATH
brew install --quiet zsh
echo ::endgroup::
- name: Run Ubuntu Build
if: runner.os == 'Linux'
shell: zsh --no-rcs --errexit --pipefail {0}
working-directory: ${{ inputs.workingDirectory }}
run: |
: Run Ubuntu Build
local -a build_args=(
--target linux-${{ inputs.target }}
--config ${{ inputs.config }}
)
if (( ${+RUNNER_DEBUG} )) build_args+=(--debug)
.github/scripts/build-linux ${build_args}
- name: Run Windows Build
if: runner.os == 'Windows'
shell: pwsh
run: |
# Run Windows Build
if ( $Env:RUNNER_DEBUG -ne $null ) {
Set-PSDebug -Trace 1
}
$BuildArgs = @{
Target = '${{ inputs.target }}'
Configuration = '${{ inputs.config }}'
}
.github/scripts/Build-Windows.ps1 @BuildArgs
- name: Create Summary 📊
if: contains(fromJSON('["Linux", "macOS"]'),runner.os)
shell: zsh --no-rcs --errexit --pipefail {0}
env:
CCACHE_CONFIGPATH: ${{ inputs.workingDirectory }}/.ccache.conf
run: |
: Create Summary 📊
local -a ccache_data
if (( ${+RUNNER_DEBUG} )) {
setopt XTRACE
ccache_data=("${(fA)$(ccache -s -vv)}")
} else {
ccache_data=("${(fA)$(ccache -s)}")
}
print '### ${{ runner.os }} Ccache Stats (${{ inputs.target }})' >> $GITHUB_STEP_SUMMARY
print '```' >> $GITHUB_STEP_SUMMARY
for line (${ccache_data}) {
print ${line} >> $GITHUB_STEP_SUMMARY
}
print '```' >> $GITHUB_STEP_SUMMARY

View File

@ -1,77 +0,0 @@
name: 'Setup and build plugin'
description: 'Builds the plugin for specified architecture and build config.'
inputs:
target:
description: 'Build target for dependencies'
required: true
config:
description: 'Build configuration'
required: false
default: 'Release'
codesign:
description: 'Enable codesigning (macOS only)'
required: false
default: 'false'
codesignIdent:
description: 'Developer ID for application codesigning (macOS only)'
required: false
default: '-'
visualStudio:
description: 'Visual Studio version (Windows only)'
required: false
default: 'Visual Studio 16 2019'
workingDirectory:
description: 'Working directory for packaging'
required: false
default: ${{ github.workspace }}
runs:
using: 'composite'
steps:
- name: Run macOS Build
if: ${{ runner.os == 'macOS' }}
shell: zsh {0}
env:
CODESIGN_IDENT: ${{ inputs.codesignIdent }}
run: |
build_args=(
-c ${{ inputs.config }}
-t macos-${{ inputs.target }}
)
if [[ '${{ inputs.codesign }}' == 'true' ]] build_args+=(-s)
if (( ${+CI} && ${+RUNNER_DEBUG} )) build_args+=(--debug)
${{ inputs.workingDirectory }}/.github/scripts/build-macos.zsh ${build_args}
- name: Run Linux Build
if: ${{ runner.os == 'Linux' }}
shell: bash
run: |
build_args=(
-c ${{ inputs.config }}
-t linux-${{ inputs.target }}
)
if [[ -n "${CI}" && -n "${RUNNER_DEBUG}" ]]; then
build_args+=(--debug)
fi
${{ inputs.workingDirectory }}/.github/scripts/build-linux.sh "${build_args[@]}"
- name: Run Windows Build
if: ${{ runner.os == 'Windows' }}
shell: pwsh
run: |
$BuildArgs = @{
Target = '${{ inputs.target }}'
Configuration = '${{ inputs.config }}'
CMakeGenerator = '${{ inputs.visualStudio }}'
}
if ( ( Test-Path env:CI ) -and ( Test-Path env:RUNNER_DEBUG ) ) {
$BuildArgs += @{
Debug = $true
}
}
${{ inputs.workingDirectory }}/.github/scripts/Build-Windows.ps1 @BuildArgs

View File

@ -0,0 +1,117 @@
name: 'Package plugin'
description: 'Packages the plugin for specified architecture and build config.'
inputs:
target:
description: 'Build target for dependencies'
required: true
config:
description: 'Build configuration'
required: false
default: 'RelWithDebInfo'
codesign:
description: 'Enable codesigning (macOS only)'
required: false
default: 'false'
notarize:
description: 'Enable notarization (macOS only)'
required: false
default: 'false'
codesignIdent:
description: 'Developer ID for application codesigning (macOS only)'
required: false
default: '-'
installerIdent:
description: 'Developer ID for installer package codesigning (macOS only)'
required: false
default: ''
codesignTeam:
description: 'Developer team for codesigning (macOS only)'
required: false
default: ''
codesignUser:
description: 'Apple ID username for notarization (macOS only)'
required: false
default: ''
codesignPass:
description: 'Apple ID password for notarization (macOS only)'
required: false
default: ''
package:
description: 'Create Windows or macOS installation package'
required: false
default: 'false'
workingDirectory:
description: 'Working directory for packaging'
required: false
default: ${{ github.workspace }}
runs:
using: composite
steps:
- name: Run macOS Packaging
if: runner.os == 'macOS'
shell: zsh --no-rcs --errexit --pipefail {0}
working-directory: ${{ inputs.workingDirectory }}
env:
CODESIGN_IDENT: ${{ inputs.codesignIdent }}
CODESIGN_IDENT_INSTALLER: ${{ inputs.installerIdent }}
CODESIGN_TEAM: ${{ inputs.codesignTeam }}
CODESIGN_IDENT_USER: ${{ inputs.codesignUser }}
CODESIGN_IDENT_PASS: ${{ inputs.codesignPass }}
run: |
: Run macOS Packaging
local -a package_args=(--config ${{ inputs.config }})
if (( ${+RUNNER_DEBUG} )) package_args+=(--debug)
if [[ '${{ inputs.codesign }}' == 'true' ]] package_args+=(--codesign)
if [[ '${{ inputs.notarize }}' == 'true' ]] package_args+=(--notarize)
if [[ '${{ inputs.package }}' == 'true' ]] package_args+=(--package)
.github/scripts/package-macos ${package_args}
- name: Install Dependencies 🛍️
if: runner.os == 'Linux'
shell: bash
run: |
: Install Dependencies 🛍️
echo ::group::Install Dependencies
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
echo "/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin" >> $GITHUB_PATH
brew install --quiet zsh
echo ::endgroup::
- name: Run Ubuntu Packaging
if: runner.os == 'Linux'
shell: zsh --no-rcs --errexit --pipefail {0}
working-directory: ${{ inputs.workingDirectory }}
run: |
: Run Ubuntu Packaging
package_args=(
--target linux-${{ inputs.target }}
--config ${{ inputs.config }}
)
if (( ${+RUNNER_DEBUG} )) build_args+=(--debug)
if [[ '${{ inputs.package }}' == 'true' ]] package_args+=(--package)
.github/scripts/package-linux ${package_args}
- name: Run Windows Packaging
if: runner.os == 'Windows'
shell: pwsh
run: |
# Run Windows Packaging
if ( $Env:RUNNER_DEBUG -ne $null ) {
Set-PSDebug -Trace 1
}
$PackageArgs = @{
Target = '${{ inputs.target }}'
Configuration = '${{ inputs.config }}'
}
if ( '${{ inputs.package }}' -eq 'true' ) {
$PackageArgs += @{BuildInstaller = $true}
}
.github/scripts/Package-Windows.ps1 @PackageArgs

View File

@ -1,99 +0,0 @@
name: 'Package plugin'
description: 'Packages the plugin for specified architecture and build config.'
inputs:
target:
description: 'Build target for dependencies'
required: true
config:
description: 'Build configuration'
required: false
default: 'Release'
codesign:
description: 'Enable codesigning (macOS only)'
required: false
default: 'false'
notarize:
description: 'Enable notarization (macOS only)'
required: false
default: 'false'
codesignIdent:
description: 'Developer ID for application codesigning (macOS only)'
required: false
default: '-'
installerIdent:
description: 'Developer ID for installer package codesigning (macOS only)'
required: false
default: ''
codesignUser:
description: 'Apple ID username for notarization (macOS only)'
required: false
default: ''
codesignPass:
description: 'Apple ID password for notarization (macOS only)'
required: false
default: ''
createInstaller:
description: 'Create InnoSetup installer (Windows only)'
required: false
default: 'false'
workingDirectory:
description: 'Working directory for packaging'
required: false
default: ${{ github.workspace }}
runs:
using: 'composite'
steps:
- name: Run macOS packaging
if: ${{ runner.os == 'macOS' }}
shell: zsh {0}
env:
CODESIGN_IDENT: ${{ inputs.codesignIdent }}
CODESIGN_IDENT_INSTALLER: ${{ inputs.installerIdent }}
CODESIGN_IDENT_USER: ${{ inputs.codesignUser }}
CODESIGN_IDENT_PASS: ${{ inputs.codesignPass }}
run: |
package_args=(
-c ${{ inputs.config }}
-t macos-${{ inputs.target }}
)
if [[ '${{ inputs.codesign }}' == 'true' ]] package_args+=(-s)
if [[ '${{ inputs.notarize }}' == 'true' ]] package_args+=(-n)
if (( ${+CI} && ${+RUNNER_DEBUG} )) build_args+=(--debug)
${{ inputs.workingDirectory }}/.github/scripts/package-macos.zsh ${package_args}
- name: Run Linux packaging
if: ${{ runner.os == 'Linux' }}
shell: bash
run: |
package_args=(
-c ${{ inputs.config }}
-t linux-${{ inputs.target }}
)
if [[ -n "${CI}" && -n "${RUNNER_DEBUG}" ]]; then
build_args+=(--debug)
fi
${{ inputs.workingDirectory }}/.github/scripts/package-linux.sh "${package_args[@]}"
- name: Run Windows packaging
if: ${{ runner.os == 'Windows' }}
shell: pwsh
run: |
$PackageArgs = @{
Target = '${{ inputs.target }}'
Configuration = '${{ inputs.config }}'
}
if ( '${{ inputs.createInstaller }}' -eq 'true' ) {
$PackageArgs += @{BuildInstaller = $true}
}
if ( ( Test-Path env:CI ) -and ( Test-Path env:RUNNER_DEBUG ) ) {
$BuildArgs += @{
Debug = $true
}
}
${{ inputs.workingDirectory }}/.github/scripts/Package-Windows.ps1 @PackageArgs

View File

@ -0,0 +1,61 @@
name: Run clang-format
description: Runs clang-format and checks for any changes introduced by it
inputs:
failCondition:
description: Controls whether failed checks also fail the workflow run
required: false
default: 'never'
workingDirectory:
description: Working directory for checks
required: false
default: ${{ github.workspace }}
runs:
using: composite
steps:
- name: Check Runner Operating System 🏃‍♂️
if: runner.os == 'Windows'
shell: bash
run: |
: Check Runner Operating System 🏃‍♂️
echo "::notice::run-clang-format action requires a macOS-based or Linux-based runner."
exit 2
- name: Install Dependencies 🛍️
if: runner.os == 'Linux'
shell: bash
run: |
: Install Dependencies 🛍️
echo ::group::Install Dependencies
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
echo "/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin" >> $GITHUB_PATH
echo "/home/linuxbrew/.linuxbrew/opt/clang-format@16/bin" >> $GITHUB_PATH
brew install --quiet zsh
echo ::endgroup::
- name: Run clang-format 🐉
id: result
shell: zsh --no-rcs --errexit --pipefail {0}
working-directory: ${{ inputs.workingDirectory }}
env:
GITHUB_EVENT_FORCED: ${{ github.event.forced }}
GITHUB_REF_BEFORE: ${{ github.event.before }}
run: |
: Run clang-format 🐉
if (( ${+RUNNER_DEBUG} )) setopt XTRACE
local -a changes=($(git diff --name-only HEAD~1 HEAD))
case ${GITHUB_EVENT_NAME} {
pull_request) changes=($(git diff --name-only origin/${GITHUB_BASE_REF} HEAD)) ;;
push) if [[ ${GITHUB_EVENT_FORCED} != true ]] changes=($(git diff --name-only ${GITHUB_REF_BEFORE} HEAD)) ;;
*) ;;
}
if (( ${changes[(I)(*.c|*.h|*.cpp|*.hpp|*.m|*.mm)]} )) {
echo ::group::Install clang-format-16
brew install --quiet obsproject/tools/clang-format@16
echo ::endgroup::
echo ::group::Run clang-format-16
./build-aux/run-clang-format --fail-${{ inputs.failCondition }} --check
echo ::endgroup::
}

View File

@ -0,0 +1,59 @@
name: Run cmake-format
description: Runs cmake-format and checks for any changes introduced by it
inputs:
failCondition:
description: Controls whether failed checks also fail the workflow run
required: false
default: 'never'
workingDirectory:
description: Working directory for checks
required: false
default: ${{ github.workspace }}
runs:
using: composite
steps:
- name: Check Runner Operating System 🏃‍♂️
if: runner.os == 'Windows'
shell: bash
run: |
: Check Runner Operating System 🏃‍♂️
echo "::notice::run-cmake-format action requires a macOS-based or Linux-based runner."
exit 2
- name: Install Dependencies 🛍️
if: runner.os == 'Linux'
shell: bash
run: |
: Install Dependencies 🛍️
echo ::group::Install Dependencies
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
echo "/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin" >> $GITHUB_PATH
brew install --quiet zsh
echo ::endgroup::
- name: Run cmake-format 🎛️
id: result
shell: zsh --no-rcs --errexit --pipefail {0}
working-directory: ${{ github.workspace }}
env:
GITHUB_EVENT_FORCED: ${{ github.event.forced }}
GITHUB_REF_BEFORE: ${{ github.event.before }}
run: |
: Run cmake-format 🎛️
if (( ${+RUNNER_DEBUG} )) setopt XTRACE
local -a changes=($(git diff --name-only HEAD~1 HEAD))
case ${GITHUB_EVENT_NAME} {
pull_request) changes=($(git diff --name-only origin/${GITHUB_BASE_REF} HEAD)) ;;
push) if [[ ${GITHUB_EVENT_FORCED} != true ]] changes=($(git diff --name-only ${GITHUB_REF_BEFORE} HEAD)) ;;
*) ;;
}
if (( ${changes[(I)*.cmake|*CMakeLists.txt]} )) {
echo ::group::Install cmakelang
pip3 install cmakelang
echo ::endgroup::
echo ::group::Run cmake-format
./build-aux/run-cmake-format --fail-${{ inputs.failCondition }} --check
echo ::endgroup::
}

View File

@ -0,0 +1,154 @@
name: Set up macOS codesigning
description: Sets up code signing certificates, provisioning profiles, and notarization information
inputs:
codesignIdentity:
description: Codesigning identity
required: true
installerIdentity:
description: Codesigning identity for package installer
required: false
codesignCertificate:
description: PKCS12 certificate in base64 format
required: true
certificatePassword:
description: Password required to install PKCS12 certificate
required: true
keychainPassword:
description: Password to use for temporary keychain
required: false
notarizationUser:
description: Apple ID to use for notarization
required: false
notarizationPassword:
description: Application password for notarization
provisioningProfile:
description: Provisioning profile in base64 format
required: false
outputs:
haveCodesignIdent:
description: True if necessary codesigning credentials were found
value: ${{ steps.codesign.outputs.haveCodesignIdent }}
haveProvisioningProfile:
description: True if necessary provisioning profile credentials were found
value: ${{ steps.provisioning.outputs.haveProvisioningProfile }}
haveNotarizationUser:
description: True if necessary notarization credentials were found
value: ${{ steps.notarization.outputs.haveNotarizationUser }}
codesignIdent:
description: Codesigning identity
value: ${{ steps.codesign.outputs.codesignIdent }}
installerIdent:
description: Codesigning identity for package installer
value: ${{ steps.codesign.outputs.installerIdent }}
codesignTeam:
description: Codesigning team
value: ${{ steps.codesign.outputs.codesignTeam }}
runs:
using: composite
steps:
- name: Check Runner Operating System 🏃‍♂️
if: runner.os != 'macOS'
shell: bash
run: |
: Check Runner Operating System 🏃‍♂️
echo "setup-macos-codesigning action requires a macOS-based runner."
exit 2
- name: macOS Codesigning ✍️
shell: zsh --no-rcs --errexit --pipefail {0}
id: codesign
env:
MACOS_SIGNING_IDENTITY: ${{ inputs.codesignIdentity }}
MACOS_SIGNING_IDENTITY_INSTALLER: ${{ inputs.installerIdentity}}
MACOS_SIGNING_CERT: ${{ inputs.codesignCertificate }}
MAOCS_SIGNING_CERT_PASSWORD: ${{ inputs.certificatePassword }}
MACOS_KEYCHAIN_PASSWORD: ${{ inputs.keychainPassword }}
run: |
: macOS Codesigning ✍️
if (( ${+RUNNER_DEBUG} )) setopt XTRACE
if [[ ${MACOS_SIGNING_IDENTITY} && ${MACOS_SIGNING_IDENTITY_INSTALLER} && ${MACOS_SIGNING_CERT} ]] {
print 'haveCodesignIdent=true' >> $GITHUB_OUTPUT
local -r certificate_path="${RUNNER_TEMP}/build_certificate.p12"
local -r keychain_path="${RUNNER_TEMP}/app-signing.keychain-db"
print -n "${MACOS_SIGNING_CERT}" | base64 --decode --output="${certificate_path}"
: "${MACOS_KEYCHAIN_PASSWORD:="$(print ${RANDOM} | shasum | head -c 32)"}"
print '::group::Keychain setup'
security create-keychain -p "${MACOS_KEYCHAIN_PASSWORD}" ${keychain_path}
security set-keychain-settings -lut 21600 ${keychain_path}
security unlock-keychain -p "${MACOS_KEYCHAIN_PASSWORD}" ${keychain_path}
security import "${certificate_path}" -P "${MAOCS_SIGNING_CERT_PASSWORD}" -A \
-t cert -f pkcs12 -k ${keychain_path} \
-T /usr/bin/codesign -T /usr/bin/security -T /usr/bin/xcrun
security set-key-partition-list -S 'apple-tool:,apple:' -k "${MACOS_KEYCHAIN_PASSWORD}" \
${keychain_path} &> /dev/null
security list-keychain -d user -s ${keychain_path} 'login-keychain'
print '::endgroup::'
local -r team_id="${${MACOS_SIGNING_IDENTITY##* }//(\(|\))/}"
print "codesignIdent=${MACOS_SIGNING_IDENTITY}" >> $GITHUB_OUTPUT
print "installerIdent=${MACOS_SIGNING_IDENTITY_INSTALLER}" >> $GITHUB_OUTPUT
print "MACOS_KEYCHAIN_PASSWORD=${MACOS_KEYCHAIN_PASSWORD}" >> $GITHUB_ENV
print "codesignTeam=${team_id}" >> $GITHUB_OUTPUT
} else {
print 'haveCodesignIdent=false' >> $GITHUB_OUTPUT
}
- name: Provisioning Profile 👤
shell: zsh --no-rcs --errexit --pipefail {0}
id: provisioning
if: ${{ fromJSON(steps.codesign.outputs.haveCodesignIdent) }}
env:
MACOS_SIGNING_PROVISIONING_PROFILE: ${{ inputs.provisioningProfile }}
run: |
: Provisioning Profile 👤
if (( ${+RUNNER_DEBUG} )) setopt XTRACE
if [[ ${MACOS_SIGNING_PROVISIONING_PROFILE} ]] {
print 'haveProvisioningProfile=true' >> $GITHUB_OUTPUT
local -r profile_path="${RUNNER_TEMP}/build_profile.provisionprofile"
print -n "${MACOS_SIGNING_PROVISIONING_PROFILE}" \
| base64 --decode --output ${profile_path}
print '::group::Provisioning Profile Setup'
mkdir -p ~/Library/MobileDevice/Provisioning\ Profiles
security cms -D -i ${profile_path} -o ${RUNNER_TEMP}/build_profile.plist
local -r uuid="$(plutil -extract UUID raw ${RUNNER_TEMP}/build_profile.plist)"
local -r team_id="$(plutil -extract TeamIdentifier.0 raw -expect string ${RUNNER_TEMP}/build_profile.plist)"
if [[ ${team_id} != '${{ steps.codesign.codesignTeam }}' ]] {
print '::notice::Code Signing team in provisioning profile does not match certificate.'
}
cp ${profile_path} ~/Library/MobileDevice/Provisioning\ Profiles/${uuid}.provisionprofile
print "provisioningProfileUUID=${uuid}" >> $GITHUB_OUTPUT
print '::endgroup::'
} else {
print 'haveProvisioningProfile=false' >> $GITHUB_OUTPUT
}
- name: Notarization 🧑‍💼
shell: zsh --no-rcs --errexit --pipefail {0}
id: notarization
if: ${{ fromJSON(steps.codesign.outputs.haveCodesignIdent) }}
env:
MACOS_NOTARIZATION_USERNAME: ${{ inputs.notarizationUser }}
MACOS_NOTARIZATION_PASSWORD: ${{ inputs.notarizationPassword }}
run: |
: Notarization 🧑‍💼
if (( ${+RUNNER_DEBUG} )) setopt XTRACE
if [[ ${MACOS_NOTARIZATION_USERNAME} && ${MACOS_NOTARIZATION_PASSWORD} ]] {
print 'haveNotarizationUser=true' >> $GITHUB_OUTPUT
} else {
print 'haveNotarizationUser=false' >> $GITHUB_OUTPUT
}

View File

@ -1,9 +1,6 @@
package 'cmake' package 'cmake'
package 'ccache' package 'ccache'
package 'curl'
package 'git' package 'git'
package 'jq' package 'jq'
package 'ninja-build', bin: 'ninja' package 'ninja-build', bin: 'ninja'
package 'pkg-config' package 'pkg-config'
package 'clang'
package 'clang-format-13'

View File

@ -3,4 +3,4 @@ brew "coreutils"
brew "cmake" brew "cmake"
brew "git" brew "git"
brew "jq" brew "jq"
brew "ninja" brew "xcbeautify"

View File

@ -1,3 +1,2 @@
package '7zip.7zip', path: '7-zip', bin: '7z'
package 'cmake', path: 'Cmake\bin', bin: 'cmake' package 'cmake', path: 'Cmake\bin', bin: 'cmake'
package 'innosetup', path: 'Inno Setup 6', bin: 'iscc' package 'innosetup', path: 'Inno Setup 6', bin: 'iscc'

View File

@ -17,55 +17,76 @@ setopt FUNCTION_ARGZERO
# setopt XTRACE # setopt XTRACE
autoload -Uz is-at-least && if ! is-at-least 5.2; then autoload -Uz is-at-least && if ! is-at-least 5.2; then
print -u2 -PR "%F{1}${funcstack[1]##*/}:%f Running on Zsh version %B${ZSH_VERSION}%b, but Zsh %B5.2%b is the minimum supported version. Upgrade Zsh to fix this issue." print -u2 -PR "${CI:+::error::}%F{1}${funcstack[1]##*/}:%f Running on Zsh version %B${ZSH_VERSION}%b, but Zsh %B5.2%b is the minimum supported version. Upgrade Zsh to fix this issue."
exit 1 exit 1
fi fi
_trap_error() { TRAPEXIT() {
print -u2 -PR '%F{1} ✖︎ script execution error%f' local return_value=$?
if (( ${+CI} )) unset NSUnbufferedIO
return ${return_value}
}
TRAPZERR() {
if (( ${_loglevel:-3} > 2 )) {
print -u2 -PR "${CI:+::error::}%F{1} ✖︎ script execution error%f"
print -PR -e " print -PR -e "
Callstack: Callstack:
${(j:\n :)funcfiletrace} ${(j:\n :)funcfiletrace}
" "
}
exit 2 exit 2
} }
build() { build() {
if (( ! ${+SCRIPT_HOME} )) typeset -g SCRIPT_HOME=${ZSH_ARGZERO:A:h} if (( ! ${+SCRIPT_HOME} )) typeset -g SCRIPT_HOME=${ZSH_ARGZERO:A:h}
local host_os=${${(s:-:)ZSH_ARGZERO:t:r}[2]} local host_os=${${(s:-:)ZSH_ARGZERO:t:r}[2]}
local target="${host_os}-${CPUTYPE}"
local project_root=${SCRIPT_HOME:A:h:h} local project_root=${SCRIPT_HOME:A:h:h}
local buildspec_file="${project_root}/buildspec.json" local buildspec_file=${project_root}/buildspec.json
trap '_trap_error' ZERR
fpath=("${SCRIPT_HOME}/utils.zsh" ${fpath}) fpath=("${SCRIPT_HOME}/utils.zsh" ${fpath})
autoload -Uz log_info log_error log_output set_loglevel check_${host_os} setup_${host_os} setup_obs setup_ccache autoload -Uz log_group log_info log_error log_output set_loglevel check_${host_os} setup_ccache
if [[ ! -r ${buildspec_file} ]] { if [[ ! -r ${buildspec_file} ]] {
log_error \ log_error \
'No buildspec.json found. Please create a build specification for your project.' \ 'No buildspec.json found. Please create a build specification for your project.'
'A buildspec.json.template file is provided in the repository to get you started.'
return 2 return 2
} }
typeset -g -a skips=() typeset -g -a skips=()
local -i _verbosity=1 local -i verbosity=1
local -r _version='1.0.0' local -r _version='2.0.0'
local -r -a _valid_targets=( local -r -a _valid_targets=(
macos-x86_64
macos-arm64
macos-universal macos-universal
linux-x86_64 linux-x86_64
linux-aarch64
) )
local target
local config='RelWithDebInfo'
local -r -a _valid_configs=(Debug RelWithDebInfo Release MinSizeRel) local -r -a _valid_configs=(Debug RelWithDebInfo Release MinSizeRel)
if [[ ${host_os} == 'macos' ]] { local -i codesign=0
local -r -a _valid_generators=(Xcode Ninja 'Unix Makefiles')
local generator="${${CI:+Ninja}:-Xcode}" if [[ ${host_os} == linux ]] {
} else {
local -r -a _valid_generators=(Ninja 'Unix Makefiles') local -r -a _valid_generators=(Ninja 'Unix Makefiles')
local generator='Ninja' local generator='Ninja'
local -r _usage_host="
%F{yellow} Additional options for Linux builds%f
-----------------------------------------------------------------------------
%B--generator%b Specify build system to generate
Available generators:
- Ninja
- Unix Makefiles"
} elif [[ ${host_os} == macos ]] {
local -r _usage_host="
%F{yellow} Additional options for macOS builds%f
-----------------------------------------------------------------------------
%B-s | --codesign%b Enable codesigning (macOS only)"
} }
local -i print_config=0
local -r _usage=" local -r _usage="
Usage: %B${functrace[1]%:*}%b <option> [<options>] Usage: %B${functrace[1]%:*}%b <option> [<options>]
@ -73,26 +94,21 @@ Usage: %B${functrace[1]%:*}%b <option> [<options>]
%F{yellow} Build configuration options%f %F{yellow} Build configuration options%f
----------------------------------------------------------------------------- -----------------------------------------------------------------------------
%B-t | --target%b Specify target - default: %B%F{green}${host_os}-${CPUTYPE}%f%b %B-t | --target%b Specify target
%B-c | --config%b Build configuration - default: %B%F{green}RelWithDebInfo%f%b %B-c | --config%b Build configuration
%B-s | --codesign%b Enable codesigning (macOS only) %B--skip-[all|build|deps]%b Skip all|building|checking for dependencies
%B--generator%b Specify build system to generate - default: %B%F{green}Ninja%f%b
Available generators:
- Ninja
- Unix Makefiles
- Xcode (macOS only)
%F{yellow} Output options%f %F{yellow} Output options%f
----------------------------------------------------------------------------- -----------------------------------------------------------------------------
%B-q | --quiet%b Quiet (error output only) %B-q | --quiet%b Quiet (error output only)
%B-v | --verbose%b Verbose (more detailed output) %B-v | --verbose%b Verbose (more detailed output)
%B--skip-[all|build|deps|unpack]%b Skip all|building OBS|checking for dependencies|unpacking dependencies
%B--debug%b Debug (very detailed and added output) %B--debug%b Debug (very detailed and added output)
%F{yellow} General options%f %F{yellow} General options%f
----------------------------------------------------------------------------- -----------------------------------------------------------------------------
%B-h | --help%b Print this usage help %B-h | --help%b Print this usage help
%B-V | --version%b Print script version information" %B-V | --version%b Print script version information
${_usage_host:-}"
local -a args local -a args
while (( # )) { while (( # )) {
@ -126,27 +142,30 @@ Usage: %B${functrace[1]%:*}%b <option> [<options>]
log_output ${_usage} log_output ${_usage}
exit 2 exit 2
} }
BUILD_CONFIG=${2} config=${2}
shift 2 shift 2
;; ;;
-s|--codesign) CODESIGN=1; shift ;; -s|--codesign) codesign=1; shift ;;
-q|--quiet) (( _verbosity -= 1 )) || true; shift ;; -q|--quiet) (( verbosity -= 1 )) || true; shift ;;
-v|--verbose) (( _verbosity += 1 )); shift ;; -v|--verbose) (( verbosity += 1 )); shift ;;
-h|--help) log_output ${_usage}; exit 0 ;; -h|--help) log_output ${_usage}; exit 0 ;;
-V|--version) print -Pr "${_version}"; exit 0 ;; -V|--version) print -Pr "${_version}"; exit 0 ;;
--debug) _verbosity=3; shift ;; --debug) verbosity=3; shift ;;
--generator) --generator)
if [[ ${host_os} == linux ]] {
if (( ! ${_valid_generators[(Ie)${2}]} )) { if (( ! ${_valid_generators[(Ie)${2}]} )) {
log_error "Invalid value %B${2}%b for option %B${1}%b" log_error "Invalid value %B${2}%b for option %B${1}%b"
log_output ${_usage} log_output ${_usage}
exit 2 exit 2
} }
generator=${2} generator=${2}
}
shift 2 shift 2
;; ;;
--print-config) print_config=1; skips+=(deps); shift ;;
--skip-*) --skip-*)
local _skip="${${(s:-:)1}[-1]}" local -r _skip="${${(s:-:)1}[-1]}"
local _check=(all deps unpack build) local -r -a _check=(all build deps)
(( ${_check[(Ie)${_skip}]} )) || log_warning "Invalid skip mode %B${_skip}%b supplied" (( ${_check[(Ie)${_skip}]} )) || log_warning "Invalid skip mode %B${_skip}%b supplied"
typeset -g -a skips=(${skips} ${_skip}) typeset -g -a skips=(${skips} ${_skip})
shift shift
@ -155,92 +174,120 @@ Usage: %B${functrace[1]%:*}%b <option> [<options>]
} }
} }
set -- ${(@)args} : "${target:="${host_os}-${CPUTYPE}"}"
set_loglevel ${_verbosity}
set -- ${(@)args}
set_loglevel ${verbosity}
if (( ! (${skips[(Ie)all]} + ${skips[(Ie)deps]}) )) {
check_${host_os} check_${host_os}
setup_ccache setup_ccache
}
typeset -g QT_VERSION if [[ ${host_os} == linux ]] {
typeset -g DEPLOYMENT_TARGET autoload -Uz setup_linux && setup_linux
typeset -g OBS_DEPS_VERSION }
setup_${host_os}
local product_name local product_name
local product_version local product_version
read -r product_name product_version <<< \ read -r product_name product_version <<< \
"$(jq -r '. | {name, version} | join(" ")' ${buildspec_file})" "$(jq -r '. | {name, version} | join(" ")' ${buildspec_file})"
case ${host_os} {
macos)
sed -i '' \
"s/project(\(.*\) VERSION \(.*\))/project(${product_name} VERSION ${product_version})/" \
"${project_root}/CMakeLists.txt"
;;
linux)
sed -i'' \
"s/project(\(.*\) VERSION \(.*\))/project(${product_name} VERSION ${product_version})/"\
"${project_root}/CMakeLists.txt"
;;
}
setup_obs
pushd ${project_root} pushd ${project_root}
if (( ! (${skips[(Ie)all]} + ${skips[(Ie)build]}) )) { if (( ! (${skips[(Ie)all]} + ${skips[(Ie)build]}) )) {
log_info "Configuring ${product_name}..." log_group "Configuring ${product_name}..."
local _plugin_deps="${project_root:h}/obs-build-dependencies/plugin-deps-${OBS_DEPS_VERSION}-qt${QT_VERSION}-${target##*-}" local -a cmake_args=()
local -a cmake_args=( local -a cmake_build_args=(--build)
-DCMAKE_BUILD_TYPE=${BUILD_CONFIG:-RelWithDebInfo} local -a cmake_install_args=(--install)
-DQT_VERSION=${QT_VERSION}
-DCMAKE_PREFIX_PATH="${_plugin_deps}"
)
if (( _loglevel == 0 )) cmake_args+=(-Wno_deprecated -Wno-dev --log-level=ERROR) case ${_loglevel} {
if (( _loglevel > 2 )) cmake_args+=(--debug-output) 0) cmake_args+=(-Wno_deprecated -Wno-dev --log-level=ERROR) ;;
1) ;;
local num_procs 2) cmake_build_args+=(--verbose) ;;
*) cmake_args+=(--debug-output) ;;
}
local -r _preset="${target%%-*}${CI:+-ci}"
case ${target} { case ${target} {
macos-*) macos-*)
autoload -Uz read_codesign if (( ${+CI} )) typeset -gx NSUnbufferedIO=YES
if (( ${+CODESIGN} )) {
read_codesign cmake_args+=(
--preset ${_preset}
)
if (( codesign )) {
autoload -Uz read_codesign_team && read_codesign_team
if [[ -z ${CODESIGN_TEAM} ]] {
autoload -Uz read_codesign && read_codesign
}
} }
cmake_args+=( cmake_args+=(
-DCMAKE_FRAMEWORK_PATH="${_plugin_deps}/Frameworks" -DCODESIGN_TEAM=${CODESIGN_TEAM:-}
-DCMAKE_OSX_ARCHITECTURES=${${target##*-}//universal/x86_64;arm64} -DCODESIGN_IDENTITY=${CODESIGN_IDENT:--}
-DCMAKE_OSX_DEPLOYMENT_TARGET=${DEPLOYMENT_TARGET:-10.15}
-DOBS_CODESIGN_LINKER=ON
-DOBS_BUNDLE_CODESIGN_IDENTITY="${CODESIGN_IDENT:--}"
) )
num_procs=$(( $(sysctl -n hw.ncpu) + 1 ))
cmake_build_args+=(--preset ${_preset} --parallel --config ${config} -- ONLY_ACTIVE_ARCH=NO -arch arm64 -arch x86_64)
cmake_install_args+=(build_macos --config ${config} --prefix "${project_root}/release/${config}")
local -a xcbeautify_opts=()
if (( _loglevel == 0 )) xcbeautify_opts+=(--quiet)
;; ;;
linux-*) linux-*)
if (( ${+CI} )) { cmake_args+=(
cmake_args+=(-DCMAKE_INSTALL_PREFIX=/usr) --preset ${_preset}-${target##*-}
-G "${generator}"
-DQT_VERSION=${QT_VERSION:-6}
-DCMAKE_BUILD_TYPE=${config}
-DCMAKE_INSTALL_PREFIX=/usr
)
local cmake_version
read -r _ _ cmake_version <<< "$(cmake --version)"
if [[ ${CPUTYPE} != ${target##*-} ]] {
if is-at-least 3.21.0 ${cmake_version}; then
cmake_args+=(--toolchain "${project_root}/cmake/linux/toolchains/${target##*-}-linux-gcc.cmake")
else
cmake_args+=(-D"CMAKE_TOOLCHAIN_FILE=${project_root}/cmake/linux/toolchains/${target##*-}-linux-gcc.cmake")
fi
} }
num_procs=$(( $(nproc) + 1 ))
cmake_build_args+=(--preset ${_preset}-${target##*-} --config ${config})
if [[ ${generator} == 'Unix Makefiles' ]] {
cmake_build_args+=(--parallel $(( $(nproc) + 1 )))
} else {
cmake_build_args+=(--parallel)
}
cmake_install_args+=(build_${target##*-} --prefix ${project_root}/release/${config})
;; ;;
} }
log_debug "Attempting to configure ${product_name} with CMake arguments: ${cmake_args}" log_debug "Attempting to configure with CMake arguments: ${cmake_args}"
cmake -S . -B build_${target##*-} -G ${generator} ${cmake_args}
log_info "Building ${product_name}..." cmake ${cmake_args}
local -a cmake_args=()
if (( _loglevel > 1 )) cmake_args+=(--verbose) log_group "Building ${product_name}..."
if [[ ${generator} == 'Unix Makefiles' ]] cmake_args+=(--parallel ${num_procs}) if [[ ${host_os} == macos ]] {
cmake --build build_${target##*-} --config ${BUILD_CONFIG:-RelWithDebInfo} ${cmake_args} if (( _loglevel > 1 )) {
cmake ${cmake_build_args}
} else {
cmake ${cmake_build_args} 2>&1 | xcbeautify ${xcbeautify_opts}
}
} else {
cmake ${cmake_build_args}
}
} }
log_info "Installing ${product_name}..." log_group "Installing ${product_name}..."
local -a cmake_args=() if (( _loglevel > 1 )) cmake_install_args+=(--verbose)
if (( _loglevel > 1 )) cmake_args+=(--verbose) cmake ${cmake_install_args}
cmake --install build_${target##*-} --config ${BUILD_CONFIG:-RelWithDebInfo} --prefix "${project_root}/release" ${cmake_args}
popd popd
log_group
} }
build ${@} build ${@}

View File

@ -17,39 +17,70 @@ setopt FUNCTION_ARGZERO
# setopt XTRACE # setopt XTRACE
autoload -Uz is-at-least && if ! is-at-least 5.2; then autoload -Uz is-at-least && if ! is-at-least 5.2; then
print -u2 -PR "%F{1}${funcstack[1]##*/}:%f Running on Zsh version %B${ZSH_VERSION}%b, but Zsh %B5.2%b is the minimum supported version. Upgrade Zsh to fix this issue." print -u2 -PR "${CI:+::error::}%F{1}${funcstack[1]##*/}:%f Running on Zsh version %B${ZSH_VERSION}%b, but Zsh %B5.2%b is the minimum supported version. Upgrade Zsh to fix this issue."
exit 1 exit 1
fi fi
_trap_error() { TRAPEXIT() {
print -u2 -PR '%F{1} ✖︎ script execution error%f' local return_value=$?
if (( ${+CI} )) {
unset NSUnbufferedIO
}
return ${return_value}
}
TRAPZERR() {
if (( ${_loglevel:-3} > 2 )) {
print -u2 -PR "${CI:+::error::}%F{1} ✖︎ script execution error%f"
print -PR -e " print -PR -e "
Callstack: Callstack:
${(j:\n :)funcfiletrace} ${(j:\n :)funcfiletrace}
" "
}
exit 2 exit 2
} }
package() { package() {
if (( ! ${+SCRIPT_HOME} )) typeset -g SCRIPT_HOME=${ZSH_ARGZERO:A:h} if (( ! ${+SCRIPT_HOME} )) typeset -g SCRIPT_HOME=${ZSH_ARGZERO:A:h}
local host_os=${${(s:-:)ZSH_ARGZERO:t:r}[2]} local host_os=${${(s:-:)ZSH_ARGZERO:t:r}[2]}
local target="${host_os}-${CPUTYPE}"
local project_root=${SCRIPT_HOME:A:h:h} local project_root=${SCRIPT_HOME:A:h:h}
local buildspec_file="${project_root}/buildspec.json" local buildspec_file=${project_root}/buildspec.json
trap '_trap_error' ZERR
fpath=("${SCRIPT_HOME}/utils.zsh" ${fpath}) fpath=("${SCRIPT_HOME}/utils.zsh" ${fpath})
autoload -Uz set_loglevel log_info log_error log_output check_${host_os} autoload -Uz set_loglevel log_info log_group log_error log_output check_${host_os}
local -i _verbosity=1 if [[ ! -r ${buildspec_file} ]] {
local -r _version='1.0.0' log_error \
'No buildspec.json found. Please create a build specification for your project.'
return 2
}
local -i verbosity=1
local -r _version='2.0.0'
local -r -a _valid_targets=( local -r -a _valid_targets=(
macos-x86_64
macos-arm64
macos-universal macos-universal
linux-x86_64 linux-x86_64
) )
local target
local config='RelWithDebInfo'
local -r -a _valid_configs=(Debug RelWithDebInfo Release MinSizeRel) local -r -a _valid_configs=(Debug RelWithDebInfo Release MinSizeRel)
local -i codesign=0
local -i notarize=0
local -i package=0
local -i skip_deps=0
if [[ ${host_os} == macos ]] {
local -r _usage_host="
%F{yellow} Additional options for macOS builds%f
-----------------------------------------------------------------------------
%B-s | --codesign%b Enable codesigning (macOS only)
%B-n | --notarize%b Enable notarization (macOS only)
%B-p | --package%b Create package installer (macOS only)"
}
local -r _usage=" local -r _usage="
Usage: %B${functrace[1]%:*}%b <option> [<options>] Usage: %B${functrace[1]%:*}%b <option> [<options>]
@ -57,10 +88,9 @@ Usage: %B${functrace[1]%:*}%b <option> [<options>]
%F{yellow} Package configuration options%f %F{yellow} Package configuration options%f
----------------------------------------------------------------------------- -----------------------------------------------------------------------------
%B-t | --target%b Specify target - default: %B%F{green}${host_os}-${CPUTYPE}%f%b %B-t | --target%b Specify target
%B-c | --config%b Build configuration - default: %B%F{green}RelWithDebInfo%f%b %B-c | --config%b Build configuration
%B-s | --codesign%b Enable codesigning (macOS only) %B--skip-deps%b Skip checking for dependencies
%B-n | --notarize%b Enable notarization (macOS only)
%F{yellow} Output options%f %F{yellow} Output options%f
----------------------------------------------------------------------------- -----------------------------------------------------------------------------
@ -71,7 +101,8 @@ Usage: %B${functrace[1]%:*}%b <option> [<options>]
%F{yellow} General options%f %F{yellow} General options%f
----------------------------------------------------------------------------- -----------------------------------------------------------------------------
%B-h | --help%b Print this usage help %B-h | --help%b Print this usage help
%B-V | --version%b Print script version information" %B-V | --version%b Print script version information
${_usage_host:-}"
local -a args local -a args
while (( # )) { while (( # )) {
@ -105,68 +136,73 @@ Usage: %B${functrace[1]%:*}%b <option> [<options>]
log_output ${_usage} log_output ${_usage}
exit 2 exit 2
} }
BUILD_CONFIG=${2} config=${2}
shift 2 shift 2
;; ;;
-s|--codesign) typeset -g CODESIGN=1; shift ;; -s|--codesign) typeset -g codesign=1; shift ;;
-n|--notarize) typeset -g NOTARIZE=1; typeset -g CODESIGN=1; shift ;; -n|--notarize) typeset -g notarize=1; typeset -g codesign=1; shift ;;
-q|--quiet) (( _verbosity -= 1 )) || true; shift ;; -p|--package) typeset -g package=1; shift ;;
-v|--verbose) (( _verbosity += 1 )); shift ;; --skip-deps) typeset -g skip_deps=1; shift ;;
-q|--quiet) (( verbosity -= 1 )) || true; shift ;;
-v|--verbose) (( verbosity += 1 )); shift ;;
-h|--help) log_output ${_usage}; exit 0 ;; -h|--help) log_output ${_usage}; exit 0 ;;
-V|--version) print -Pr "${_version}"; exit 0 ;; -V|--version) print -Pr "${_version}"; exit 0 ;;
--debug) _verbosity=3; shift ;; --debug) verbosity=3; shift ;;
*) log_error "Unknown option: %B${1}%b"; log_output ${_usage}; exit 2 ;; *) log_error "Unknown option: %B${1}%b"; log_output ${_usage}; exit 2 ;;
} }
} }
set -- ${(@)args} : "${target:="${host_os}-${CPUTYPE}"}"
set_loglevel ${_verbosity}
set -- ${(@)args}
set_loglevel ${verbosity}
if (( ! skip_deps )) {
check_${host_os} check_${host_os}
}
local product_name local product_name
local product_version local product_version
read -r product_name product_version <<< \ read -r product_name product_version <<< \
"$(jq -r '. | {name, version} | join(" ")' ${project_root}/buildspec.json)" "$(jq -r '. | {name, version} | join(" ")' ${buildspec_file})"
if [[ ${host_os} == 'macos' ]] { if [[ ${host_os} == macos ]] {
autoload -Uz check_packages read_codesign read_codesign_installer read_codesign_pass autoload -Uz check_packages read_codesign read_codesign_installer read_codesign_pass
local output_name="${product_name}-${product_version}-${host_os}-${target##*-}.pkg" local output_name="${product_name}-${product_version}-${host_os}-universal"
if [[ ! -d ${project_root}/release/${product_name}.plugin ]] { if [[ ! -d ${project_root}/release/${config}/${product_name}.plugin ]] {
log_error 'No release artifact found. Run the build script or the CMake install procedure first.' log_error 'No release artifact found. Run the build script or the CMake install procedure first.'
return 2 return 2
} }
if [[ ! -f ${project_root}/build_${target##*-}/installer-macos.generated.pkgproj ]] { local _tarflags='cJf'
log_error 'Packages project file not found. Run the build script or the CMake build and install procedures first.' if (( _loglevel > 1 || ${+CI} )) _tarflags="v${_tarflags}"
if (( package )) {
if [[ ! -f ${project_root}/release/${config}/${product_name}.pkg ]] {
log_error 'Installer Package not found. Run the build script or the CMake build and install procedures first.'
return 2 return 2
} }
check_packages log_group "Packaging ${product_name}..."
log_info "Packaging ${product_name}..."
pushd ${project_root} pushd ${project_root}
packagesbuild \
--build-folder ${project_root}/release \
${project_root}/build_${target##*-}/installer-macos.generated.pkgproj
if (( ${+CODESIGN} )) { if (( codesign )) {
read_codesign_installer read_codesign_installer
productsign \ productsign \
--sign "${CODESIGN_IDENT_INSTALLER}" \ --sign "${CODESIGN_IDENT_INSTALLER}" \
"${project_root}/release/${product_name}.pkg" \ ${project_root}/release/${config}/${product_name}.pkg \
"${project_root}/release/${output_name}" ${project_root}/release/${output_name}.pkg
rm "${project_root}/release/${product_name}.pkg" rm ${project_root}/release/${config}/${product_name}.pkg
} else { } else {
mv "${project_root}/release/${product_name}.pkg" \ mv ${project_root}/release/${config}/${product_name}.pkg \
"${project_root}/release/${output_name}" ${project_root}/release/${output_name}.pkg
} }
if (( ${+CODESIGN} && ${+NOTARIZE} )) { if (( codesign && notarize )) {
if [[ ! -f "${project_root}/release/${output_name}" ]] { if [[ ! -f ${project_root}/release/${output_name}.pkg ]] {
log_error "No package for notarization found." log_error "No package for notarization found."
return 2 return 2
} }
@ -174,18 +210,59 @@ Usage: %B${functrace[1]%:*}%b <option> [<options>]
read_codesign_installer read_codesign_installer
read_codesign_pass read_codesign_pass
xcrun notarytool submit "${project_root}/release/${output_name}" \ xcrun notarytool submit ${project_root}/release/${output_name}.pkg \
--keychain-profile "OBS-Codesign-Password" --wait --keychain-profile "OBS-Codesign-Password" --wait
xcrun stapler staple "${project_root}/release/${output_name}"
local -i _status=0
xcrun stapler staple ${project_root}/release/${output_name}.pkg || _status=1
if (( _status )) {
log_error "Notarization failed. Use 'xcrun notarytool log <submission ID>' to check for errors."
return 2
}
} }
popd popd
} elif [[ ${host_os} == 'linux' ]] { } else {
log_group "Archiving ${product_name}..."
pushd ${project_root}/release/${config}
XZ_OPT=-T0 tar "-${_tarflags}" ${project_root}/release/${output_name}.tar.xz ${product_name}.plugin
popd
}
if [[ ${config} == Release ]] {
log_group "Archiving ${product_name} Debug Symbols..."
pushd ${project_root}/release/${config}
XZ_OPT=-T0 tar "-${_tarflags}" ${project_root}/release/${output_name}-dSYMs.tar.xz ${product_name}.plugin.dSYM
popd
}
log_group
} elif [[ ${host_os} == linux ]] {
local -a cmake_args=() local -a cmake_args=()
if (( _loglevel > 1 )) cmake_args+=(--verbose) if (( _loglevel > 1 )) cmake_args+=(--verbose)
log_group "Creating source tarball for ${product_name}..."
pushd ${project_root} pushd ${project_root}
cmake --build build_${target##*-} --config ${BUILD_CONFIG:-RelWithDebInfo} -t package ${cmake_args} cmake --build build_${target##*-} --config ${config} -t package_source ${cmake_args}
popd popd
if (( package )) {
log_group "Packaging ${product_name}..."
pushd ${project_root}
cmake --build build_${target##*-} --config ${config} -t package ${cmake_args}
popd
} else {
log_group "Archiving ${product_name}..."
local output_name="${product_name}-${product_version}-${target##*-}-linux-gnu"
local _tarflags='cJf'
if (( _loglevel > 1 || ${+CI} )) _tarflags="v${_tarflags}"
pushd ${project_root}/release/${config}
XZ_OPT=-T0 tar "-${_tarflags}" ${project_root}/release/${output_name}.tar.xz (lib|share)
popd
}
log_group
} }
} }

View File

@ -1,15 +1,12 @@
[CmdletBinding()] [CmdletBinding()]
param( param(
[ValidateSet('x64')]
[string] $Target = 'x64',
[ValidateSet('Debug', 'RelWithDebInfo', 'Release', 'MinSizeRel')] [ValidateSet('Debug', 'RelWithDebInfo', 'Release', 'MinSizeRel')]
[string] $Configuration = 'RelWithDebInfo', [string] $Configuration = 'RelWithDebInfo',
[ValidateSet('x86', 'x64')]
[string] $Target,
[ValidateSet('Visual Studio 17 2022', 'Visual Studio 16 2019')]
[string] $CMakeGenerator,
[switch] $SkipAll, [switch] $SkipAll,
[switch] $SkipBuild, [switch] $SkipBuild,
[switch] $SkipDeps, [switch] $SkipDeps
[switch] $SkipUnpack
) )
$ErrorActionPreference = 'Stop' $ErrorActionPreference = 'Stop'
@ -19,6 +16,10 @@ if ( $DebugPreference -eq 'Continue' ) {
$InformationPreference = 'Continue' $InformationPreference = 'Continue'
} }
if ( ! ( [System.Environment]::Is64BitOperatingSystem ) ) {
throw "A 64-bit system is required to build the project."
}
if ( $PSVersionTable.PSVersion -lt '7.0.0' ) { 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' Write-Warning 'The obs-deps PowerShell build script requires PowerShell Core 7. Install or upgrade your PowerShell version: https://aka.ms/pscore6'
exit 2 exit 2
@ -28,6 +29,7 @@ function Build {
trap { trap {
Pop-Location -Stack BuildTemp -ErrorAction 'SilentlyContinue' Pop-Location -Stack BuildTemp -ErrorAction 'SilentlyContinue'
Write-Error $_ Write-Error $_
Log-Group
exit 2 exit 2
} }
@ -46,56 +48,58 @@ function Build {
$ProductName = $BuildSpec.name $ProductName = $BuildSpec.name
$ProductVersion = $BuildSpec.version $ProductVersion = $BuildSpec.version
$script:DepsVersion = '' if ( ! $SkipDeps ) {
$script:QtVersion = '5' Install-BuildDependencies -WingetFile "${ScriptHome}/.Wingetfile"
$script:VisualStudioVersion = ''
$script:PlatformSDK = '10.0.18363.657'
Setup-Host
if ( $CmakeGenerator -eq '' ) {
$CmakeGenerator = $script:VisualStudioVersion
} }
(Get-Content -Path ${ProjectRoot}/CMakeLists.txt -Raw) `
-replace "project\((.*) VERSION (.*)\)", "project(${ProductName} VERSION ${ProductVersion})" `
| Out-File -Path ${ProjectRoot}/CMakeLists.txt
Setup-Obs
Push-Location -Stack BuildTemp Push-Location -Stack BuildTemp
if ( ! ( ( $SkipAll ) -or ( $SkipBuild ) ) ) { if ( ! ( ( $SkipAll ) -or ( $SkipBuild ) ) ) {
Ensure-Location $ProjectRoot Ensure-Location $ProjectRoot
$DepsPath = "plugin-deps-${script:DepsVersion}-qt${script:QtVersion}-${script:Target}" $CmakeArgs = @()
$CmakeArgs = @( $CmakeBuildArgs = @()
'-G', $CmakeGenerator $CmakeInstallArgs = @()
"-DCMAKE_SYSTEM_VERSION=${script:PlatformSDK}"
"-DCMAKE_GENERATOR_PLATFORM=$(if (${script:Target} -eq "x86") { "Win32" } else { "x64" })"
"-DCMAKE_BUILD_TYPE=${Configuration}"
"-DCMAKE_PREFIX_PATH:PATH=$(Resolve-Path -Path "${ProjectRoot}/../obs-build-dependencies/${DepsPath}")"
"-DQT_VERSION=${script:QtVersion}"
)
Log-Debug "Attempting to configure OBS with CMake arguments: $($CmakeArgs | Out-String)"
Log-Information "Configuring ${ProductName}..."
Invoke-External cmake -S . -B build_${script:Target} @CmakeArgs
$CmakeArgs = @(
'--config', "${Configuration}"
)
if ( $VerbosePreference -eq 'Continue' ) { if ( $VerbosePreference -eq 'Continue' ) {
$CmakeArgs+=('--verbose') $CmakeBuildArgs += ('--verbose')
$CmakeInstallArgs += ('--verbose')
} }
Log-Information "Building ${ProductName}..." if ( $DebugPreference -eq 'Continue' ) {
Invoke-External cmake --build "build_${script:Target}" @CmakeArgs $CmakeArgs += ('--debug-output')
} }
Log-Information "Install ${ProductName}..."
Invoke-External cmake --install "build_${script:Target}" --prefix "${ProjectRoot}/release" @CmakeArgs $Preset = "windows-$(if ( $Env:CI -ne $null ) { 'ci-' })${Target}"
$CmakeArgs += @(
'--preset', $Preset
)
$CmakeBuildArgs += @(
'--build'
'--preset', $Preset
'--config', $Configuration
'--parallel'
'--', '/consoleLoggerParameters:Summary', '/noLogo'
)
$CmakeInstallArgs += @(
'--install', "build_${Target}"
'--prefix', "${ProjectRoot}/release/${Configuration}"
'--config', $Configuration
)
Log-Group "Configuring ${ProductName}..."
Invoke-External cmake @CmakeArgs
Log-Group "Building ${ProductName}..."
Invoke-External cmake @CmakeBuildArgs
}
Log-Group "Install ${ProductName}..."
Invoke-External cmake @CmakeInstallArgs
Pop-Location -Stack BuildTemp Pop-Location -Stack BuildTemp
Log-Group
} }
Build Build

View File

@ -1,10 +1,11 @@
[CmdletBinding()] [CmdletBinding()]
param( param(
[ValidateSet('x64')]
[string] $Target = 'x64',
[ValidateSet('Debug', 'RelWithDebInfo', 'Release', 'MinSizeRel')] [ValidateSet('Debug', 'RelWithDebInfo', 'Release', 'MinSizeRel')]
[string] $Configuration = 'RelWithDebInfo', [string] $Configuration = 'RelWithDebInfo',
[ValidateSet('x86', 'x64', 'x86+x64')] [switch] $BuildInstaller,
[string] $Target, [switch] $SkipDeps
[switch] $BuildInstaller = $false
) )
$ErrorActionPreference = 'Stop' $ErrorActionPreference = 'Stop'
@ -14,14 +15,21 @@ if ( $DebugPreference -eq 'Continue' ) {
$InformationPreference = 'Continue' $InformationPreference = 'Continue'
} }
if ( ! ( [System.Environment]::Is64BitOperatingSystem ) ) {
throw "Packaging script requires a 64-bit system to build and run."
}
if ( $PSVersionTable.PSVersion -lt '7.0.0' ) { 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' Write-Warning 'The packaging script requires PowerShell Core 7. Install or upgrade your PowerShell version: https://aka.ms/pscore6'
exit 2 exit 2
} }
function Package { function Package {
trap { trap {
Pop-Location -Stack BuildTemp -ErrorAction 'SilentlyContinue'
Write-Error $_ Write-Error $_
Log-Group
exit 2 exit 2
} }
@ -42,9 +50,9 @@ function Package {
$OutputName = "${ProductName}-${ProductVersion}-windows-${Target}" $OutputName = "${ProductName}-${ProductVersion}-windows-${Target}"
if ( ! $SkipDeps ) {
Install-BuildDependencies -WingetFile "${ScriptHome}/.Wingetfile" Install-BuildDependencies -WingetFile "${ScriptHome}/.Wingetfile"
}
Log-Information "Packaging ${ProductName}..."
$RemoveArgs = @{ $RemoveArgs = @{
ErrorAction = 'SilentlyContinue' ErrorAction = 'SilentlyContinue'
@ -56,19 +64,20 @@ function Package {
Remove-Item @RemoveArgs Remove-Item @RemoveArgs
Log-Group "Archiving ${ProductName}..."
$CompressArgs = @{
Path = (Get-ChildItem -Path "${ProjectRoot}/release/${Configuration}" -Exclude "${OutputName}*.*")
CompressionLevel = 'Optimal'
DestinationPath = "${ProjectRoot}/release/${OutputName}.zip"
Verbose = ($Env:CI -ne $null)
}
Compress-Archive -Force @CompressArgs
Log-Group
if ( ( $BuildInstaller ) ) { if ( ( $BuildInstaller ) ) {
if ( $Target -eq 'x86+x64' ) { Log-Group "Packaging ${ProductName}..."
$IsccCandidates = Get-ChildItem -Recurse -Path '*.iss'
if ( $IsccCandidates.length -gt 0 ) {
$IsccFile = $IsccCandidates[0].FullName
} else {
$IsccFile = ''
}
} else {
$IsccFile = "${ProjectRoot}/build_${Target}/installer-Windows.generated.iss" $IsccFile = "${ProjectRoot}/build_${Target}/installer-Windows.generated.iss"
}
if ( ! ( Test-Path -Path $IsccFile ) ) { if ( ! ( Test-Path -Path $IsccFile ) ) {
throw 'InnoSetup install script not found. Run the build script or the CMake build and install procedures first.' throw 'InnoSetup install script not found. Run the build script or the CMake build and install procedures first.'
} }
@ -76,17 +85,13 @@ function Package {
Log-Information 'Creating InnoSetup installer...' Log-Information 'Creating InnoSetup installer...'
Push-Location -Stack BuildTemp Push-Location -Stack BuildTemp
Ensure-Location -Path "${ProjectRoot}/release" Ensure-Location -Path "${ProjectRoot}/release"
Invoke-External iscc ${IsccFile} /O. /F"${OutputName}-Installer" Copy-Item -Path ${Configuration} -Destination Package -Recurse
Invoke-External iscc ${IsccFile} /O"${ProjectRoot}/release" /F"${OutputName}-Installer"
Remove-Item -Path Package -Recurse
Pop-Location -Stack BuildTemp Pop-Location -Stack BuildTemp
}
$CompressArgs = @{ Log-Group
Path = (Get-ChildItem -Path "${ProjectRoot}/release" -Exclude "${OutputName}*.*")
CompressionLevel = 'Optimal'
DestinationPath = "${ProjectRoot}/release/${OutputName}.zip"
} }
Compress-Archive -Force @CompressArgs
} }
Package Package

View File

@ -1,13 +0,0 @@
#!/bin/sh
if ! type zsh > /dev/null 2>&1; then
echo ' => Installing script dependency Zsh.'
sudo apt-get -y update
sudo apt-get -y install zsh
fi
SCRIPT=$(readlink -f "${0}")
SCRIPT_DIR=$(dirname "${SCRIPT}")
zsh ${SCRIPT_DIR}/build-linux.zsh "${@}"

View File

@ -1,11 +0,0 @@
#!/bin/bash
dirty=$(git ls-files --modified)
set +x
if [[ $dirty ]]; then
echo "================================="
echo "Files were not formatted properly"
echo "$dirty"
echo "================================="
exit 1
fi

View File

@ -1,53 +0,0 @@
#!/usr/bin/env bash
set -o errexit
set -o pipefail
if [ ${#} -eq 1 -a "${1}" = "VERBOSE" ]; then
VERBOSITY="-l debug"
else
VERBOSITY=""
fi
if [ "${CI}" ]; then
MODE="--check"
else
MODE="-i"
fi
# Runs the formatter in parallel on the code base.
# Return codes:
# - 1 there are files to be formatted
# - 0 everything looks fine
# Get CPU count
OS=$(uname)
NPROC=1
if [[ ${OS} = "Linux" ]] ; then
NPROC=$(nproc)
elif [[ ${OS} = "Darwin" ]] ; then
NPROC=$(sysctl -n hw.physicalcpu)
fi
# Discover clang-format
if ! type cmake-format 2> /dev/null ; then
echo "Required cmake-format not found"
exit 1
fi
find . -type d \( \
-path ./\*build\* -o \
-path ./release -o \
-path ./deps/jansson -o \
-path ./plugins/decklink/\*/decklink-sdk -o \
-path ./plugins/enc-amf -o \
-path ./plugins/mac-syphon/syphon-framework -o \
-path ./plugins/obs-outputs/ftl-sdk -o \
-path ./plugins/obs-vst -o \
-path ./plugins/obs-browser -o \
-path ./plugins/win-dshow/libdshowcapture -o \
-path ./plugins/obs-websocket/deps \
\) -prune -false -type f -o \
-name 'CMakeLists.txt' -or \
-name '*.cmake' \
| xargs -L10 -P ${NPROC} cmake-format ${MODE} ${VERBOSITY}

View File

@ -1,60 +0,0 @@
#!/usr/bin/env bash
# Original source https://github.com/Project-OSRM/osrm-backend/blob/master/scripts/format.sh
set -o errexit
set -o pipefail
set -o nounset
if [ ${#} -eq 1 ]; then
VERBOSITY="--verbose"
else
VERBOSITY=""
fi
# Runs the Clang Formatter in parallel on the code base.
# Return codes:
# - 1 there are files to be formatted
# - 0 everything looks fine
# Get CPU count
OS=$(uname)
NPROC=1
if [[ ${OS} = "Linux" ]] ; then
NPROC=$(nproc)
elif [[ ${OS} = "Darwin" ]] ; then
NPROC=$(sysctl -n hw.physicalcpu)
fi
# Discover clang-format
if type clang-format-13 2> /dev/null ; then
CLANG_FORMAT=clang-format-13
elif type clang-format 2> /dev/null ; then
# Clang format found, but need to check version
CLANG_FORMAT=clang-format
V=$(clang-format --version)
if [[ $V != *"version 13.0"* ]]; then
echo "clang-format is not 13.0 (returned ${V})"
exit 1
fi
else
echo "No appropriate clang-format found (expected clang-format-13.0.0, or clang-format)"
exit 1
fi
find . -type d \( \
-path ./\*build\* -o \
-path ./release -o \
-path ./cmake -o \
-path ./plugins/decklink/\*/decklink-sdk -o \
-path ./plugins/enc-amf -o \
-path ./plugins/mac-syphon/syphon-framework -o \
-path ./plugins/obs-outputs/ftl-sdk -o \
-path ./plugins/obs-websocket/deps \
\) -prune -false -type f -o \
-name '*.h' -or \
-name '*.hpp' -or \
-name '*.m' -or \
-name '*.mm' -or \
-name '*.c' -or \
-name '*.cpp' \
| xargs -L100 -P ${NPROC} "${CLANG_FORMAT}" ${VERBOSITY} -i -style=file -fallback-style=none

View File

@ -1,13 +0,0 @@
#!/bin/sh
if ! type zsh > /dev/null 2>&1; then
echo ' => Installing script dependency Zsh.'
sudo apt-get update
sudo apt-get install zsh
fi
SCRIPT=$(readlink -f "${0}")
SCRIPT_DIR=$(dirname "${SCRIPT}")
zsh ${SCRIPT_DIR}/package-linux.zsh "${@}"

View File

@ -1,25 +0,0 @@
function Check-Git {
<#
.SYNOPSIS
Ensures available git executable on host system.
.DESCRIPTION
Checks whether a git command is available on the host system. If none is found,
Git is installed via winget.
.EXAMPLE
Check-Git
#>
if ( ! ( Test-Path function:Log-Info ) ) {
. $PSScriptRoot/Logger.ps1
}
Log-Information 'Checking for Git executable...'
if ( ! ( Get-Command git ) ) {
Log-Warning 'No Git executable found. Will try to install via winget.'
winget install git
} else {
Log-Debug "Git found at $(Get-Command git)."
Log-Status "Git found."
}
}

View File

@ -18,7 +18,11 @@ function Install-BuildDependencies {
. $PSScriptRoot/Logger.ps1 . $PSScriptRoot/Logger.ps1
} }
$Host64Bit = [System.Environment]::Is64BitOperatingSystem $Prefixes = @{
'x64' = ${Env:ProgramFiles}
'x86' = ${Env:ProgramFiles(x86)}
'arm64' = ${Env:ProgramFiles(arm)}
}
$Paths = $Env:Path -split [System.IO.Path]::PathSeparator $Paths = $Env:Path -split [System.IO.Path]::PathSeparator
@ -28,14 +32,15 @@ function Install-BuildDependencies {
$WingetOptions += '--silent' $WingetOptions += '--silent'
} }
Log-Group 'Check Windows build requirements'
Get-Content $WingetFile | ForEach-Object { Get-Content $WingetFile | ForEach-Object {
$_, $Package, $_, $Path, $_, $Binary = ([regex]::Split($_, " (?=(?:[^']|'[^']*')*$)")) -replace ',', '' -replace "'",'' $_, $Package, $_, $Path, $_, $Binary, $_, $Version = $_ -replace ',','' -split " +(?=(?:[^\']*\'[^\']*\')*[^\']*$)" -replace "'",''
(${Env:ProgramFiles(x86)}, $Env:ProgramFiles) | ForEach-Object { $Prefixes.GetEnumerator() | ForEach-Object {
$Prefix = $_ $Prefix = $_.value
$FullPath = "${Prefix}\${Path}" $FullPath = "${Prefix}\${Path}"
if ( ( Test-Path $FullPath ) -and ! ( $Paths -contains $FullPath ) ) { if ( ( Test-Path $FullPath ) -and ! ( $Paths -contains $FullPath ) ) {
$Paths += $FullPath $Paths = @($FullPath) + $Paths
$Env:Path = $Paths -join [System.IO.Path]::PathSeparator $Env:Path = $Paths -join [System.IO.Path]::PathSeparator
} }
} }
@ -46,7 +51,11 @@ function Install-BuildDependencies {
if ( $Found ) { if ( $Found ) {
Log-Status "Found dependency ${Binary} as $($Found.Source)" Log-Status "Found dependency ${Binary} as $($Found.Source)"
} else { } else {
Log-Status "Installing package ${Package}" Log-Status "Installing package ${Package} $(if ( $Version -ne $null ) { "Version: ${Version}" } )"
if ( $Version -ne $null ) {
$WingetOptions += @('--version', ${Version})
}
try { try {
$Params = $WingetOptions + $Package $Params = $WingetOptions + $Package
@ -57,4 +66,5 @@ function Install-BuildDependencies {
} }
} }
} }
Log-Group
} }

View File

@ -1,117 +0,0 @@
function Set-GitConfig {
<#
.SYNOPSIS
Sets a git config value.
.DESCRIPTION
Allows setting single or multiple config values in a PowerShell-friendly fashion.
.EXAMPLE
Set-GitConfig advice.detachedHead false
#>
if ( $args.Count -lt 2 ) {
throw 'Set-GitConfig called without required arguments <OPTION> <VALUE>.'
}
Invoke-External git config @args
}
function Invoke-GitCheckout {
<#
.SYNOPSIS
Checks out a specified git repository.
.DESCRIPTION
Wraps the git executable with PowerShell syntax to check out
a specified Git repository with a given commit hash and branch,
or a GitHub pull request ID.
.EXAMPLE
Invoke-GitCheckout -Uri "My-Repo-Uri" -Commit "My-Commit-Hash"
Invoke-GitCheckout -Uri "My-Repo-Uri" -Commit "My-Commit-Hash" -Branch "main"
Invoke-GitCheckout -Uri "My-Repo-Uri" -Commit "My-Commit-Hash" -PullRequest 250
#>
param(
[Parameter(Mandatory)]
[string] $Uri,
[Parameter(Mandatory)]
[string] $Commit,
[string] $Path,
[string] $Branch = "master",
[string] $PullRequest
)
if ( ! ( $Uri -like "*github.com*" ) -and ( $PullRequest -ne "" ) ) {
throw 'Fetching pull requests is only supported with GitHub-based repositories.'
}
if ( ! ( Test-Path function:Log-Information ) ) {
. $PSScriptRoot/Logger.ps1
}
if ( ! ( Test-Path function:Invoke-External ) ) {
. $PSScriptRoot/Invoke-External.ps1
}
$RepositoryName = [System.IO.Path]::GetFileNameWithoutExtension($Uri)
if ( $Path -eq "" ) {
$Path = "$(Get-Location | Convert-Path)\${RepositoryName}"
}
Push-Location -Stack GitCheckoutTemp
if ( Test-Path $Path/.git ) {
Write-Information "Repository ${RepositoryName} found in ${Path}"
Set-Location $Path
Set-GitConfig advice.detachedHead false
Set-GitConfig remote.origin.url $Uri
Set-GitConfig remote.origin.tapOpt --no-tags
$Ref = "+refs/heads/{0}:refs/remotes/origin/{0}" -f $Branch
Set-GitConfig --replace-all remote.origin.fetch $Ref
if ( $PullRequest -ne "" ) {
try {
Invoke-External git show-ref --quiet --verify refs/heads/pr-$PullRequest
} catch {
Invoke-External git fetch origin $("pull/{0}/head:pull-{0}" -f $PullRequest)
} finally {
Invoke-External git checkout -f "pull-${PullRequest}"
}
}
try {
$null = Invoke-External git rev-parse -q --verify "${Commit}^{commit}"
} catch {
Invoke-External git fetch origin
}
Invoke-External git checkout -f $Commit -- | Log-Information
} else {
Invoke-External git clone $Uri $Path
Set-Location $Path
Set-GitConfig advice.detachedHead false
if ( $PullRequest -ne "" ) {
$Ref = "pull/{0}/head:pull-{0}" -f $PullRequest
$Branch = "pull-${PullRequest}"
Invoke-External git fetch origin $Ref
Invoke-External git checkout $Branch
}
Invoke-External git checkout -f $Commit
}
Log-Information "Checked out commit ${Commit} on branch ${Branch}"
if ( Test-Path ${Path}/.gitmodules ) {
Invoke-External git submodule foreach --recursive git submodule sync
Invoke-External git submodule update --init --recursive
}
Pop-Location -Stack GitCheckoutTemp
}

View File

@ -8,7 +8,7 @@ function Log-Debug {
Process { Process {
foreach($m in $Message) { foreach($m in $Message) {
Write-Debug $m Write-Debug "$(if ( $env:CI -ne $null ) { '::debug::' })$m"
} }
} }
} }
@ -38,7 +38,7 @@ function Log-Warning {
Process { Process {
foreach($m in $Message) { foreach($m in $Message) {
Write-Warning $m Write-Warning "$(if ( $env:CI -ne $null ) { '::warning::' })$m"
} }
} }
} }
@ -53,7 +53,7 @@ function Log-Error {
Process { Process {
foreach($m in $Message) { foreach($m in $Message) {
Write-Error $m Write-Error "$(if ( $env:CI -ne $null ) { '::error::' })$m"
} }
} }
} }
@ -79,6 +79,32 @@ function Log-Information {
} }
} }
function Log-Group {
[CmdletBinding()]
param(
[Parameter(ValueFromPipeline)]
[string[]] $Message
)
Process {
if ( $Env:CI -ne $null ) {
if ( $script:LogGroup ) {
Write-Output '::endgroup::'
$script:LogGroup = $false
}
if ( $Message.count -ge 1 ) {
Write-Output "::group::$($Message -join ' ')"
$script:LogGroup = $true
}
} else {
if ( $Message.count -ge 1 ) {
Log-Information $Message
}
}
}
}
function Log-Status { function Log-Status {
[CmdletBinding()] [CmdletBinding()]
param( param(

View File

@ -1,103 +0,0 @@
function Setup-Host {
if ( ! ( Test-Path function:Log-Output ) ) {
. $PSScriptRoot/Logger.ps1
}
if ( ! ( Test-Path function:Ensure-Location ) ) {
. $PSScriptRoot/Ensure-Location.ps1
}
if ( ! ( Test-Path function:Install-BuildDependencies ) ) {
. $PSScriptRoot/Install-BuildDependencies.ps1
}
if ( ! ( Test-Path function:Expand-ArchiveExt ) ) {
. $PSScriptRoot/Expand-ArchiveExt.ps1
}
Install-BuildDependencies -WingetFile "${ScriptHome}/.Wingetfile"
if ( $script:Target -eq '' ) { $script:Target = $script:HostArchitecture }
$script:QtVersion = $BuildSpec.platformConfig."windows-${script:Target}".qtVersion
$script:VisualStudioVersion = $BuildSpec.platformConfig."windows-${script:Target}".visualStudio
$script:PlatformSDK = $BuildSpec.platformConfig."windows-${script:Target}".platformSDK
if ( ! ( ( $script:SkipAll ) -or ( $script:SkipDeps ) ) ) {
('prebuilt', "qt${script:QtVersion}") | ForEach-Object {
$_Dependency = $_
$_Version = $BuildSpec.dependencies."${_Dependency}".version
$_BaseUrl = $BuildSpec.dependencies."${_Dependency}".baseUrl
$_Label = $BuildSpec.dependencies."${_Dependency}".label
$_Hash = $BuildSpec.dependencies."${_Dependency}".hashes."windows-${script:Target}"
if ( $BuildSpec.dependencies."${_Dependency}".PSobject.Properties.Name -contains "pdb-hashes" ) {
$_PdbHash = $BuildSpec.dependencies."${_Dependency}".'pdb-hashes'."$windows-${script:Target}"
}
if ( $_Version -eq '' ) {
throw "No ${_Dependency} spec found in ${script:BuildSpecFile}."
}
Log-Information "Setting up ${_Label}..."
Push-Location -Stack BuildTemp
Ensure-Location -Path "$(Resolve-Path -Path "${ProjectRoot}/..")/obs-build-dependencies"
switch -wildcard ( $_Dependency ) {
prebuilt {
$_Filename = "windows-deps-${_Version}-${script:Target}.zip"
$_Uri = "${_BaseUrl}/${_Version}/${_Filename}"
$_Target = "plugin-deps-${_Version}-qt${script:QtVersion}-${script:Target}"
$script:DepsVersion = ${_Version}
}
"qt*" {
$_Filename = "windows-deps-qt${script:QtVersion}-${_Version}-${script:Target}.zip"
$_Uri = "${_BaseUrl}/${_Version}/${_Filename}"
$_Target = "plugin-deps-${_Version}-qt${script:QtVersion}-${script:Target}"
}
}
if ( ! ( Test-Path -Path $_Filename ) ) {
$Params = @{
UserAgent = 'NativeHost'
Uri = $_Uri
OutFile = $_Filename
UseBasicParsing = $true
ErrorAction = 'Stop'
}
Invoke-WebRequest @Params
Log-Status "Downloaded ${_Label} for ${script:Target}."
} else {
Log-Status "Found downloaded ${_Label}."
}
$_FileHash = Get-FileHash -Path $_Filename -Algorithm SHA256
if ( $_FileHash.Hash.ToLower() -ne $_Hash ) {
throw "Checksum of downloaded ${_Label} does not match specification. Expected '${_Hash}', 'found $(${_FileHash}.Hash.ToLower())'"
}
Log-Status "Checksum of downloaded ${_Label} matches."
if ( ! ( ( $script:SkipAll ) -or ( $script:SkipUnpack ) ) ) {
Push-Location -Stack BuildTemp
Ensure-Location -Path $_Target
Expand-ArchiveExt -Path "../${_Filename}" -DestinationPath . -Force
Pop-Location -Stack BuildTemp
}
Pop-Location -Stack BuildTemp
}
}
}
function Get-HostArchitecture {
$Host64Bit = [System.Environment]::Is64BitOperatingSystem
$HostArchitecture = ('x86', 'x64')[$Host64Bit]
return $HostArchitecture
}
$script:HostArchitecture = Get-HostArchitecture

View File

@ -1,84 +0,0 @@
function Setup-Obs {
if ( ! ( Test-Path function:Log-Output ) ) {
. $PSScriptRoot/Logger.ps1
}
if ( ! ( Test-Path function:Check-Git ) ) {
. $PSScriptRoot/Check-Git.ps1
}
Check-Git
if ( ! ( Test-Path function:Ensure-Location ) ) {
. $PSScriptRoot/Ensure-Location.ps1
}
if ( ! ( Test-Path function:Invoke-GitCheckout ) ) {
. $PSScriptRoot/Invoke-GitCheckout.ps1
}
if ( ! ( Test-Path function:Invoke-External ) ) {
. $PSScriptRoot/Invoke-External.ps1
}
Log-Information 'Setting up OBS Studio...'
$ObsVersion = $BuildSpec.dependencies.'obs-studio'.version
$ObsRepository = $BuildSpec.dependencies.'obs-studio'.repository
$ObsBranch = $BuildSpec.dependencies.'obs-studio'.branch
$ObsHash = $BuildSpec.dependencies.'obs-studio'.hash
if ( $ObsVersion -eq '' ) {
throw 'No obs-studio version found in buildspec.json.'
}
Push-Location -Stack BuildTemp
Ensure-Location -Path "$(Resolve-Path -Path "${ProjectRoot}/../")/obs-studio"
if ( ! ( ( $script:SkipAll ) -or ( $script:SkipUnpack ) ) ) {
Invoke-GitCheckout -Uri $ObsRepository -Commit $ObsHash -Path . -Branch $ObsBranch
}
if ( ! ( ( $script:SkipAll ) -or ( $script:SkipBuild ) ) ) {
Log-Information 'Configuring OBS Studio...'
$NumProcessors = (Get-CimInstance Win32_ComputerSystem).NumberOfLogicalProcessors
if ( $NumProcessors -gt 1 ) {
$env:UseMultiToolTask = $true
$env:EnforceProcessCountAcrossBuilds = $true
}
$DepsPath = "plugin-deps-${script:DepsVersion}-qt${script:QtVersion}-${script:Target}"
$CmakeArgs = @(
'-G', $CmakeGenerator
"-DCMAKE_SYSTEM_VERSION=${script:PlatformSDK}"
"-DCMAKE_GENERATOR_PLATFORM=$(if (${script:Target} -eq "x86") { "Win32" } else { "x64" })"
"-DCMAKE_BUILD_TYPE=${script:Configuration}"
"-DQT_VERSION=${script:QtVersion}"
'-DENABLE_PLUGINS=OFF'
'-DENABLE_UI=OFF'
'-DENABLE_SCRIPTING=OFF'
"-DCMAKE_INSTALL_PREFIX:PATH=$(Resolve-Path -Path "${ProjectRoot}/../obs-build-dependencies/${DepsPath}")"
"-DCMAKE_PREFIX_PATH:PATH=$(Resolve-Path -Path "${ProjectRoot}/../obs-build-dependencies/${DepsPath}")"
)
Log-Debug "Attempting to configure OBS with CMake arguments: $($CmakeArgs | Out-String)"
Log-Information "Configuring OBS..."
Invoke-External cmake -S . -B plugin_build_${script:Target} @CmakeArgs
Log-Information 'Building libobs and obs-frontend-api...'
$CmakeArgs = @(
'--config', "$( if ( $script:Configuration -eq '' ) { 'RelWithDebInfo' } else { $script:Configuration })"
)
if ( $VerbosePreference -eq 'Continue' ) {
$CmakeArgs+=('--verbose')
}
Invoke-External cmake --build plugin_build_${script:Target} @CmakeArgs -t obs-frontend-api
Invoke-External cmake --install plugin_build_${script:Target} @CmakeArgs --component obs_libraries
}
Pop-Location -Stack BuildTemp
}

View File

@ -1,4 +1,20 @@
autoload -Uz log_info log_status log_error log_debug log_warning autoload -Uz log_info log_status log_error log_debug log_warning log_group
log_group 'Check Linux build requirements'
log_debug 'Checking Linux distribution name and version...'
# Check for Ubuntu version 22.10 or later, which have srt and librist available via apt-get
typeset -g -i UBUNTU_2210_OR_LATER=0
if [[ -f /etc/os_release ]] {
local dist_name
local dist_version
read -r dist_name dist_version <<< "$(source /etc/os_release; print "${NAME} ${VERSION_ID}")"
autoload -Uz is-at-least
if [[ ${dist_name} == Ubuntu ]] && is-at-least 22.10 ${dist_version}; then
typeset -g -i UBUNTU_2210_OR_LATER=1
fi
}
log_debug 'Checking for apt-get...' log_debug 'Checking for apt-get...'
if (( ! ${+commands[apt-get]} )) { if (( ! ${+commands[apt-get]} )) {
@ -8,12 +24,14 @@ if (( ! ${+commands[apt-get]} )) {
log_debug "Apt-get located at ${commands[apt-get]}" log_debug "Apt-get located at ${commands[apt-get]}"
} }
local -a dependencies=("${(f)$(<${SCRIPT_HOME}/.Aptfile)}") local -a dependencies=("${(fA)$(<${SCRIPT_HOME}/.Aptfile)}")
local -a install_list local -a install_list
local binary local binary
sudo apt-get update -qq
for dependency (${dependencies}) { for dependency (${dependencies}) {
local -a tokens=(${(s: :)dependency//(,|:|\')/}) local -a tokens=(${=dependency//(,|:|\')/})
if [[ ! ${tokens[1]} == 'package' ]] continue if [[ ! ${tokens[1]} == 'package' ]] continue
@ -26,11 +44,18 @@ for dependency (${dependencies}) {
if (( ! ${+commands[${binary}]} )) install_list+=(${tokens[2]}) if (( ! ${+commands[${binary}]} )) install_list+=(${tokens[2]})
} }
local -a _quiet=('' '--quiet')
log_debug "List of dependencies to install: ${install_list}" log_debug "List of dependencies to install: ${install_list}"
if (( ${#install_list} )) { if (( ${#install_list} )) {
if (( ! ${+CI} )) log_warning 'Dependency installation via apt may require elevated privileges' if (( ! ${+CI} )) log_warning 'Dependency installation via apt may require elevated privileges'
sudo apt-get -y install ${install_list} ${_quiet[(( (_loglevel == 0) + 1 ))]} local -a apt_args=(
${CI:+-y}
--no-install-recommends
)
if (( _loglevel == 0 )) apt_args+=(--quiet)
sudo apt-get ${apt_args} install ${install_list}
} }
rehash
log_group

View File

@ -1,9 +1,10 @@
autoload -Uz is-at-least log_info log_error log_status read_codesign autoload -Uz is-at-least log_group log_info log_error log_status read_codesign
local macos_version=$(sw_vers -productVersion) local macos_version=$(sw_vers -productVersion)
log_group 'Install macOS build requirements'
log_info 'Checking macOS version...' log_info 'Checking macOS version...'
if ! is-at-least 11.0 "${macos_version}"; then if ! is-at-least 11.0 ${macos_version}; then
log_error "Minimum required macOS version is 11.0, but running on macOS ${macos_version}" log_error "Minimum required macOS version is 11.0, but running on macOS ${macos_version}"
return 2 return 2
else else
@ -16,5 +17,6 @@ if (( ! ${+commands[brew]} )) {
return 2 return 2
} }
brew bundle --file "${SCRIPT_HOME}/.Brewfile" brew bundle --file ${SCRIPT_HOME}/.Brewfile
rehash rehash
log_group

View File

@ -1,52 +0,0 @@
if (( ! ${+commands[packagesbuild]} )) {
autoload -Uz log_info log_status mkcd
if (( ! ${+commands[curl]} )) {
log_error 'curl not found. Please install curl.'
return 2
}
if (( ! ${+project_root} )) {
log_error "'project_root' not set. Please set before running ${0}."
return 2
}
local -a curl_opts=()
if (( ! ${+CI} )) {
curl_opts+=(--progress-bar)
} else {
curl_opts+=(--show-error --silent)
}
curl_opts+=(--location -O ${@})
log_info 'Installing Packages.app...'
pushd
mkcd ${project_root:h}/obs-build-dependencies
local packages_url='http://s.sudre.free.fr/Software/files/Packages_1210_1.dmg'
local packages_hash='6afdd25386295974dad8f078b8f1e41cabebd08e72d970bf92f707c7e48b16c9'
if [[ ! -f Packages_1210_1.dmg ]] {
log_status 'Download Packages.app'
curl ${curl_opts} ${packages_url}
}
local image_checksum
read -r image_checksum _ <<< "$(sha256sum Packages_1210_1.dmg)"
if [[ ${packages_hash} != ${image_checksum} ]] {
log_error "Checksum mismatch of Packages.app download.
Expected : ${packages_hash}
Actual : ${image_checksum}"
return 2
}
hdiutil attach -noverify Packages_1210_1.dmg &> /dev/null && log_status 'Packages_1210_1.dmg image mounted.'
log_info 'Installing Packages.app...'
packages_volume=$(hdiutil info -plist | grep '<string>/Volumes/Packages' | sed 's/.*<string>\(\/Volumes\/[^<]*\)<\/string>/\1/')
sudo installer -pkg "${packages_volume}/packages/Packages.pkg" -target / && rehash
hdiutil detach ${packages_volume} &> /dev/null && log_status 'Packages.dmg image unmounted.'
}

View File

@ -1,3 +1,3 @@
if (( ! ${+_loglevel} )) typeset -g _loglevel=1 if (( ! ${+_loglevel} )) typeset -g _loglevel=1
if (( _loglevel > 2 )) print -PR -e -- "%F{220}DEBUG: ${@}%f" if (( _loglevel > 2 )) print -PR -e -- "${CI:+::debug::}%F{220}DEBUG: ${@}%f"

View File

@ -1,3 +1,3 @@
local icon=' ✖︎ ' local icon=' ✖︎ '
print -u2 -PR "%F{1} ${icon} %f ${@}" print -u2 -PR "${CI:+::error::}%F{1} ${icon} %f ${@}"

16
.github/scripts/utils.zsh/log_group vendored Executable file
View File

@ -0,0 +1,16 @@
autoload -Uz log_info
if (( ! ${+_log_group} )) typeset -g _log_group=0
if (( ${+CI} )) {
if (( _log_group )) {
print "::endgroup::"
typeset -g _log_group=0
}
if (( # )) {
print "::group::${@}"
typeset -g _log_group=1
}
} else {
if (( # )) log_info ${@}
}

View File

@ -1,5 +1,5 @@
if (( _loglevel > 0 )) { if (( _loglevel > 0 )) {
local icon=' =>' local icon=' =>'
print -PR "%F{3} ${(r:5:)icon} ${@}%f" print -PR "${CI:+::warning::}%F{3} ${(r:5:)icon} ${@}%f"
} }

View File

@ -2,6 +2,8 @@ autoload -Uz log_info
if (( ! ${+CODESIGN_IDENT} )) { if (( ! ${+CODESIGN_IDENT} )) {
typeset -g CODESIGN_IDENT typeset -g CODESIGN_IDENT
log_info 'Setting up identity for application codesigning...' log_info 'Setting up Apple Developer ID for application codesigning...'
read CODESIGN_IDENT'?Apple Developer Application ID: ' read CODESIGN_IDENT'?Apple Developer Application ID: '
} }
typeset -g CODESIGN_TEAM=$(print "${CODESIGN_IDENT}" | /usr/bin/sed -En 's/.+\((.+)\)/\1/p')

View File

@ -2,6 +2,6 @@ autoload -Uz log_info
if (( ! ${+CODESIGN_IDENT_INSTALLER} )) { if (( ! ${+CODESIGN_IDENT_INSTALLER} )) {
typeset -g CODESIGN_IDENT_INSTALLER typeset -g CODESIGN_IDENT_INSTALLER
log_info 'Setting up identity for installer package codesigning...' log_info 'Setting up Apple Developer Installer ID for installer package codesigning...'
read CODESIGN_IDENT_INSTALLER'?Apple Developer Installer ID: ' read CODESIGN_IDENT_INSTALLER'?Apple Developer Installer ID: '
} }

View File

@ -11,14 +11,12 @@
# 'OBS-Codesign-Password'with access Apple's 'altool' only. # 'OBS-Codesign-Password'with access Apple's 'altool' only.
############################################################################## ##############################################################################
autoload -Uz read_codesign read_codesign_user log_info autoload -Uz read_codesign read_codesign_user log_info log_warning
if (( ! ${+CODESIGN_IDENT} )) { if (( ! ${+CODESIGN_IDENT} )) {
read_codesign read_codesign
} }
local codesign_ident_short=$(print "${CODESIGN_IDENT}" | /usr/bin/sed -En 's/.+\((.+)\)/\1/p')
if (( ! ${+CODESIGN_IDENT_USER} )) { if (( ! ${+CODESIGN_IDENT_USER} )) {
read_codesign_user read_codesign_user
} }
@ -30,4 +28,11 @@ if (( ! ${+CODESIGN_IDENT_PASS} )) {
print '' print ''
log_info 'Setting up notarization keychain...' log_info 'Setting up notarization keychain...'
xcrun notarytool store-credentials 'OBS-Codesign-Password' --apple-id "${CODESIGN_IDENT_USER}" --team-id "${codesign_ident_short}" --password "${CODESIGN_IDENT_PASS}" log_warning "
+ Your Apple ID and an app-specific password is necessary for notarization from CLI
+ This password will be stored in your macOS keychain under the identifier
'OBS-Codesign-Password' with access Apple's 'altool' only.
"
xcrun notarytool store-credentials 'OBS-Codesign-Password' --apple-id "${CODESIGN_IDENT_USER}" --team-id "${CODESIGN_TEAM}" --password "${CODESIGN_IDENT_PASS}"

View File

@ -0,0 +1,7 @@
autoload -Uz log_info
if (( ! ${+CODESIGN_TEAM} )) {
typeset -g CODESIGN_TEAM
log_info 'Setting up Apple Developer Team ID for codesigning...'
read CODESIGN_TEAM'?Apple Developer Team ID (leave empty to use Apple Developer ID instead): '
}

View File

@ -2,6 +2,6 @@ autoload -Uz log_info
if (( ! ${+CODESIGN_IDENT_USER} )) { if (( ! ${+CODESIGN_IDENT_USER} )) {
typeset -g CODESIGN_IDENT_USER typeset -g CODESIGN_IDENT_USER
log_info 'Setting up developer id for codesigning...' log_info 'Setting up Apple ID for notarization...'
read CODESIGN_IDENT_USER'?Apple Developer ID: ' read CODESIGN_IDENT_USER'?Apple ID: '
} }

View File

@ -1,12 +1,40 @@
autoload -Uz log_debug log_warning autoload -Uz log_debug log_warning
if (( ! ${+project_root} )) {
log_error "'project_root' not set. Please set before running ${0}."
return 2
}
if (( ${+commands[ccache]} )) { if (( ${+commands[ccache]} )) {
log_debug "Found ccache at ${commands[ccache]}" log_debug "Found ccache at ${commands[ccache]}"
typeset -gx CCACHE_CONFIGPATH="${project_root}/.ccache.conf"
ccache --set-config=run_second_cpp=true
ccache --set-config=direct_mode=true
ccache --set-config=inode_cache=true
ccache --set-config=compiler_check=content
ccache --set-config=file_clone=true
local -a sloppiness=(
include_file_mtime
include_file_ctime
file_stat_matches
system_headers
)
if [[ ${host_os} == macos ]] {
sloppiness+=(
modules
clang_index_store
)
ccache --set-config=sloppiness=${(j:,:)sloppiness}
}
if (( ${+CI} )) { if (( ${+CI} )) {
ccache --set-config=cache_dir="${GITHUB_WORKSPACE:-${HOME}}/.ccache" ccache --set-config=cache_dir="${GITHUB_WORKSPACE:-${HOME}}/.ccache"
ccache --set-config=max_size="${CCACHE_SIZE:-500M}" ccache --set-config=max_size="${CCACHE_SIZE:-1G}"
ccache --set-config=compression=true
ccache -z > /dev/null ccache -z > /dev/null
} }
} else { } else {

View File

@ -13,50 +13,53 @@ if (( ! ${+target} )) {
pushd ${project_root} pushd ${project_root}
typeset -g QT_VERSION typeset -g QT_VERSION
read -r QT_VERSION <<< \
"$(jq -r --arg target "${target}" \ local -a apt_args=(
'.platformConfig[$target] | { qtVersion } | join(" ")' \ ${CI:+-y}
${project_root}/buildspec.json)" --no-install-recommends
)
if (( _loglevel == 0 )) apt_args+=(--quiet)
if (( ! (${skips[(Ie)all]} + ${skips[(Ie)deps]}) )) { if (( ! (${skips[(Ie)all]} + ${skips[(Ie)deps]}) )) {
log_info 'Installing obs build dependencies...' log_group 'Installing obs-studio build dependencies...'
sudo apt-get install -y \ local suffix
if [[ ${CPUTYPE} != "${target##*-}" ]] {
local -A arch_mappings=(
aarch64 arm64
x86_64 amd64
)
suffix=":${arch_mappings[${target##*-}]}"
sudo apt-get install ${apt_args} gcc-${${target##*-}//_/-}-linux-gnu g++-${${target##*-}//_/-}-linux-gnu
}
sudo add-apt-repository --yes ppa:obsproject/obs-studio
sudo apt update
sudo apt-get install ${apt_args} \
build-essential \ build-essential \
libcurl4-openssl-dev \
libavcodec-dev libavdevice-dev libavfilter-dev libavformat-dev libavutil-dev \
libswresample-dev libswscale-dev \
libjansson-dev \
libx11-xcb-dev \
libgles2-mesa-dev \ libgles2-mesa-dev \
libwayland-dev \ obs-studio
libpulse-dev
local -a _qt_packages=() local -a _qt_packages=()
if (( QT_VERSION == 5 )) { if (( QT_VERSION == 5 )) {
_qt_packages+=( _qt_packages+=(
qtbase5-dev qtbase5-dev${suffix}
libqt5svg5-dev libqt5svg5-dev${suffix}
qtbase5-private-dev qtbase5-private-dev${suffix}
libqt5x11extras5-dev libqt5x11extras5-dev${suffix}
)
} elif (( QT_VERSION == 6 )) {
_qt_packages+=(
qt6-base-dev
libqt6svg6-dev
qt6-base-private-dev
) )
} else { } else {
log_error "Unsupported Qt version '${QT_VERSION}' specified." _qt_packages+=(
return 2 qt6-base-dev${suffix}
libqt6svg6-dev${suffix}
qt6-base-private-dev${suffix}
)
} }
sudo apt-get install -y ${_qt_packages} sudo apt-get install ${apt_args} ${_qt_packages}
log_group
} }
local deps_version
read -r deps_version <<< \
"$(jq -r '.dependencies.prebuilt.version' ${buildspec_file})"
typeset -g OBS_DEPS_VERSION=${deps_version}

View File

@ -1,127 +0,0 @@
autoload -Uz log_error log_status log_info mkcd
if (( ! ${+commands[curl]} )) {
log_error 'curl not found. Please install curl.'
return 2
}
if (( ! ${+commands[jq]} )) {
log_error 'jq not found. Please install jq.'
return 2
}
if (( ! ${+project_root} )) {
log_error "'project_root' not set. Please set before running ${0}."
return 2
}
if (( ! ${+target} )) {
log_error "'target' not set. Please set before running ${0}."
return 2
}
local -a curl_opts=()
if (( ! ${+CI} )) {
curl_opts+=(--progress-bar)
} else {
curl_opts+=(--show-error --silent)
}
curl_opts+=(--location -O ${@})
pushd ${project_root}
local _qt_version
local _deployment_target
read -r _qt_version _deployment_target <<< \
"$(jq -r --arg target "${target}" \
'.platformConfig[$target] | { qtVersion, deploymentTarget } | join (" ")' \
${buildspec_file})"
typeset -g QT_VERSION=${_qt_version}
typeset -g DEPLOYMENT_TARGET=${_deployment_target}
if (( ! (${skips[(Ie)all]} + ${skips[(Ie)deps]}) )) {
mkdir -p ${project_root:h}/obs-build-dependencies
local dependency
local deps_version
local deps_baseurl
local deps_label
local deps_hash
local _filename
local _url
local _target
local artifact_checksum
for dependency ('prebuilt' "qt${QT_VERSION}") {
IFS=';' read -r deps_version deps_baseurl deps_label deps_hash <<< \
"$(jq -r --arg dependency "${dependency}" --arg target "${target}" \
'.dependencies[$dependency] | {version, baseUrl, "label", "hash": .hashes[$target]} | join(";")' \
${buildspec_file})"
if [[ -z "${deps_version}" ]] {
log_error "No ${dependency} spec found in ${buildspec_file}."
return 2
}
log_info "Setting up ${deps_label}..."
pushd ${project_root:h}/obs-build-dependencies
case ${dependency} {
prebuilt)
_filename="macos-deps-${deps_version}-${target##*-}.tar.xz"
_url="${deps_baseurl}/${deps_version}/${_filename}"
_target="plugin-deps-${deps_version}-qt${QT_VERSION}-${target##*-}"
typeset -g OBS_DEPS_VERSION=${deps_version}
;;
qt*)
if (( ${+CI} )) {
_filename="macos-deps-qt${QT_VERSION}-${deps_version}-universal.tar.xz"
deps_hash="$(jq -r --arg dependency "${dependency}" \
'.dependencies[$dependency].hashes["macos-universal"]' \
${buildspec_file})"
} else {
_filename="macos-deps-qt${QT_VERSION}-${deps_version}-${target##*-}.tar.xz"
}
_url="${deps_baseurl}/${deps_version}/${_filename}"
_target="plugin-deps-${deps_version}-qt${QT_VERSION}-${target##*-}"
;;
}
if [[ ! -f ${_filename} ]] {
log_debug "Running curl ${curl_opts} ${_url}"
curl ${curl_opts} ${_url} && \
log_status "Downloaded ${deps_label} for ${target}."
} else {
log_status "Found downloaded ${deps_label}"
}
read -r artifact_checksum _ <<< "$(sha256sum ${_filename})"
if [[ ${deps_hash} != ${artifact_checksum} ]] {
log_error "Checksum of downloaded ${deps_label} does not match specification.
Expected : ${deps_hash}
Actual : ${artifact_checksum}"
return 2
}
log_status "Checksum of downloaded ${deps_label} matches."
if (( ! (${skips[(Ie)all]} + ${skips[(Ie)unpack]}) )) {
mkdir -p ${_target} && pushd ${_target}
XZ_OPT=-T0 tar -xzf ../${_filename} && log_status "${deps_label} extracted."
popd
}
}
popd
pushd ${project_root:h}/obs-build-dependencies
xattr -r -d com.apple.quarantine *
log_status 'Removed quarantine flag from downloaded dependencies...'
popd
} else {
local deps_version
read -r deps_version <<< \
"$(jq -r '.dependencies.prebuilt.version' ${buildspec_file})"
typeset -g OBS_DEPS_VERSION=${deps_version}
}

View File

@ -1,122 +0,0 @@
autoload -Uz log_error log_info log_status
if (( ! ${+buildspec_file} )) {
log_error "'buildspec_file' not set. Please set before running ${0}."
return 2
}
if (( ! ${+commands[git]} )) {
log_error 'git not found. Please install git.'
return 2
}
if (( ! ${+commands[jq]} )) {
log_error 'jq not found. Please install jq.'
return 2
}
if (( ! ${+project_root} )) {
log_error "'project_root' not set. Please set before running ${0}."
return 2
}
if (( ! ${+target} )) {
log_error "'target' not set. Please set before running ${0}."
return 2
}
log_info 'Setting up OBS-Studio...'
local obs_version
local obs_repo
local obs_branch
local obs_hash
read -r obs_version obs_repo obs_branch obs_hash <<< \
"$(jq -r --arg key "obs-studio" \
'.dependencies[$key] | {version, repository, branch, hash} | join(" ")' \
${buildspec_file})"
if [[ -z ${obs_version} ]] {
log_error "No obs-studio version found in buildspec.json"
return 2
}
pushd
mkcd ${project_root:h}/obs-studio
if (( ! (${skips[(Ie)all]} + ${skips[(Ie)unpack]}) )) {
if [[ -d .git ]] {
git config advice.detachedHead false
git config remote.pluginbuild.url "${obs_repo:-https://github.com/obsproject/obs-studio.git}"
git config remote.pluginbuild.fetch "+refs/heads/${obs_branch:-master}:refs/remotes/origin/${obs_branch:-master}"
git rev-parse -q --verify "${obs_hash}^{commit}" > /dev/null || git fetch pluginbuild
git checkout ${obs_branch:-master} -B ${product_name}
git reset --hard "${obs_hash}"
log_status 'Found existing obs-studio repository.'
} else {
git clone "${obs_repo:-https://github.com/obsproject/obs-studio.git}" "${PWD}"
git config advice.detachedHead false
git checkout -f "${obs_hash}" --
git checkout ${obs_branch:-master} -b ${product_name}
log_status 'obs-studio checked out.'
}
git submodule foreach --recursive git submodule sync
git submodule update --init --recursive
}
if (( ! (${skips[(Ie)all]} + ${skips[(Ie)build]}) )) {
log_info 'Configuring obs-studio...'
local -a cmake_args=(
-DCMAKE_BUILD_TYPE=${BUILD_CONFIG:-Release}
-DQT_VERSION=${QT_VERSION}
-DENABLE_PLUGINS=OFF
-DENABLE_UI=OFF
-DENABLE_SCRIPTING=OFF
-DCMAKE_INSTALL_PREFIX="${project_root:h}/obs-build-dependencies/plugin-deps-${OBS_DEPS_VERSION}-qt${QT_VERSION}-${target##*-}"
-DCMAKE_PREFIX_PATH="${project_root:h}/obs-build-dependencies/plugin-deps-${OBS_DEPS_VERSION}-qt${QT_VERSION}-${target##*-}"
)
if (( _loglevel == 0 )) cmake_args+=(-Wno_deprecated -Wno-dev --log-level=ERROR)
if (( _loglevel > 2 )) cmake_args+=(--debug-output)
local num_procs
case ${target} {
macos-*)
autoload -Uz read_codesign
if (( ${+CODESIGN} )) {
read_codesign
}
cmake_args+=(
-DCMAKE_OSX_ARCHITECTURES=${${target##*-}//universal/x86_64;arm64}
-DCMAKE_OSX_DEPLOYMENT_TARGET=${DEPLOYMENT_TARGET:-10.15}
-DOBS_CODESIGN_LINKER=ON
-DOBS_BUNDLE_CODESIGN_IDENTITY="${CODESIGN_IDENT:--}"
)
num_procs=$(( $(sysctl -n hw.ncpu) + 1 ))
;;
linux-*)
cmake_args+=(
-DENABLE_PIPEWIRE=OFF
)
num_procs=$(( $(nproc) + 1 ))
;;
}
log_debug "Attempting to configure OBS with CMake arguments: ${cmake_args}"
cmake -S . -B plugin_build_${target##*-} -G ${generator} ${cmake_args}
log_info 'Building libobs and obs-frontend-api...'
local -a cmake_args=()
if (( _loglevel > 1 )) cmake_args+=(--verbose)
if [[ ${generator} == 'Unix Makefiles' ]] cmake_args+=(--parallel ${num_procs})
cmake --build plugin_build_${target##*-} --config ${BUILD_CONFIG:-Release} ${cmake_args} -t obs-frontend-api
cmake --install plugin_build_${target##*-} --config ${BUILD_CONFIG:-Release} --component obs_libraries ${cmake_args}
}
popd

282
.github/workflows/build-project.yaml vendored Normal file
View File

@ -0,0 +1,282 @@
name: Build Project
on:
workflow_call:
outputs:
pluginName:
description: 'Project name detected by parsing build spec file'
value: ${{ jobs.check-event.outputs.pluginName }}
jobs:
check-event:
name: Check GitHub Event Data 🔎
runs-on: ubuntu-22.04
defaults:
run:
shell: bash
outputs:
package: ${{ steps.setup.outputs.package }}
codesign: ${{ steps.setup.outputs.codesign }}
notarize: ${{ steps.setup.outputs.notarize }}
config: ${{ steps.setup.outputs.config }}
commitHash: ${{ steps.setup.outputs.commitHash }}
pluginName: ${{ steps.setup.outputs.pluginName }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Check Event Data ☑️
id: setup
env:
GH_TOKEN: ${{ github.token }}
run: |
: Check Event Data ☑️
if [[ "${RUNNER_DEBUG}" ]]; then set -x; fi
case "${GITHUB_EVENT_NAME}" in
pull_request)
config_data=('codesign:false' 'notarize:false' 'package:false' 'config:RelWithDebInfo')
if gh pr view ${{ github.event.number }} --json labels \
| jq -e -r '.labels[] | select(.name == "Seeking Testers")' > /dev/null; then
config_data[0]='codesign:true'
config_data[2]='package:true'
fi
;;
push)
config_data=('codesign:true' 'notarize:false' 'package:true' 'config:RelWithDebInfo')
if [[ ${GITHUB_REF_NAME} =~ [0-9]+.[0-9]+.[0-9]+(-(rc|beta).+)? ]]; then
config_data[1]='notarize:true'
config_data[3]='config:Release'
fi
;;
workflow_dispatch)
config_data=('codesign:true' 'notarize:false' 'package:false' 'config:RelWithDebInfo')
;;
schedule)
config_data=('codesign:true' 'notarize:false' 'package:true' 'config:RelWithDebInfo')
;;
*) ;;
esac
for config in "${config_data[@]}"; do
IFS=':' read -r key value <<< "${config}"
echo "${key}=${value}" >> $GITHUB_OUTPUT
done
echo "commitHash=${GITHUB_SHA:0:9}" >> $GITHUB_OUTPUT
plugin_name="$(grep 'name' buildspec.json | sed -E -e 's/^.+"name":[^"]+"(.+)",?$/\1/g')"
plugin_display_name="$(grep 'displayName' buildspec.json | sed -E -e 's/^.+"displayName":[^"]+"(.+)",?$/\1/g' || echo "")"
if [[ "${plugin_display_name}" ]]; then
echo "pluginName=${plugin_display_name}" >> $GITHUB_OUTPUT
else
echo "pluginName=${plugin_name}" >> $GITHUB_OUTPUT
fi
macos-build:
name: Build for macOS 🍏
runs-on: macos-14
needs: check-event
defaults:
run:
shell: zsh --no-rcs --errexit --pipefail {0}
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
- name: Set Up Environment 🔧
id: setup
run: |
: Set Up Environment 🔧
if (( ${+RUNNER_DEBUG} )) setopt XTRACE
print '::group::Enable Xcode 15.2'
sudo xcode-select --switch /Applications/Xcode_15.2.app/Contents/Developer
print '::endgroup::'
print '::group::Clean Homebrew Environment'
local -a to_remove=()
if (( #to_remove )) brew uninstall --ignore-dependencies ${to_remove}
print '::endgroup::'
local product_name
local product_version
read -r product_name product_version <<< \
"$(jq -r '. | {name, version} | join(" ")' buildspec.json)"
print "pluginName=${product_name}" >> $GITHUB_OUTPUT
print "pluginVersion=${product_version}" >> $GITHUB_OUTPUT
- uses: actions/cache@v4
id: ccache-cache
with:
path: ${{ github.workspace }}/.ccache
key: ${{ runner.os }}-ccache-${{ needs.check-event.outputs.config }}
restore-keys: |
${{ runner.os }}-ccache-
- name: Set Up Codesigning 🔑
uses: ./.github/actions/setup-macos-codesigning
if: fromJSON(needs.check-event.outputs.codesign)
id: codesign
with:
codesignIdentity: ${{ secrets.APPLE_TEAM }}
installerIdentity: ${{ secrets.APPLE_TEAM }}
codesignCertificate: ${{ secrets.APPLE_CSC_LINK }}
certificatePassword: ${{ secrets.APPLE_CSC_PASSWORD }}
keychainPassword: ${{ secrets.MACOS_KEYCHAIN_PASSWORD }}
provisioningProfile: ${{ secrets.MACOS_SIGNING_PROVISIONING_PROFILE }}
notarizationUser: ${{ secrets.APPLE_EMAIL }}
notarizationPassword: ${{ secrets.APPLE_PASSWORD }}
- name: Build Plugin 🧱
uses: ./.github/actions/build-plugin
with:
target: macos-universal
config: ${{ needs.check-event.outputs.config }}
codesign: ${{ fromJSON(needs.check-event.outputs.codesign) }}
codesignIdent: ${{ steps.codesign.outputs.codesignIdent }}
- name: Package Plugin 📀
uses: ./.github/actions/package-plugin
with:
target: macos-universal
config: ${{ needs.check-event.outputs.config }}
package: ${{ fromJSON(needs.check-event.outputs.package) }}
codesign: ${{ fromJSON(needs.check-event.outputs.codesign) && fromJSON(steps.codesign.outputs.haveCodesignIdent) }}
codesignIdent: ${{ steps.codesign.outputs.codesignIdent }}
installerIdent: ${{ steps.codesign.outputs.installerIdent }}
codesignTeam: ${{ steps.codesign.outputs.codesignTeam }}
notarize: ${{ fromJSON(needs.check-event.outputs.notarize) && fromJSON(steps.codesign.outputs.haveNotarizationUser) }}
codesignUser: ${{ secrets.APPLE_EMAIL }}
codesignPass: ${{ secrets.APPLE_PASSWORD }}
- name: Upload Artifacts 📡
uses: actions/upload-artifact@v4
with:
name: ${{ steps.setup.outputs.pluginName }}-${{ steps.setup.outputs.pluginVersion }}-macos-universal-${{ needs.check-event.outputs.commitHash }}
path: ${{ github.workspace }}/release/${{ steps.setup.outputs.pluginName }}-${{ steps.setup.outputs.pluginVersion }}-macos-universal.*
- name: Upload Debug Symbol Artifacts 🪲
uses: actions/upload-artifact@v4
if: ${{ needs.check-event.outputs.config == 'Release' }}
with:
name: ${{ steps.setup.outputs.pluginName }}-${{ steps.setup.outputs.pluginVersion }}-macos-universal-${{ needs.check-event.outputs.commitHash }}-dSYMs
path: ${{ github.workspace }}/release/${{ steps.setup.outputs.pluginName }}-${{ steps.setup.outputs.pluginVersion }}-macos-universal-dSYMs.*
ubuntu-build:
name: Build for Ubuntu 🐧
runs-on: ubuntu-22.04
needs: check-event
if: false
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
- name: Set Up Environment 🔧
id: setup
run: |
: Set Up Environment 🔧
if [[ "${RUNNER_DEBUG}" ]]; then set -x; fi
read -r product_name product_version <<< \
"$(jq -r '. | {name, version} | join(" ")' buildspec.json)"
echo "pluginName=${product_name}" >> $GITHUB_OUTPUT
echo "pluginVersion=${product_version}" >> $GITHUB_OUTPUT
- uses: actions/cache@v4
id: ccache-cache
with:
path: ${{ github.workspace }}/.ccache
key: ${{ runner.os }}-ccache-x86_64-${{ needs.check-event.outputs.config }}
restore-keys: |
${{ runner.os }}-ccache-x86_64-
- name: Set up Homebrew 🍺
uses: Homebrew/actions/setup-homebrew@master
- name: Build Plugin 🧱
uses: ./.github/actions/build-plugin
with:
target: x86_64
config: ${{ needs.check-event.outputs.config }}
- name: Package Plugin 📀
uses: ./.github/actions/package-plugin
with:
package: ${{ fromJSON(needs.check-event.outputs.package) }}
target: x86_64
config: ${{ needs.check-event.outputs.config }}
- name: Upload Source Tarball 🗜️
uses: actions/upload-artifact@v4
with:
name: ${{ steps.setup.outputs.pluginName }}-${{ steps.setup.outputs.pluginVersion }}-sources-${{ needs.check-event.outputs.commitHash }}
path: ${{ github.workspace }}/release/${{ steps.setup.outputs.pluginName }}-${{ steps.setup.outputs.pluginVersion }}-source.*
- name: Upload Artifacts 📡
uses: actions/upload-artifact@v4
with:
name: ${{ steps.setup.outputs.pluginName }}-${{ steps.setup.outputs.pluginVersion }}-ubuntu-22.04-x86_64-${{ needs.check-event.outputs.commitHash }}
path: ${{ github.workspace }}/release/${{ steps.setup.outputs.pluginName }}-${{ steps.setup.outputs.pluginVersion }}-x86_64*.*
- name: Upload debug symbol artifacts 🪲
uses: actions/upload-artifact@v4
if: ${{ fromJSON(needs.check-event.outputs.package) }}
with:
name: ${{ steps.setup.outputs.pluginName }}-${{ steps.setup.outputs.pluginVersion }}-ubuntu-22.04-x86_64-${{ needs.check-event.outputs.commitHash }}-dbgsym
path: ${{ github.workspace }}/release/${{ steps.setup.outputs.pluginName }}-${{ steps.setup.outputs.pluginVersion }}-x86_64*-dbgsym.ddeb
windows-build:
name: Build for Windows 🪟
runs-on: windows-2022
needs: check-event
defaults:
run:
shell: pwsh
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
- name: Set Up Environment 🔧
id: setup
run: |
# Set Up Environment 🔧
if ( $Env:RUNNER_DEBUG -ne $null ) {
Set-PSDebug -Trace 1
}
$BuildSpec = Get-Content -Path buildspec.json -Raw | ConvertFrom-Json
$ProductName = $BuildSpec.name
$ProductVersion = $BuildSpec.version
"pluginName=${ProductName}" >> $env:GITHUB_OUTPUT
"pluginVersion=${ProductVersion}" >> $env:GITHUB_OUTPUT
- name: Build Plugin 🧱
uses: ./.github/actions/build-plugin
with:
target: x64
config: ${{ needs.check-event.outputs.config }}
- name: Package Plugin 📀
uses: ./.github/actions/package-plugin
with:
target: x64
config: ${{ needs.check-event.outputs.config }}
package: ${{ fromJSON(needs.check-event.outputs.package) }}
- name: Upload Artifacts 📡
uses: actions/upload-artifact@v4
with:
name: ${{ steps.setup.outputs.pluginName }}-${{ steps.setup.outputs.pluginVersion }}-windows-x64-${{ needs.check-event.outputs.commitHash }}
path: ${{ github.workspace }}/release/${{ steps.setup.outputs.pluginName }}-${{ steps.setup.outputs.pluginVersion }}-windows-x64*.*

View File

@ -1,317 +0,0 @@
name: build obs plugin
on: workflow_dispatch
env:
PLUGIN_NAME: aitum-multistream
OBS_VERSION: 30.0.0
jobs:
macos:
name: macOS
runs-on: macos-12
strategy:
fail-fast: false
matrix:
arch: [x86_64, arm64, universal]
outputs:
commitHash: ${{ steps.setup.outputs.commitHash }}
env:
CODESIGN_IDENT: '-'
CODESIGN_IDENT_INSTALLER: ''
MACOSX_DEPLOYMENT_TARGET: '11.0'
defaults:
run:
shell: zsh {0}
steps:
- name: Checkout
uses: actions/checkout@v4.1.1
with:
path: plugin
submodules: recursive
- name: Checkout obs-studio
uses: actions/checkout@v4.1.1
with:
repository: 'obsproject/obs-studio'
path: obs-studio
fetch-depth: 0
submodules: recursive
- name: Setup Environment
id: setup
working-directory: ${{ github.workspace }}/plugin
run: |
## SETUP ENVIRONMENT SCRIPT
print '::group::Clean Homebrew Environment'
typeset -a to_remove=()
for formula (speexdsp curl php) {
if [[ -d ${HOMEBREW_PREFIX}/opt/${formula} ]] to_remove+=(${formula})
}
if (( #to_remove > 0 )) brew uninstall --ignore-dependencies ${to_remove}
print '::endgroup::'
print '::group::Set up code signing'
if [[ '${{ secrets.MACOS_SIGNING_APPLICATION_IDENTITY }}' != '' && \
'${{ secrets.MACOS_SIGNING_INSTALLER_IDENTITY }}' != '' && \
'${{ secrets.MACOS_SIGNING_CERT }}' != '' ]] {
print 'haveCodesignIdent=true' >> $GITHUB_OUTPUT
} else {
print 'haveCodesignIdent=false' >> $GITHUB_OUTPUT
}
if [[ '${{ secrets.MACOS_NOTARIZATION_USERNAME }}' != '' && \
'${{ secrets.MACOS_NOTARIZATION_PASSWORD }}' != '' ]] {
print 'haveNotarizationUser=true' >> $GITHUB_OUTPUT
} else {
print 'haveNotarizationUser=false' >> $GITHUB_OUTPUT
}
print '::endgroup::'
print "ccacheDate=$(date +"%Y-%m-%d")" >> $GITHUB_OUTPUT
print "commitHash=${"$(git rev-parse HEAD)"[0,9]}" >> $GITHUB_OUTPUT
- name: Restore Compilation Cache
id: ccache-cache
uses: actions/cache@v4.0.0
with:
path: ${{ github.workspace }}/.ccache
key: macos-${{ matrix.arch }}-ccache-plugin-${{ steps.setup.outputs.ccacheDate }}
restore-keys: |
macos-${{ matrix.arch }}-ccache-plugin-
- name: Check for GitHub Labels
id: seekingTesters
if: ${{ github.event_name == 'pull_request' }}
run: |
if [[ -n "$(curl -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" -s "${{ github.event.pull_request.url }}" | jq -e '.labels[] | select(.name == "Seeking Testers")')" ]] {
print 'found=true' >> $GITHUB_OUTPUT
} else {
print 'found=false' >> $GITHUB_OUTPUT
}
- name: Install Apple Developer Certificate
if: ${{ github.event_name != 'pull_request' && steps.setup.outputs.haveCodesignIdent == 'true' }}
uses: apple-actions/import-codesign-certs@253ddeeac23f2bdad1646faac5c8c2832e800071
with:
keychain-password: ${{ github.run_id }}
p12-file-base64: ${{ secrets.MACOS_SIGNING_CERT }}
p12-password: ${{ secrets.MACOS_SIGNING_CERT_PASSWORD }}
- name: Set Signing Identity
if: ${{ github.event_name != 'pull_request' && steps.setup.outputs.haveCodesignIdent == 'true' }}
run: |
print "CODESIGN_IDENT=${{ secrets.MACOS_SIGNING_APPLICATION_IDENTITY }}" >> $GITHUB_ENV
print "CODESIGN_IDENT_INSTALLER=${{ secrets.MACOS_SIGNING_INSTALLER_IDENTITY }}" >> $GITHUB_ENV
- name: Build Plugin
uses: ./plugin/.github/actions/build-plugin
with:
workingDirectory: ${{ github.workspace }}/plugin
target: ${{ matrix.arch }}
config: RelWithDebInfo
codesign: 'true'
codesignIdent: ${{ env.CODESIGN_IDENT }}
- name: Package Plugin
uses: ./plugin/.github/actions/package-plugin
with:
workingDirectory: ${{ github.workspace }}/plugin
target: ${{ matrix.arch }}
config: RelWithDebInfo
codesign: ${{ github.event_name != 'pull_request' && steps.setup.outputs.haveCodesignIdent == 'true' }}
notarize: ${{ startsWith(github.ref, 'refs/tags/') && github.event_name != 'pull_request' && steps.setup.outputs.haveNotarizationUser == 'true' }}
codesignIdent: ${{ env.CODESIGN_IDENT }}
installerIdent: ${{ env.CODESIGN_IDENT_INSTALLER }}
codesignUser: ${{ secrets.MACOS_NOTARIZATION_USERNAME }}
codesignPass: ${{ secrets.MACOS_NOTARIZATION_PASSWORD }}
- name: Upload Build Artifact
uses: actions/upload-artifact@v4.3.1
with:
name: ${{ env.PLUGIN_NAME }}-macos-${{ matrix.arch }}-${{ steps.setup.outputs.commitHash }}
path: ${{ github.workspace }}/plugin/release/${{ env.PLUGIN_NAME }}-*-macos-${{ matrix.arch }}.pkg
linux-in-tree:
name: 'Linux'
runs-on: ${{ matrix.ubuntu }}
strategy:
fail-fast: false
matrix:
ubuntu: ['ubuntu-22.04']
steps:
- name: Checkout
uses: actions/checkout@v4.1.1
with:
repository: obsproject/obs-studio
ref: ${{ env.OBS_VERSION }}
submodules: 'recursive'
- name: "Checkout plugin"
uses: actions/checkout@v4.1.1
with:
path: UI/frontend-plugins/${{ env.PLUGIN_NAME }}
- name: Add plugin to obs cmake
shell: bash
run: echo "add_subdirectory(${{ env.PLUGIN_NAME }})" >> UI/frontend-plugins/CMakeLists.txt
- name: Fetch Git Tags
run: git fetch --prune --tags --unshallow
- name: 'Install dependencies'
run: CI/linux/01_install_dependencies.sh --disable-pipewire
- name: 'Configure'
shell: bash
run: |
mkdir ./build
cmake -S . -B "./build" -G Ninja -DCMAKE_BUILD_TYPE="RelWithDebInfo" -DLINUX_PORTABLE=OFF -DENABLE_AJA=OFF -DENABLE_NEW_MPEGTS_OUTPUT=OFF -DBUILD_CAPTIONS=OFF -DWITH_RTMPS=OFF -DBUILD_BROWSER=OFF -DBUILD_VIRTUALCAM=OFF -DBUILD_VST=OFF -DENABLE_PIPEWIRE=OFF -DENABLE_SCRIPTING=OFF
- name: 'Build'
shell: bash
run: |
cmake --build "./build"
- name: 'Package'
shell: bash
run: |
FILE_DATE=$(date +%Y-%m-%d)
FILE_NAME=${{ env.PLUGIN_NAME }}-$FILE_DATE-${{ github.sha }}-${{ matrix.ubuntu }}.tar.gz
echo "FILE_NAME=${FILE_NAME}" >> $GITHUB_ENV
mkdir -p ./${{ env.PLUGIN_NAME }}/bin/64bit/
mv ./build/UI/frontend-plugins/${{ env.PLUGIN_NAME }}/${{ env.PLUGIN_NAME }}.so ./${{ env.PLUGIN_NAME }}/bin/64bit/${{ env.PLUGIN_NAME }}.so
mv ./UI/frontend-plugins/${{ env.PLUGIN_NAME }}/data ./${{ env.PLUGIN_NAME }}/data
tar -cvzf "${FILE_NAME}" ${{ env.PLUGIN_NAME }}
- name: 'Publish'
uses: actions/upload-artifact@v4.3.1
with:
name: '${{ env.FILE_NAME }}'
path: '*.tar.gz'
windows-build:
name: 'Windows Build'
runs-on: [windows-latest]
strategy:
fail-fast: false
matrix:
target: [x64]
include:
- target: x64
cmake_build: 'x64'
deps_ext: '64'
env:
QT_VERSION: '6.3.1'
CMAKE_GENERATOR: "Visual Studio 17 2022"
CMAKE_SYSTEM_VERSION: "10.0.18363.657"
WINDOWS_DEPS_VERSION: '2023-11-03'
steps:
- name: Add msbuild to PATH
uses: microsoft/setup-msbuild@v2
- name: Checkout obs
uses: actions/checkout@v4.1.1
with:
repository: obsproject/obs-studio
ref: ${{ env.OBS_VERSION }}
submodules: 'recursive'
- name: Checkout plugin
uses: actions/checkout@v4.1.1
with:
path: UI/frontend-plugins/${{ env.PLUGIN_NAME}}
- name: Add plugin to obs cmake
shell: cmd
run: echo add_subdirectory(${{ env.PLUGIN_NAME }}) >> UI/frontend-plugins/CMakeLists.txt
- name: Fetch Git Tags
run: git fetch --prune --tags --unshallow
- name: 'Install prerequisite: QT'
run: |
curl -kLO https://github.com/obsproject/obs-deps/releases/download/${{ env.WINDOWS_DEPS_VERSION }}/windows-deps-qt6-${{ env.WINDOWS_DEPS_VERSION }}-${{ matrix.target }}.zip -f --retry 5 -C -
7z x windows-deps-qt6-${{ env.WINDOWS_DEPS_VERSION }}-${{ matrix.target }}.zip -o"${{ github.workspace }}/cmbuild/deps" -aoa
- name: 'Install prerequisite: Pre-built dependencies'
run: |
curl -kLO https://github.com/obsproject/obs-deps/releases/download/${{ env.WINDOWS_DEPS_VERSION }}/windows-deps-${{ env.WINDOWS_DEPS_VERSION }}-${{ matrix.target }}.zip -f --retry 5 -C -
7z x windows-deps-${{ env.WINDOWS_DEPS_VERSION }}-${{ matrix.target }}.zip -o"${{ github.workspace }}/cmbuild/deps" -aoa
- name: Configure
run: |
mkdir ./package
mkdir ./installer
mkdir ./installer/media
mkdir ./build
cmake -S . -B "${{ github.workspace }}/build" -G"${{ env.CMAKE_GENERATOR }}" -DCMAKE_PREFIX_PATH:PATH="${{ github.workspace }}/cmbuild/deps" -A"${{ matrix.cmake_build }}" -DCMAKE_SYSTEM_VERSION="${{ env.CMAKE_SYSTEM_VERSION }}" -DBUILD_BROWSER=false -DBUILD_VST=false -DBUILD_VIRTUALCAM=false -DBUILD_CAPTIONS=false -DCOMPILE_D3D12_HOOK=false -DENABLE_SCRIPTING=false -DDepsPath="${{ github.workspace }}/cmbuild/deps" -DDepsPath${{ matrix.deps_ext }}="${{ github.workspace }}/cmbuild/deps" -DQTDIR="${{ github.workspace }}/cmbuild/deps/qt6" -DCOPIED_DEPENDENCIES=FALSE -DCOPY_DEPENDENCIES=TRUE -DENABLE_PLUGINS=FALSE -DDISABLE_PLUGINS=TRUE
- name: 'Build'
run: msbuild /m /p:Configuration=RelWithDebInfo .\build\obs-studio.sln
- name: Package
if: success()
run: |
$env:FILE_NAME="${{ env.PLUGIN_NAME }}-${{ github.sha }}-windows-${{ matrix.target }}"
echo "FILE_NAME=${env:FILE_NAME}" >> ${env:GITHUB_ENV}
robocopy .\build\rundir\RelWithDebInfo\obs-plugins\${{ matrix.deps_ext }}bit\ .\package\obs-plugins\${{ matrix.deps_ext }}bit ${{ env.PLUGIN_NAME }}.* /E /XF .gitignore
robocopy .\build\rundir\RelWithDebInfo\data\obs-plugins\${{ env.PLUGIN_NAME }}\ .\package\data\obs-plugins\${{ env.PLUGIN_NAME }}\ /E /XF .gitignore
copy .\build\UI\frontend-plugins\${{ env.PLUGIN_NAME }}\installer.iss .\installer\installer.iss
robocopy .\UI\frontend-plugins\${{ env.PLUGIN_NAME}}\media\ .\installer\media\ /E /XF .gitignore
exit 0
- name: Publish zip
if: success()
uses: actions/upload-artifact@v4.3.1
with:
name: '${{ env.FILE_NAME }}'
path: package/*
- name: Publish Installer Files
if: success() && matrix.target == 'x64'
uses: actions/upload-artifact@v4.3.1
with:
name: 'installer-files'
path: installer/*
windows-package:
name: 'Windows Package'
runs-on: [windows-latest]
needs: [windows-build]
steps:
- name: Init
if: success()
run: |
mkdir ./package
$env:FILE_DATE=(Get-Date -UFormat "%F")
$env:FILE_NAME="${{ env.PLUGIN_NAME }}-${env:FILE_DATE}-${{ github.sha }}-windows"
echo "FILE_NAME=${env:FILE_NAME}" >> ${env:GITHUB_ENV}
$env:FILE_NAME_X64="${{ env.PLUGIN_NAME }}-${{ github.sha }}-windows-x64"
echo "FILE_NAME_X64=${env:FILE_NAME_X64}" >> ${env:GITHUB_ENV}
- name: Retrieve x64 build
uses: actions/download-artifact@v4.1.2
with:
name: '${{ env.FILE_NAME_X64 }}'
path: ./package
- name: Retrieve installer files
uses: actions/download-artifact@v4.1.2
with:
name: 'installer-files'
path: .
- name: Create Code Signing Certificate
if: success() && github.event_name != 'pull_request'
run: |
New-Item -ItemType directory -Path certificate
Set-Content -Path certificate\certificate.txt -Value '${{ secrets.WINDOWS_CSC_LINK }}'
certutil -decode certificate\certificate.txt certificate\certificate.pfx
- name: Code Sign 64
if: success() && github.event_name != 'pull_request'
run: |
& 'C:/Program Files (x86)/Windows Kits/10/bin/10.0.20348.0/x64/signtool.exe' sign /f certificate\certificate.pfx /p '${{ secrets.WINDOWS_CSC_PASS }}' /t http://timestamp.comodoca.com/authenticode .\package\obs-plugins\64bit\${{ env.PLUGIN_NAME }}.dll
- name: Publish zip
if: success()
uses: actions/upload-artifact@v4.3.1
with:
name: '${{ env.FILE_NAME }}'
path: package/*
- name: "Package Installer (Prereqs)"
run: |
curl "-kL" "https://files.jrsoftware.org/is/6/innosetup-6.0.3.exe" "-f" "--retry" "5" "-o" "inno.exe"
.\inno.exe /VERYSILENT /SP- /SUPPRESSMSGBOXES /NORESTART
- name: "Package Installer (Compile)"
run: |
& 'C:\Program Files (x86)\Inno Setup 6\ISCC.exe' /Qp ".\installer.iss"
- name: Code Sign Installer
if: success() && github.event_name != 'pull_request'
run: |
& 'C:/Program Files (x86)/Windows Kits/10/bin/10.0.20348.0/x64/signtool.exe' sign /f certificate\certificate.pfx /p '${{ secrets.WINDOWS_CSC_PASS }}' /t http://timestamp.comodoca.com/authenticode .\package\${{ env.PLUGIN_NAME }}-installer.exe
- name: Publish installer
if: success()
uses: actions/upload-artifact@v4.3.1
with:
name: '${{ env.FILE_NAME }}-installer'
path: package/*.exe
- name: Remove temp artifacts
uses: geekyeggo/delete-artifact@v4.1.0
with:
name: "${{ env.FILE_NAME_X64 }}\ninstaller-files"

15
.github/workflows/check-format.yaml vendored Normal file
View File

@ -0,0 +1,15 @@
name: Check Code Formatting 🛠️
on:
workflow_call:
jobs:
clang-format:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: clang-format check 🐉
id: clang-format
uses: ./.github/actions/run-clang-format
with:
failCondition: error

18
.github/workflows/dispatch.yaml vendored Normal file
View File

@ -0,0 +1,18 @@
name: Dispatch
run-name: Dispatched Repository Actions - ${{ inputs.job }} ⌛️
on:
workflow_dispatch:
inputs:
job:
description: Dispatch job to run
required: true
type: choice
options:
- build
permissions:
contents: write
jobs:
check-and-build:
if: inputs.job == 'build'
uses: ./.github/workflows/build-project.yaml
secrets: inherit

27
.github/workflows/pr-pull.yaml vendored Normal file
View File

@ -0,0 +1,27 @@
name: Pull Request
run-name: ${{ github.event.pull_request.title }} pull request run 🚀
on:
workflow_dispatch:
pull_request:
paths-ignore:
- '**.md'
branches: [master, main]
types: [ opened, synchronize, reopened ]
permissions:
contents: read
concurrency:
group: '${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}'
cancel-in-progress: true
jobs:
check-format:
name: Check Formatting 🔍
uses: ./.github/workflows/check-format.yaml
permissions:
contents: read
build-project:
name: Build Project 🧱
uses: ./.github/workflows/build-project.yaml
secrets: inherit
permissions:
contents: read

122
.github/workflows/push.yaml vendored Normal file
View File

@ -0,0 +1,122 @@
name: Push to master
run-name: ${{ github.ref_name }} push run 🚀
on:
push:
branches:
- master
- main
- 'release/**'
tags:
- '*'
permissions:
contents: write
concurrency:
group: '${{ github.workflow }} @ ${{ github.ref }}'
cancel-in-progress: ${{ github.ref_type == 'tag' }}
jobs:
check-format:
name: Check Formatting 🔍
if: github.ref_name == 'master'
uses: ./.github/workflows/check-format.yaml
permissions:
contents: read
build-project:
name: Build Project 🧱
uses: ./.github/workflows/build-project.yaml
secrets: inherit
permissions:
contents: read
create-release:
name: Create Release 🛫
if: github.ref_type == 'tag'
runs-on: ubuntu-22.04
needs: build-project
defaults:
run:
shell: bash
steps:
- name: Check Release Tag ☑️
id: check
run: |
: Check Release Tag ☑️
if [[ "${RUNNER_DEBUG}" ]]; then set -x; fi
shopt -s extglob
case "${GITHUB_REF_NAME}" in
+([0-9]).+([0-9]).+([0-9]) )
echo 'validTag=true' >> $GITHUB_OUTPUT
echo 'prerelease=false' >> $GITHUB_OUTPUT
echo "version=${GITHUB_REF_NAME}" >> $GITHUB_OUTPUT
;;
+([0-9]).+([0-9]).+([0-9])-@(beta|rc)*([0-9]) )
echo 'validTag=true' >> $GITHUB_OUTPUT
echo 'prerelease=true' >> $GITHUB_OUTPUT
echo "version=${GITHUB_REF_NAME}" >> $GITHUB_OUTPUT
;;
*) echo 'validTag=false' >> $GITHUB_OUTPUT ;;
esac
- name: Download Build Artifacts 📥
uses: actions/download-artifact@v4
if: fromJSON(steps.check.outputs.validTag)
id: download
- name: Rename Files 🏷️
if: fromJSON(steps.check.outputs.validTag)
run: |
: Rename Files 🏷️
if [[ "${RUNNER_DEBUG}" ]]; then set -x; fi
shopt -s extglob
shopt -s nullglob
root_dir="$(pwd)"
commit_hash="${GITHUB_SHA:0:9}"
variants=(
'windows-x64;zip|exe'
'macos-universal;tar.xz|pkg'
'ubuntu-22.04-x86_64;tar.xz|deb|ddeb'
'sources;tar.xz'
)
for variant_data in "${variants[@]}"; do
IFS=';' read -r variant suffix <<< "${variant_data}"
candidates=(*-${variant}-${commit_hash}/@(*|*-dbgsym).@(${suffix}))
for candidate in "${candidates[@]}"; do
mv "${candidate}" "${root_dir}"
done
done
- name: Generate Checksums 🪪
if: fromJSON(steps.check.outputs.validTag)
run: |
: Generate Checksums 🪪
if [[ "${RUNNER_DEBUG}" ]]; then set -x; fi
shopt -s extglob
echo "### Checksums" > ${{ github.workspace }}/CHECKSUMS.txt
for file in ${{ github.workspace }}/@(*.exe|*.deb|*.ddeb|*.pkg|*.tar.xz|*.zip); do
echo " ${file##*/}: $(sha256sum "${file}" | cut -d " " -f 1)" >> ${{ github.workspace }}/CHECKSUMS.txt
done
- name: Create Release 🛫
if: fromJSON(steps.check.outputs.validTag)
id: create_release
uses: softprops/action-gh-release@d4e8205d7e959a9107da6396278b2f1f07af0f9b
with:
draft: true
prerelease: ${{ fromJSON(steps.check.outputs.prerelease) }}
tag_name: ${{ steps.check.outputs.version }}
name: ${{ needs.build-project.outputs.pluginName }} ${{ steps.check.outputs.version }}
body_path: ${{ github.workspace }}/CHECKSUMS.txt
files: |
${{ github.workspace }}/*.exe
${{ github.workspace }}/*.zip
${{ github.workspace }}/*.pkg
${{ github.workspace }}/*.deb
${{ github.workspace }}/*.ddeb
${{ github.workspace }}/*.tar.xz

View File

@ -1,26 +1,53 @@
# --- Detect if the plugin is build out of tree or not --- # --- Detect if the plugin is build out of tree or not ---
if(CMAKE_PROJECT_NAME STREQUAL "obs-studio") if(CMAKE_PROJECT_NAME STREQUAL "obs-studio")
set(BUILD_OUT_OF_TREE OFF) set(BUILD_OUT_OF_TREE OFF)
if(OBS_CMAKE_VERSION VERSION_GREATER_EQUAL 3.0.0) set(OBS_FRONTEND_API_NAME "obs-frontend-api")
legacy_check()
endif()
else() else()
set(BUILD_OUT_OF_TREE ON) set(BUILD_OUT_OF_TREE ON)
cmake_minimum_required(VERSION 3.18) set(OBS_FRONTEND_API_NAME "frontend-api")
cmake_minimum_required(VERSION 3.16...3.26)
endif() endif()
include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/common/bootstrap.cmake" NO_POLICY_SCOPE)
project(aitum-multistream VERSION 0.0.1) project(${_name} VERSION ${_version})
set(PROJECT_FULL_NAME "Aitum Multistream")
# Set new UUIDs when you start to create a new plugin. include(compilerconfig)
set(MACOS_PACKAGE_UUID "231194EC-716C-4AF8-8BA0-B2BC2F7582ED") include(defaults)
set(MACOS_INSTALLER_UUID "5FF79C7A-9B23-42BB-A4E6-2081B2E6B5FA") include(helpers)
add_library(${PROJECT_NAME} MODULE) add_library(${PROJECT_NAME} MODULE)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/version.h.in ${CMAKE_CURRENT_SOURCE_DIR}/version.h) find_package(libobs REQUIRED)
target_link_libraries(${PROJECT_NAME} PRIVATE OBS::libobs)
set(CMAKE_AUTORCC ON) if(BUILD_OUT_OF_TREE)
find_package(obs-frontend-api REQUIRED)
target_link_libraries(${PROJECT_NAME} PRIVATE OBS::obs-frontend-api)
else()
target_link_libraries(${PROJECT_NAME} PRIVATE OBS::frontend-api)
endif()
if(BUILD_OUT_OF_TREE)
find_qt(COMPONENTS Widgets Core)
else()
find_package(Qt6 REQUIRED COMPONENTS Core Widgets)
endif()
target_link_libraries(${PROJECT_NAME} PRIVATE Qt::Core Qt::Widgets)
target_compile_options(
${PROJECT_NAME} PRIVATE $<$<C_COMPILER_ID:Clang,AppleClang>:-Wno-quoted-include-in-framework-header
-Wno-comma>)
set_target_properties(
${PROJECT_NAME}
PROPERTIES AUTOMOC ON
AUTOUIC ON
AUTORCC ON)
if(BUILD_OUT_OF_TREE)
find_package(CURL REQUIRED)
endif()
target_link_libraries(${PROJECT_NAME} PRIVATE CURL::libcurl)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/version.h.in ${CMAKE_CURRENT_SOURCE_DIR}/version.h)
target_sources(${PROJECT_NAME} PRIVATE target_sources(${PROJECT_NAME} PRIVATE
config-dialog.cpp config-dialog.cpp
@ -32,69 +59,7 @@ target_sources(${PROJECT_NAME} PRIVATE
file-updater.h) file-updater.h)
if(BUILD_OUT_OF_TREE) if(BUILD_OUT_OF_TREE)
include(cmake/ObsPluginHelpers.cmake) set_target_properties_plugin(${CMAKE_PROJECT_NAME} PROPERTIES OUTPUT_NAME ${_name})
find_package(libobs REQUIRED)
find_package(obs-frontend-api REQUIRED)
find_package(CURL REQUIRED)
find_qt(COMPONENTS Widgets COMPONENTS_LINUX Gui)
set(OBS_FRONTEND_API_NAME "obs-frontend-api")
else() else()
find_package(Qt6 REQUIRED COMPONENTS Core Widgets)
set(OBS_FRONTEND_API_NAME "frontend-api")
endif()
if(OS_WINDOWS)
get_filename_component(ISS_FILES_DIR "${CMAKE_BINARY_DIR}\\..\\package" ABSOLUTE)
file(TO_NATIVE_PATH "${ISS_FILES_DIR}" ISS_FILES_DIR)
get_filename_component(ISS_PACKAGE_DIR "${CMAKE_PACKAGE_PREFIX}\\.." ABSOLUTE)
file(TO_NATIVE_PATH "${ISS_PACKAGE_DIR}" ISS_PACKAGE_DIR)
get_filename_component(ISS_SOURCE_DIR "${PROJECT_SOURCE_DIR}" ABSOLUTE)
file(TO_NATIVE_PATH "${ISS_SOURCE_DIR}" ISS_SOURCE_DIR)
configure_file("installer.iss.in"
"${PROJECT_BINARY_DIR}/installer.iss"
)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resource.rc.in ${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}.rc)
target_sources(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}.rc)
elseif(OS_MACOS)
set(MACOS_BUNDLEID "tv.aitum.${PROJECT_NAME}")
set(MACOSX_PLUGIN_GUI_IDENTIFIER "${MACOS_BUNDLEID}")
set(MACOSX_PLUGIN_BUNDLE_VERSION "${PROJECT_VERSION}")
set(MACOSX_PLUGIN_SHORT_VERSION_STRING "1")
configure_file(cmake/bundle/macos/installer-macos.pkgproj.in ${CMAKE_BINARY_DIR}/installer-macos.generated.pkgproj)
target_compile_options(${PROJECT_NAME} PRIVATE -Wall)
elseif(OS_POSIX)
target_link_libraries(${PROJECT_NAME} Qt::GuiPrivate)
endif()
set_target_properties(${PROJECT_NAME} PROPERTIES AUTOMOC ON AUTOUIC ON AUTORCC ON)
target_link_libraries(${PROJECT_NAME}
OBS::${OBS_FRONTEND_API_NAME}
CURL::libcurl
Qt::Widgets
OBS::libobs)
if(BUILD_OUT_OF_TREE)
if(NOT LIB_OUT_DIR)
set(LIB_OUT_DIR "/lib/obs-plugins")
endif()
if(NOT DATA_OUT_DIR)
set(DATA_OUT_DIR "/share/obs/obs-plugins/${PROJECT_NAME}")
endif()
set_target_properties(${PROJECT_NAME} PROPERTIES PREFIX "")
install(TARGETS ${PROJECT_NAME}
LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX}/${LIB_OUT_DIR})
install(DIRECTORY data/locale data/images
DESTINATION ${CMAKE_INSTALL_PREFIX}/${DATA_OUT_DIR})
setup_plugin_target(${PROJECT_NAME})
else()
target_include_directories(${PROJECT_NAME} PRIVATE
"${CMAKE_SOURCE_DIR}/UI/obs-frontend-api")
if(OBS_CMAKE_VERSION VERSION_GREATER_EQUAL 3.0.0)
set_target_properties_obs(${PROJECT_NAME} PROPERTIES FOLDER "plugins/aitum" PREFIX "") set_target_properties_obs(${PROJECT_NAME} PROPERTIES FOLDER "plugins/aitum" PREFIX "")
else()
set_target_properties(${PROJECT_NAME} PROPERTIES FOLDER "plugins/aitum")
setup_plugin_target(${PROJECT_NAME})
endif()
endif() endif()

190
CMakePresets.json Normal file
View File

@ -0,0 +1,190 @@
{
"version": 3,
"cmakeMinimumRequired": {
"major": 3,
"minor": 22,
"patch": 0
},
"configurePresets": [
{
"name": "template",
"hidden": true,
"cacheVariables": {
"ENABLE_FRONTEND_API": false,
"ENABLE_QT": false
}
},
{
"name": "macos",
"displayName": "macOS Universal",
"description": "Build for macOS 11.0+ (Universal binary)",
"inherits": ["template"],
"binaryDir": "${sourceDir}/build_macos",
"condition": {
"type": "equals",
"lhs": "${hostSystemName}",
"rhs": "Darwin"
},
"generator": "Xcode",
"warnings": {"dev": true, "deprecated": true},
"cacheVariables": {
"QT_VERSION": "6",
"CMAKE_OSX_DEPLOYMENT_TARGET": "11.0",
"CODESIGN_IDENTITY": "$penv{CODESIGN_IDENT}",
"CODESIGN_TEAM": "$penv{CODESIGN_TEAM}"
}
},
{
"name": "macos-ci",
"inherits": ["macos"],
"displayName": "macOS Universal CI build",
"description": "Build for macOS 11.0+ (Universal binary) for CI",
"generator": "Xcode",
"cacheVariables": {
"CMAKE_COMPILE_WARNING_AS_ERROR": true
}
},
{
"name": "windows-x64",
"displayName": "Windows x64",
"description": "Build for Windows x64",
"inherits": ["template"],
"binaryDir": "${sourceDir}/build_x64",
"condition": {
"type": "equals",
"lhs": "${hostSystemName}",
"rhs": "Windows"
},
"generator": "Visual Studio 17 2022",
"architecture": "x64",
"warnings": {"dev": true, "deprecated": true},
"cacheVariables": {
"QT_VERSION": "6",
"CMAKE_SYSTEM_VERSION": "10.0.18363.657"
}
},
{
"name": "windows-ci-x64",
"inherits": ["windows-x64"],
"displayName": "Windows x64 CI build",
"description": "Build for Windows x64 on CI",
"cacheVariables": {
"CMAKE_COMPILE_WARNING_AS_ERROR": true
}
},
{
"name": "linux-x86_64",
"displayName": "Linux x86_64",
"description": "Build for Linux x86_64",
"inherits": ["template"],
"binaryDir": "${sourceDir}/build_x86_64",
"condition": {
"type": "equals",
"lhs": "${hostSystemName}",
"rhs": "Linux"
},
"generator": "Ninja",
"warnings": {"dev": true, "deprecated": true},
"cacheVariables": {
"QT_VERSION": "6",
"CMAKE_BUILD_TYPE": "RelWithDebInfo"
}
},
{
"name": "linux-ci-x86_64",
"inherits": ["linux-x86_64"],
"displayName": "Linux x86_64 CI build",
"description": "Build for Linux x86_64 on CI",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "RelWithDebInfo",
"CMAKE_COMPILE_WARNING_AS_ERROR": true
}
},
{
"name": "linux-aarch64",
"displayName": "Linux aarch64",
"description": "Build for Linux aarch64",
"inherits": ["template"],
"binaryDir": "${sourceDir}/build_aarch64",
"condition": {
"type": "equals",
"lhs": "${hostSystemName}",
"rhs": "Linux"
},
"generator": "Ninja",
"warnings": {"dev": true, "deprecated": true},
"cacheVariables": {
"QT_VERSION": "6",
"CMAKE_BUILD_TYPE": "RelWithDebInfo"
}
},
{
"name": "linux-ci-aarch64",
"inherits": ["linux-aarch64"],
"displayName": "Linux aarch64 CI build",
"description": "Build for Linux aarch64 on CI",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "RelWithDebInfo",
"CMAKE_COMPILE_WARNING_AS_ERROR": true
}
}
],
"buildPresets": [
{
"name": "macos",
"configurePreset": "macos",
"displayName": "macOS Universal",
"description": "macOS build for Universal architectures",
"configuration": "Release"
},
{
"name": "macos-ci",
"configurePreset": "macos-ci",
"displayName": "macOS Universal CI",
"description": "macOS CI build for Universal architectures",
"configuration": "RelWithDebInfo"
},
{
"name": "windows-x64",
"configurePreset": "windows-x64",
"displayName": "Windows x64",
"description": "Windows build for x64",
"configuration": "RelWithDebInfo"
},
{
"name": "windows-ci-x64",
"configurePreset": "windows-ci-x64",
"displayName": "Windows x64 CI",
"description": "Windows CI build for x64 (RelWithDebInfo configuration)",
"configuration": "RelWithDebInfo"
},
{
"name": "linux-x86_64",
"configurePreset": "linux-x86_64",
"displayName": "Linux x86_64",
"description": "Linux build for x86_64",
"configuration": "RelWithDebInfo"
},
{
"name": "linux-ci-x86_64",
"configurePreset": "linux-ci-x86_64",
"displayName": "Linux x86_64 CI",
"description": "Linux CI build for x86_64",
"configuration": "RelWithDebInfo"
},
{
"name": "linux-aarch64",
"configurePreset": "linux-aarch64",
"displayName": "Linux aarch64",
"description": "Linux build for aarch64",
"configuration": "RelWithDebInfo"
},
{
"name": "linux-ci-aarch64",
"configurePreset": "linux-ci-aarch64",
"displayName": "Linux aarch64 CI",
"description": "Linux CI build for aarch64",
"configuration": "RelWithDebInfo"
}
]
}

3
build-aux/.functions/log_debug Executable file
View File

@ -0,0 +1,3 @@
if (( ! ${+_loglevel} )) typeset -g _loglevel=1
if (( _loglevel > 2 )) print -PR -e -- "${CI:+::debug::}%F{220}DEBUG: ${@}%f"

3
build-aux/.functions/log_error Executable file
View File

@ -0,0 +1,3 @@
local icon=' ✖︎ '
print -u2 -PR "${CI:+::error::}%F{1} ${icon} %f ${@}"

16
build-aux/.functions/log_group Executable file
View File

@ -0,0 +1,16 @@
autoload -Uz log_info
if (( ! ${+_log_group} )) typeset -g _log_group=0
if (( ${+CI} )) {
if (( _log_group )) {
print "::endgroup::"
typeset -g _log_group=0
}
if (( # )) {
print "::group::${@}"
typeset -g _log_group=1
}
} else {
if (( # )) log_info ${@}
}

7
build-aux/.functions/log_info Executable file
View File

@ -0,0 +1,7 @@
if (( ! ${+_loglevel} )) typeset -g _loglevel=1
if (( _loglevel > 0 )) {
local icon=' =>'
print -PR "%F{4} ${(r:5:)icon}%f %B${@}%b"
}

View File

@ -0,0 +1,7 @@
if (( ! ${+_loglevel} )) typeset -g _loglevel=1
if (( _loglevel > 0 )) {
local icon=''
print -PR " ${(r:5:)icon} ${@}"
}

View File

@ -0,0 +1,7 @@
if (( ! ${+_loglevel} )) typeset -g _loglevel=1
if (( _loglevel > 0 )) {
local icon=' >'
print -PR "%F{2} ${(r:5:)icon}%f ${@}"
}

View File

@ -0,0 +1,7 @@
if (( ! ${+_loglevel} )) typeset -g _loglevel=1
if (( _loglevel > 0 )) {
local icon=' =>'
print -PR "${CI:+::warning::}%F{3} ${(r:5:)icon} ${@}%f"
}

View File

@ -0,0 +1,17 @@
autoload -Uz log_debug log_error
local -r _usage="Usage: %B${0}%b <loglevel>
Set log level, following levels are supported: 0 (quiet), 1 (normal), 2 (verbose), 3 (debug)"
if (( ! # )); then
log_error 'Called without arguments.'
log_output ${_usage}
return 2
elif (( ${1} >= 4 )); then
log_error 'Called with loglevel > 3.'
log_output ${_usage}
fi
typeset -g -i -r _loglevel=${1}
log_debug "Log level set to '${1}'"

188
build-aux/.run-format.zsh Executable file
View File

@ -0,0 +1,188 @@
#!/usr/bin/env zsh
builtin emulate -L zsh
setopt EXTENDED_GLOB
setopt PUSHD_SILENT
setopt ERR_EXIT
setopt ERR_RETURN
setopt NO_UNSET
setopt PIPE_FAIL
setopt NO_AUTO_PUSHD
setopt NO_PUSHD_IGNORE_DUPS
setopt FUNCTION_ARGZERO
## Enable for script debugging
# setopt WARN_CREATE_GLOBAL
# setopt WARN_NESTED_VAR
# setopt XTRACE
autoload -Uz is-at-least && if ! is-at-least 5.2; then
print -u2 -PR "%F{1}${funcstack[1]##*/}:%f Running on Zsh version %B${ZSH_VERSION}%b, but Zsh %B5.2%b is the minimum supported version. Upgrade zsh to fix this issue."
exit 1
fi
invoke_formatter() {
if (( # < 1 )) {
log_error "Usage invoke_formatter [formatter_name]"
exit 2
}
case ${1} {
clang)
if (( ${+commands[clang-format-16]} )) {
local formatter=clang-format-16
} elif (( ${+commands[clang-format]} )) {
local formatter=clang-format
local -a formatter_version=($(clang-format --version))
if ! is-at-least 16.0.5 ${formatter_version[-1]}; then
log_error "clang-format is not version 16.0.5 or above (found ${formatter_version[-1]}."
exit 2
fi
if ! is-at-least ${formatter_version[-1]} 16.0.5; then
log_error "clang-format is more recent than version 16.0.5 (found ${formatter_version[-1]})."
exit 2
fi
} else {
log_error "No viable clang-format version found (required 16.0.5)"
exit 2
}
local -a source_files=(src/**/*.(c|cpp|h|hpp|m|mm)(.N))
local -a format_args=(-style=file -fallback-style=none)
if (( _loglevel > 2 )) format_args+=(--verbose)
;;
cmake)
local formatter=cmake-format
if (( ${+commands[cmake-format]} )) {
local cmake_format_version=$(cmake-format --version)
if ! is-at-least 0.6.13 ${cmake_format_version}; then
log_error "cmake-format is not version 0.6.13 or above (found ${cmake_format_version})."
exit 2
fi
} else {
log_error "No viable cmake-format version found (required 0.6.13)"
exit 2
}
local -a source_files=(**/(CMakeLists.txt|*.cmake)(.N))
source_files=(${source_files:#(build_*)/*})
local -a format_args=()
if (( _loglevel > 2 )) format_args+=(--log-level debug)
;;
swift)
local formatter=swift-format
if (( ${+commands[swift-format]} )) {
local swift_format_version=$(swift-format --version)
if ! is-at-least 508.0.0 ${swift_format_version}; then
log_error "swift-format is not version 508.0.0 or above (found ${swift_format_version})."
exit 2
fi
} else {
log_error "No viable swift-format version found (required 508.0.0)"
exit 2
}
local -a source_files=(**/*.swift(.N))
local -a format_args=()
;;
*) log_error "Invalid formatter specified: ${1}. Valid options are clang-format, cmake-format, and swift-format."; exit 2 ;;
}
local file
local -i num_failures=0
if (( check_only )) {
for file (${source_files}) {
if (( _loglevel > 1 )) log_info "Checking format of ${file}..."
if ! "${formatter}" ${format_args} "${file}" | diff -q "${file}" - &> /dev/null; then
log_error "${file} requires formatting changes."
if (( fail_on_error == 2 )) return 2;
num_failures=$(( num_failures + 1 ))
else
if (( _loglevel > 1 )) log_status "${file} requires no formatting changes."
fi
}
if (( fail_on_error && num_failures )) return 2;
} elif (( ${#source_files} )) {
format_args+=(-i)
"${formatter}" ${format_args} ${source_files}
}
}
run_format() {
if (( ! ${+SCRIPT_HOME} )) typeset -g SCRIPT_HOME=${ZSH_ARGZERO:A:h}
if (( ! ${+FORMATTER_NAME} )) typeset -g FORMATTER_NAME=${${(s:-:)ZSH_ARGZERO:t:r}[2]}
typeset -g host_os=${${(L)$(uname -s)}//darwin/macos}
local -i fail_on_error=0
local -i check_only=0
local -i verbosity=1
local -r _version='1.0.0'
fpath=("${SCRIPT_HOME}/.functions" ${fpath})
autoload -Uz log_info log_error log_output set_loglevel log_status log_warning
local -r _usage="
Usage: %B${functrace[1]%:*}%b <option>
%BOptions%b:
%F{yellow} Formatting options%f
-----------------------------------------------------------------------------
%B-c | --check%b Check only, no actual formatting takes place
%F{yellow} Output options%f
-----------------------------------------------------------------------------
%B-v | --verbose%b Verbose (more detailed output)
%B--fail-[never|error] Fail script never/on formatting change - default: %B%F{green}never%f%b
%B--debug%b Debug (very detailed and added output)
%F{yellow} General options%f
-----------------------------------------------------------------------------
%B-h | --help%b Print this usage help
%B-V | --version%b Print script version information"
local -a args
while (( # )) {
case ${1} {
--)
shift
args+=($@)
break
;;
-c|--check) check_only=1; shift ;;
-v|--verbose) (( _verbosity += 1 )); shift ;;
-h|--help) log_output ${_usage}; exit 0 ;;
-V|--version) print -Pr "${_version}"; exit 0 ;;
--debug) verbosity=3; shift ;;
--fail-never)
fail_on_error=0
shift
;;
--fail-error)
fail_on_error=1
shift
;;
--fail-fast)
fail_on_error=2
shift
;;
*) log_error "Unknown option: %B${1}%b"; log_output ${_usage}; exit 2 ;;
}
}
set -- ${(@)args}
set_loglevel ${verbosity}
invoke_formatter ${FORMATTER_NAME}
}
run_format ${@}

1
build-aux/run-clang-format Symbolic link
View File

@ -0,0 +1 @@
.run-format.zsh

1
build-aux/run-cmake-format Symbolic link
View File

@ -0,0 +1 @@
.run-format.zsh

1
build-aux/run-swift-format Symbolic link
View File

@ -0,0 +1 @@
.run-format.zsh

View File

@ -1,84 +1,48 @@
{ {
"dependencies": { "dependencies": {
"obs-studio": { "obs-studio": {
"version": "30.0.0", "version": "30.0.2",
"repository": "https://github.com/obsproject/obs-studio.git", "baseUrl": "https://github.com/obsproject/obs-studio/archive/refs/tags",
"branch": "master", "label": "OBS sources",
"hash": "34ef67e212f24a085a63705a0ab81e3401c8eca4" "hashes": {
"macos": "be12c3ad0a85713750d8325e4b1db75086223402d7080d0e3c2833d7c5e83c27",
"windows-x64": "970058c49322cfa9cd6d620abb393fed89743ba7e74bd9dbb6ebe0ea8141d9c7"
}
}, },
"prebuilt": { "prebuilt": {
"version": "2023-11-03", "version": "2023-11-03",
"baseUrl": "https://github.com/obsproject/obs-deps/releases/download", "baseUrl": "https://github.com/obsproject/obs-deps/releases/download",
"label": "Pre-built obs-deps", "label": "Pre-Built obs-deps",
"hashes": { "hashes": {
"macos-x86_64": "b669dd1518b9350c307eff8102977c7eb7a8c8c10d677d4437862e66926b46ae", "macos": "90c2fc069847ec2768dcc867c1c63b112c615ed845a907dc44acab7a97181974",
"macos-arm64": "3a6e0e0f8fcca26821f5d842d6e09a31c2376515004ae19a5310ba576b95c63f", "windows-x64": "d0825a6fb65822c993a3059edfba70d72d2e632ef74893588cf12b1f0d329ce6"
"macos-universal": "90c2fc069847ec2768dcc867c1c63b112c615ed845a907dc44acab7a97181974",
"windows-x86": "b69c864275189464483c240ef3f25ea16fba3050b136fe6c3db6e9ee63036683",
"windows-x64": "d0825a6fb65822c993a3059edfba70d72d2e632ef74893588cf12b1f0d329ce6",
"linux-x86_64": "9217c6b70854a08575cc3debe85ed5496bb0d8a9de54a1f8148aa71ad71f98d6"
}
},
"qt5": {
"version": "2023-11-03",
"baseUrl": "https://github.com/obsproject/obs-deps/releases/download",
"label": "Pre-built Qt5",
"hashes": {
"macos-x86_64": "3d0381a52b0e4d49967936c4357f79ac711f43564329304a6db5c90edadd2697",
"macos-arm64": "f4b32548c0530f121956bf0a9a70c36ecbbfca81073d39c396a1759baf2a05c3",
"macos-universal": "9a6cf3b9a6c9efee6ba10df649202e8075e99f3c54ae88dc9a36dbc9d7471c1e",
"windows-x64": "6488a33a474f750d5a4a268a5e20c78bb40799d99136a1b7ce3365a843cb2fd7",
"windows-x86": "a916e09b0a874036801deab2c8a7ec14fdf5d268aa5511eac5bf40727e0c4e33"
},
"pdb-hashes": {
"windows-x64": "e0e5070143fcad9311a68ce5685d8ba8f34f581ed6942b7a92d360f94ca1ba11",
"windows-x86": "36642d1052aa461964f46c17610477b0d9b9defbe2d745ccaacb85f805c1bec2"
} }
}, },
"qt6": { "qt6": {
"version": "2023-11-03", "version": "2023-11-03",
"baseUrl": "https://github.com/obsproject/obs-deps/releases/download", "baseUrl": "https://github.com/obsproject/obs-deps/releases/download",
"label": "Pre-built Qt6", "label": "Pre-Built Qt6",
"hashes": { "hashes": {
"macos-x86_64": "2622d6ecd484a596da12b6a45b709fe563821eda558d0bbb27335c8c2f63945c", "macos": "ba4a7152848da0053f63427a2a2cb0a199af3992997c0db08564df6f48c9db98",
"macos-arm64": "4f72aa1103d88a00d90c01bb3650276ffa1408e16ef40579177605483b986dc9", "windows-x64": "bc57dedf76b47119a6dce0435a2f21b35b08c8f2948b1cb34a157320f77732d1"
"macos-universal": "ba4a7152848da0053f63427a2a2cb0a199af3992997c0db08564df6f48c9db98",
"windows-x64": "bc57dedf76b47119a6dce0435a2f21b35b08c8f2948b1cb34a157320f77732d1",
"windows-x86": "24fc03bef153a0e027c1479e42eb08097a4ea1d70a4710825be0783d0626cb0d"
}, },
"pdb-hashes": { "debugSymbols": {
"windows-x64": "f34ee5067be19ed370268b15c53684b7b8aaa867dc800b68931df905d679e31f", "windows-x64": "fd8ecd1d8cd2ef049d9f4d7fb5c134f784836d6020758094855dfa98bd025036"
"windows-x86": "f34d1a89fc85d92913bd6c7f75ec5c28471d74db708c98161100bc8b75f8fc63"
} }
} }
}, },
"platformConfig": { "platformConfig": {
"macos-x86_64": { "macos": {
"qtVersion": 6, "bundleId": "tv.aitum.aitum-multistream"
"deploymentTarget": "11.0"
},
"macos-arm64": {
"qtVersion": 6,
"deploymentTarget": "11.0"
},
"macos-universal": {
"qtVersion": 6,
"deploymentTarget": "11.0"
},
"windows-x64": {
"qtVersion": 6,
"visualStudio": "Visual Studio 17 2022",
"platformSDK": "10.0.20348.0"
},
"windows-x86": {
"qtVersion": 6,
"visualStudio": "Visual Studio 17 2022",
"platformSDK": "10.0.20348.0"
},
"linux-x86_64": {
"qtVersion": 6
} }
}, },
"name": "aitum-multistream", "name": "aitum-multistream",
"version": "0.0.1" "displayName": "Aitum Multistream",
"version": "0.0.1",
"author": "Aitum",
"website": "https://aitum.tv",
"email": "support@aitum.tv",
"uuids": {
"windowsApp": "7E8814F2-03EE-4E2E-8062-A9A184EC0618"
}
} }

View File

@ -1,26 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleName</key>
<string>${MACOSX_PLUGIN_BUNDLE_NAME}</string>
<key>CFBundleIdentifier</key>
<string>${MACOSX_PLUGIN_GUI_IDENTIFIER}</string>
<key>CFBundleVersion</key>
<string>${MACOSX_PLUGIN_BUNDLE_VERSION}</string>
<key>CFBundleShortVersionString</key>
<string>${MACOSX_PLUGIN_SHORT_VERSION_STRING}</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleExecutable</key>
<string>${MACOSX_PLUGIN_EXECUTABLE_NAME}</string>
<key>CFBundlePackageType</key>
<string>${MACOSX_PLUGIN_BUNDLE_TYPE}</string>
<key>CFBundleSupportedPlatforms</key>
<array>
<string>MacOSX</string>
</array>
<key>LSMinimumSystemVersion</key>
<string>10.13</string>
</dict>
</plist>

View File

@ -1,17 +0,0 @@
<!--?xml version="1.0" encoding="UTF-8"?-->
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.cs.allow-unsigned-executable-memory</key>
<true/>
<key>com.apple.security.device.camera</key>
<true/>
<key>com.apple.security.device.audio-input</key>
<true/>
<key>com.apple.security.cs.disable-library-validation</key>
<true/>
<!-- Allows @executable_path to load libaries from within the .app bundle. -->
<key>com.apple.security.cs.allow-dyld-environment-variables</key>
<true/>
</dict>
</plist>

View File

@ -1,699 +0,0 @@
if(POLICY CMP0087)
cmake_policy(SET CMP0087 NEW)
endif()
set(OBS_STANDALONE_PLUGIN_DIR ${CMAKE_SOURCE_DIR}/release)
include(GNUInstallDirs)
if(${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
set(OS_MACOS ON)
set(OS_POSIX ON)
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux|FreeBSD|OpenBSD")
set(OS_POSIX ON)
string(TOUPPER "${CMAKE_SYSTEM_NAME}" _SYSTEM_NAME_U)
set(OS_${_SYSTEM_NAME_U} ON)
elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
set(OS_WINDOWS ON)
set(OS_POSIX OFF)
endif()
# Old-Style plugin detected, find "modern" libobs variant instead and set global include directories
# to fix "bad" plugin behavior
if(DEFINED LIBOBS_INCLUDE_DIR AND NOT TARGET OBS::libobs)
message(
DEPRECATION
"You are using an outdated method of adding 'libobs' to your project. Refer to the updated wiki on how to build and export 'libobs' and use it in your plugin projects."
)
find_package(libobs REQUIRED)
if(TARGET OBS::libobs)
set_target_properties(OBS::libobs PROPERTIES IMPORTED_GLOBAL TRUE)
message(STATUS "OBS: Using modern libobs target")
add_library(libobs ALIAS OBS::libobs)
if(OS_WINDOWS)
add_library(w32-pthreads ALIAS OBS::w32-pthreads)
endif()
endif()
endif()
# Set macOS and Windows specific if default value is used
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT AND (OS_WINDOWS OR OS_MACOS))
set(CMAKE_INSTALL_PREFIX
${OBS_STANDALONE_PLUGIN_DIR}
CACHE STRING "Directory to install OBS plugin after building" FORCE)
endif()
# Set default build type to RelWithDebInfo and specify allowed alternative values
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE
"RelWithDebInfo"
CACHE STRING "OBS build type [Release, RelWithDebInfo, Debug, MinSizeRel]" FORCE)
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS Release RelWithDebInfo Debug MinSizeRel)
endif()
# Set default Qt version to AUTO, preferring an available Qt6 with a fallback to Qt5
if(NOT QT_VERSION)
set(QT_VERSION
AUTO
CACHE STRING "OBS Qt version [AUTO, 6, 5]" FORCE)
set_property(CACHE QT_VERSION PROPERTY STRINGS AUTO 6 5)
endif()
# Macro to find best possible Qt version for use with the project:
#
# * Use QT_VERSION value as a hint for desired Qt version
# * If "AUTO" was specified, prefer Qt6 over Qt5
# * Creates versionless targets of desired component if none had been created by Qt itself (Qt
# versions < 5.15)
#
macro(find_qt)
set(multiValueArgs COMPONENTS COMPONENTS_WIN COMPONENTS_MAC COMPONENTS_LINUX)
cmake_parse_arguments(FIND_QT "" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
# Do not use versionless targets in the first step to avoid Qt::Core being clobbered by later
# opportunistic find_package runs
set(QT_NO_CREATE_VERSIONLESS_TARGETS ON)
# Loop until _QT_VERSION is set or FATAL_ERROR aborts script execution early
while(NOT _QT_VERSION)
if(QT_VERSION STREQUAL AUTO AND NOT _QT_TEST_VERSION)
set(_QT_TEST_VERSION 6)
elseif(NOT QT_VERSION STREQUAL AUTO)
set(_QT_TEST_VERSION ${QT_VERSION})
endif()
find_package(
Qt${_QT_TEST_VERSION}
COMPONENTS Core
QUIET)
if(TARGET Qt${_QT_TEST_VERSION}::Core)
set(_QT_VERSION
${_QT_TEST_VERSION}
CACHE INTERNAL "")
message(STATUS "Qt version found: ${_QT_VERSION}")
unset(_QT_TEST_VERSION)
break()
elseif(QT_VERSION STREQUAL AUTO)
if(_QT_TEST_VERSION EQUAL 6)
message(WARNING "Qt6 was not found, falling back to Qt5")
set(_QT_TEST_VERSION 5)
continue()
endif()
endif()
message(FATAL_ERROR "Neither Qt6 nor Qt5 found.")
endwhile()
# Enable versionless targets for the remaining Qt components
set(QT_NO_CREATE_VERSIONLESS_TARGETS OFF)
set(_QT_COMPONENTS ${FIND_QT_COMPONENTS})
if(OS_WINDOWS)
list(APPEND _QT_COMPONENTS ${FIND_QT_COMPONENTS_WIN})
elseif(OS_MACOS)
list(APPEND _QT_COMPONENTS ${FIND_QT_COMPONENTS_MAC})
else()
list(APPEND _QT_COMPONENTS ${FIND_QT_COMPONENTS_LINUX})
endif()
find_package(
Qt${_QT_VERSION}
COMPONENTS ${_QT_COMPONENTS}
REQUIRED)
list(APPEND _QT_COMPONENTS Core)
if("Gui" IN_LIST FIND_QT_COMPONENTS_LINUX)
list(APPEND _QT_COMPONENTS "GuiPrivate")
endif()
# Check for versionless targets of each requested component and create if necessary
foreach(_COMPONENT IN LISTS _QT_COMPONENTS)
if(NOT TARGET Qt::${_COMPONENT} AND TARGET Qt${_QT_VERSION}::${_COMPONENT})
add_library(Qt::${_COMPONENT} INTERFACE IMPORTED)
set_target_properties(Qt::${_COMPONENT} PROPERTIES INTERFACE_LINK_LIBRARIES
Qt${_QT_VERSION}::${_COMPONENT})
endif()
endforeach()
endmacro()
# Set relative path variables for file configurations
file(RELATIVE_PATH RELATIVE_INSTALL_PATH ${CMAKE_SOURCE_DIR} ${CMAKE_INSTALL_PREFIX})
file(RELATIVE_PATH RELATIVE_BUILD_PATH ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR})
if(OS_POSIX)
# Set default GCC/clang compile options:
#
# * Treat warnings as errors
# * Enable extra warnings, https://clang.llvm.org/docs/DiagnosticsReference.html#wextra
# * Warning about usage of variable length array,
# https://clang.llvm.org/docs/DiagnosticsReference.html#wvla
# * Warning about bad format specifiers,
# https://clang.llvm.org/docs/DiagnosticsReference.html#wformat
# * Warning about non-strings used as format strings,
# https://clang.llvm.org/docs/DiagnosticsReference.html#wformat-security
# * Warning about non-exhaustive switch blocks,
# https://clang.llvm.org/docs/DiagnosticsReference.html#wswitch
# * Warning about unused parameters,
# https://clang.llvm.org/docs/DiagnosticsReference.html#wunused-parameter
# * DISABLE warning about unused functions,
# https://clang.llvm.org/docs/DiagnosticsReference.html#wunused-function
# * DISABLE warning about missing field initializers,
# https://clang.llvm.org/docs/DiagnosticsReference.html#wmissing-field-initializers
# * DISABLE strict aliasing optimisations
# * C ONLY - treat implicit function declarations (use before declare) as errors,
# https://clang.llvm.org/docs/DiagnosticsReference.html#wimplicit-function-declaration
# * C ONLY - DISABLE warning about missing braces around subobject initalizers,
# https://clang.llvm.org/docs/DiagnosticsReference.html#wmissing-braces
# * C ONLY, Clang ONLY - Warning about implicit conversion of NULL to another type,
# https://clang.llvm.org/docs/DiagnosticsReference.html#wnull-conversion
# * C & C++, Clang ONLY - Disable warning about integer conversion losing precision,
# https://clang.llvm.org/docs/DiagnosticsReference.html#wshorten-64-to-32
# * C++, GCC ONLY - Warning about implicit conversion of NULL to another type
# * Enable color diagnostics on Clang (CMAKE_COLOR_DIAGNOSTICS available in CMake 3.24)
target_compile_options(
${CMAKE_PROJECT_NAME}
PRIVATE
-Werror
-Wextra
-Wvla
-Wformat
-Wformat-security
-Wswitch
-Wunused-parameter
-Wno-unused-function
-Wno-missing-field-initializers
-fno-strict-aliasing
"$<$<COMPILE_LANGUAGE:C>:-Werror-implicit-function-declaration;-Wno-missing-braces>"
"$<$<COMPILE_LANG_AND_ID:C,AppleClang,Clang>:-Wnull-conversion;-Wno-error=shorten-64-to-32;-fcolor-diagnostics>"
"$<$<COMPILE_LANG_AND_ID:CXX,AppleClang,Clang>:-Wnull-conversion;-Wno-error=shorten-64-to-32;-fcolor-diagnostics>"
"$<$<COMPILE_LANG_AND_ID:CXX,GNU>:-Wconversion-null>"
"$<$<CONFIG:DEBUG>:-DDEBUG=1;-D_DEBUG=1>")
# GCC 12.1.0 has a regression bug which trigger maybe-uninitialized warnings where there is not.
# (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105562)
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_EQUAL "12.1.0")
target_compile_options(${CMAKE_PROJECT_NAME} PRIVATE -Wno-error=maybe-uninitialized)
endif()
if(NOT CCACHE_SET)
# Try to find and enable ccache
find_program(CCACHE_PROGRAM "ccache")
set(CCACHE_SUPPORT
ON
CACHE BOOL "Enable ccache support")
mark_as_advanced(CCACHE_PROGRAM)
if(CCACHE_PROGRAM AND CCACHE_SUPPORT)
set(CMAKE_CXX_COMPILER_LAUNCHER
${CCACHE_PROGRAM}
CACHE INTERNAL "")
set(CMAKE_C_COMPILER_LAUNCHER
${CCACHE_PROGRAM}
CACHE INTERNAL "")
set(CMAKE_OBJC_COMPILER_LAUNCHER
${CCACHE_PROGRAM}
CACHE INTERNAL "")
set(CMAKE_OBJCXX_COMPILER_LAUNCHER
${CCACHE_PROGRAM}
CACHE INTERNAL "")
set(CMAKE_CUDA_COMPILER_LAUNCHER
${CCACHE_PROGRAM}
CACHE INTERNAL "") # CMake 3.9+
set(CCACHE_SET
ON
CACHE INTERNAL "")
endif()
endif()
endif()
# Set required C++ standard to C++17
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
# Get lowercase host architecture for easier comparison
if(MSVC_CXX_ARCHITECTURE_ID)
string(TOLOWER ${MSVC_CXX_ARCHITECTURE_ID} _HOST_ARCH)
else()
string(TOLOWER ${CMAKE_SYSTEM_PROCESSOR} _HOST_ARCH)
endif()
if(_HOST_ARCH MATCHES "i[3-6]86|x86|x64|x86_64|amd64" AND NOT CMAKE_OSX_ARCHITECTURES STREQUAL
"arm64")
# Enable MMX, SSE and SSE2 on compatible host systems (assuming no cross-compile)
set(ARCH_SIMD_FLAGS -mmmx -msse -msse2)
elseif(_HOST_ARCH MATCHES "arm64|arm64e|aarch64")
# Enable available built-in SIMD support in Clang and GCC
if(CMAKE_C_COMPILER_ID MATCHES "^(Apple)?Clang|GNU" OR CMAKE_CXX_COMPILER_ID MATCHES
"^(Apple)?Clang|GNU")
include(CheckCCompilerFlag)
include(CheckCXXCompilerFlag)
check_c_compiler_flag("-fopenmp-simd" C_COMPILER_SUPPORTS_OPENMP_SIMD)
check_cxx_compiler_flag("-fopenmp-simd" CXX_COMPILER_SUPPORTS_OPENMP_SIMD)
target_compile_options(
${CMAKE_PROJECT_NAME}
PRIVATE
-DSIMDE_ENABLE_OPENMP
"$<$<AND:$<COMPILE_LANGUAGE:C>,$<BOOL:C_COMPILER_SUPPORTS_OPENMP_SIMD>>:-fopenmp-simd>"
"$<$<AND:$<COMPILE_LANGUAGE:CXX>,$<BOOL:CXX_COMPILER_SUPPORTS_OPENMP_SIMD>>:-fopenmp-simd>")
endif()
endif()
# macOS specific settings
if(OS_MACOS)
# Set macOS-specific C++ standard library
target_compile_options(
${CMAKE_PROJECT_NAME}
PRIVATE "$<$<COMPILE_LANG_AND_ID:OBJC,AppleClang,Clang>:-fcolor-diagnostics>" -stdlib=libc++)
# Set build architecture to host architecture by default
if(NOT CMAKE_OSX_ARCHITECTURES)
set(CMAKE_OSX_ARCHITECTURES
${CMAKE_HOST_SYSTEM_PROCESSOR}
CACHE STRING "Build architecture for macOS" FORCE)
endif()
set_property(CACHE CMAKE_OSX_ARCHITECTURES PROPERTY STRINGS arm64 x86_64 "arm64;x86_64")
# Set deployment target to 11.0 for Apple Silicon or 10.15 for Intel and Universal builds
if(NOT CMAKE_OSX_DEPLOYMENT_TARGET)
set(CMAKE_XCODE_ATTRIBUTE_MACOSX_DEPLOYMENT_TARGET[arch=arm64] "11.0")
set(CMAKE_XCODE_ATTRIBUTE_MACOSX_DEPLOYMENT_TARGET[arch=x86_64] "10.15")
if("${CMAKE_OSX_ARCHITECTURES}" STREQUAL "arm64")
set(_MACOS_DEPLOYMENT_TARGET "11.0")
else()
set(_MACOS_DEPLOYMENT_TARGET "10.15")
endif()
set(CMAKE_OSX_DEPLOYMENT_TARGET
${_MACOS_DEPLOYMENT_TARGET}
CACHE STRING
"Minimum macOS version to target for deployment (at runtime); newer APIs weak linked"
FORCE)
unset(_MACOS_DEPLOYMENT_TARGET)
endif()
set_property(CACHE CMAKE_OSX_DEPLOYMENT_TARGET PROPERTY STRINGS 13.0 12.0 11.0 10.15)
# Override macOS install directory
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX
${CMAKE_BINARY_DIR}/install
CACHE STRING "Directory to install OBS to after building" FORCE)
endif()
# Set up codesigning for Xcode builds with team IDs or standalone builds with developer identity
if(NOT OBS_BUNDLE_CODESIGN_TEAM)
if(NOT OBS_BUNDLE_CODESIGN_IDENTITY)
set(OBS_BUNDLE_CODESIGN_IDENTITY
"-"
CACHE STRING "OBS code signing identity for macOS" FORCE)
endif()
set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY ${OBS_BUNDLE_CODESIGN_IDENTITY})
else()
# Team ID specified, warn if Xcode generator is not used and fall back to ad-hoc signing
if(NOT XCODE)
message(
WARNING
"Code signing with a team identifier is only supported with the Xcode generator. Using ad-hoc code signature instead."
)
if(NOT OBS_BUNDLE_CODESIGN_IDENTITY)
set(OBS_BUNDLE_CODESIGN_IDENTITY
"-"
CACHE STRING "OBS code signing identity for macOS" FORCE)
endif()
else()
unset(OBS_BUNDLE_CODESIGN_IDENTITY)
set_property(CACHE OBS_BUNDLE_CODESIGN_TEAM PROPERTY HELPSTRING
"OBS code signing team for macOS")
set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGN_STYLE Automatic)
set(CMAKE_XCODE_ATTRIBUTE_DEVELOPMENT_TEAM ${OBS_BUNDLE_CODESIGN_TEAM})
endif()
endif()
# Set path to entitlements property list for codesigning. Entitlements should match the host
# binary, in this case OBS.app.
set(OBS_CODESIGN_ENTITLEMENTS
${CMAKE_SOURCE_DIR}/cmake/bundle/macos/entitlements.plist
CACHE INTERNAL "Path to codesign entitlements plist")
# Enable linker codesigning by default. Building OBS or plugins on host systems older than macOS
# 10.15 is not supported
set(OBS_CODESIGN_LINKER
ON
CACHE BOOL "Enable linker codesigning on macOS (macOS 11+ required)")
# Tell Xcode to pretend the linker signed binaries so that editing with install_name_tool
# preserves ad-hoc signatures. This option is supported by codesign on macOS 11 or higher. See
# CMake Issue 21854: https://gitlab.kitware.com/cmake/cmake/-/issues/21854
if(OBS_CODESIGN_LINKER)
set(CMAKE_XCODE_ATTRIBUTE_OTHER_CODE_SIGN_FLAGS "-o linker-signed")
endif()
# Set default options for bundling on macOS
set(CMAKE_MACOSX_RPATH ON)
set(CMAKE_SKIP_BUILD_RPATH OFF)
set(CMAKE_BUILD_WITH_INSTALL_RPATH OFF)
set(CMAKE_INSTALL_RPATH "@executable_path/../Frameworks/")
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH OFF)
# Helper function for plugin targets (macOS version)
function(setup_plugin_target target)
# Sanity check for required bundle information
#
# * Bundle identifier
# * Bundle version
# * Short version string
if(NOT DEFINED MACOSX_PLUGIN_GUI_IDENTIFIER)
message(
FATAL_ERROR
"No 'MACOSX_PLUGIN_GUI_IDENTIFIER' set, but is required to build plugin bundles on macOS - example: 'com.yourname.pluginname'"
)
endif()
if(NOT DEFINED MACOSX_PLUGIN_BUNDLE_VERSION)
message(
FATAL_ERROR
"No 'MACOSX_PLUGIN_BUNDLE_VERSION' set, but is required to build plugin bundles on macOS - example: '25'"
)
endif()
if(NOT DEFINED MACOSX_PLUGIN_SHORT_VERSION_STRING)
message(
FATAL_ERROR
"No 'MACOSX_PLUGIN_SHORT_VERSION_STRING' set, but is required to build plugin bundles on macOS - example: '1.0.2'"
)
endif()
# Set variables for automatic property list generation
set(MACOSX_PLUGIN_BUNDLE_NAME
"${target}"
PARENT_SCOPE)
set(MACOSX_PLUGIN_BUNDLE_VERSION
"${MACOSX_PLUGIN_BUNDLE_VERSION}"
PARENT_SCOPE)
set(MACOSX_PLUGIN_SHORT_VERSION_STRING
"${MACOSX_PLUGIN_SHORT_VERSION_STRING}"
PARENT_SCOPE)
set(MACOSX_PLUGIN_EXECUTABLE_NAME
"${target}"
PARENT_SCOPE)
set(MACOSX_PLUGIN_BUNDLE_TYPE
"BNDL"
PARENT_SCOPE)
# Set installation target to install prefix root (default for bundles)
install(
TARGETS ${target}
LIBRARY DESTINATION "."
COMPONENT obs_plugins
NAMELINK_COMPONENT ${target}_Development)
if(TARGET Qt::Core)
# Framework version has changed between Qt5 (uses wrong numerical version) and Qt6 (uses
# correct alphabetical version)
if(${_QT_VERSION} EQUAL 5)
set(_QT_FW_VERSION "${QT_VERSION}")
else()
set(_QT_FW_VERSION "A")
endif()
# Set up install-time command to fix Qt library references to point into OBS.app bundle
set(_COMMAND
"${CMAKE_INSTALL_NAME_TOOL} \\
-change ${CMAKE_PREFIX_PATH}/lib/QtWidgets.framework/Versions/${QT_VERSION}/QtWidgets @rpath/QtWidgets.framework/Versions/${_QT_FW_VERSION}/QtWidgets \\
-change ${CMAKE_PREFIX_PATH}/lib/QtCore.framework/Versions/${QT_VERSION}/QtCore @rpath/QtCore.framework/Versions/${_QT_FW_VERSION}/QtCore \\
-change ${CMAKE_PREFIX_PATH}/lib/QtGui.framework/Versions/${QT_VERSION}/QtGui @rpath/QtGui.framework/Versions/${_QT_FW_VERSION}/QtGui \\
\\\"\${CMAKE_INSTALL_PREFIX}/${target}.plugin/Contents/MacOS/${target}\\\"")
install(CODE "execute_process(COMMAND /bin/sh -c \"${_COMMAND}\")" COMPONENT obs_plugins)
unset(_QT_FW_VERSION)
endif()
# Set macOS bundle properties
set_target_properties(
${target}
PROPERTIES PREFIX ""
BUNDLE ON
BUNDLE_EXTENSION "plugin"
OUTPUT_NAME ${target}
MACOSX_BUNDLE_INFO_PLIST
"${CMAKE_CURRENT_FUNCTION_LIST_DIR}/bundle/macOS/Plugin-Info.plist.in"
XCODE_ATTRIBUTE_PRODUCT_BUNDLE_IDENTIFIER "${MACOSX_PLUGIN_GUI_IDENTIFIER}"
XCODE_ATTRIBUTE_CODE_SIGN_ENTITLEMENTS
"${CMAKE_CURRENT_FUNCTION_LIST_DIR}/bundle/macOS/entitlements.plist")
# If not building with Xcode, manually code-sign the plugin
if(NOT XCODE)
set(_COMMAND
"/usr/bin/codesign --force \\
--sign \\\"${OBS_BUNDLE_CODESIGN_IDENTITY}\\\" \\
--options runtime \\
--entitlements \\\"${CMAKE_CURRENT_FUNCTION_LIST_DIR}/bundle/macOS/entitlements.plist\\\" \\
\\\"\${CMAKE_INSTALL_PREFIX}/${target}.plugin\\\"")
install(CODE "execute_process(COMMAND /bin/sh -c \"${_COMMAND}\")" COMPONENT obs_plugins)
endif()
install_bundle_resources(${target})
endfunction()
# Helper function to add resources from "data" directory as bundle resources
function(install_bundle_resources target)
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/data)
file(GLOB_RECURSE _DATA_FILES "${CMAKE_CURRENT_SOURCE_DIR}/data/*")
foreach(_DATA_FILE IN LISTS _DATA_FILES)
file(RELATIVE_PATH _RELATIVE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/data/ ${_DATA_FILE})
get_filename_component(_RELATIVE_PATH ${_RELATIVE_PATH} PATH)
target_sources(${target} PRIVATE ${_DATA_FILE})
set_source_files_properties(${_DATA_FILE} PROPERTIES MACOSX_PACKAGE_LOCATION
Resources/${_RELATIVE_PATH})
string(REPLACE "\\" "\\\\" _GROUP_NAME ${_RELATIVE_PATH})
source_group("Resources\\${_GROUP_NAME}" FILES ${_DATA_FILE})
endforeach()
endif()
endfunction()
else()
# Check for target architecture (64bit vs 32bit)
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(_ARCH_SUFFIX 64)
else()
set(_ARCH_SUFFIX 32)
endif()
set(OBS_OUTPUT_DIR ${CMAKE_BINARY_DIR}/rundir)
# Unix specific settings
if(OS_POSIX)
# Paths to binaries and plugins differ between portable and non-portable builds on Linux
option(LINUX_PORTABLE "Build portable version (Linux)" ON)
if(NOT LINUX_PORTABLE)
set(OBS_LIBRARY_DESTINATION ${CMAKE_INSTALL_LIBDIR})
set(OBS_PLUGIN_DESTINATION ${OBS_LIBRARY_DESTINATION}/obs-plugins)
set(CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/lib)
set(OBS_DATA_DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/obs)
else()
set(OBS_LIBRARY_DESTINATION bin/${_ARCH_SUFFIX}bit)
set(OBS_PLUGIN_DESTINATION obs-plugins/${_ARCH_SUFFIX}bit)
set(CMAKE_INSTALL_RPATH "$ORIGIN/" "${CMAKE_INSTALL_PREFIX}/${OBS_LIBRARY_DESTINATION}")
set(OBS_DATA_DESTINATION "data")
endif()
# Setup Linux-specific CPack values for "deb" package generation
if(OS_LINUX)
set(CPACK_PACKAGE_NAME "${CMAKE_PROJECT_NAME}")
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "${LINUX_MAINTAINER_EMAIL}")
set(CPACK_PACKAGE_VERSION "${CMAKE_PROJECT_VERSION}")
set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-linux-x86_64")
set(CPACK_GENERATOR "DEB")
set(CPACK_DEBIAN_PACKAGE_DEPENDS
"obs-studio (>= 27.0.0), libqt5core5a (>= 5.9.0~beta), libqt5gui5 (>= 5.3.0), libqt5widgets5 (>= 5.7.0)"
)
set(CPACK_OUTPUT_FILE_PREFIX ${CMAKE_SOURCE_DIR}/release)
if(NOT LINUX_PORTABLE)
set(CPACK_SET_DESTDIR ON)
endif()
include(CPack)
endif()
# Windows specific settings
else()
set(OBS_LIBRARY_DESTINATION "bin/${_ARCH_SUFFIX}bit")
set(OBS_LIBRARY32_DESTINATION "bin/32bit")
set(OBS_LIBRARY64_DESTINATION "bin/64bit")
set(OBS_PLUGIN_DESTINATION "obs-plugins/${_ARCH_SUFFIX}bit")
set(OBS_PLUGIN32_DESTINATION "obs-plugins/32bit")
set(OBS_PLUGIN64_DESTINATION "obs-plugins/64bit")
set(OBS_DATA_DESTINATION "data")
if(MSVC)
# Set default Visual Studio CL.exe compile options.
#
# * Enable building with multiple processes,
# https://docs.microsoft.com/en-us/cpp/build/reference/mp-build-with-multiple-processes?view=msvc-170
# * Enable lint-like warnings,
# https://docs.microsoft.com/en-us/cpp/build/reference/compiler-option-warning-level?view=msvc-170
# * Enable treating all warnings as errors,
# https://docs.microsoft.com/en-us/cpp/build/reference/compiler-option-warning-level?view=msvc-170
# * RelWithDebInfo ONLY - Enable expanding of all functions not explicitly marked for no
# inlining,
# https://docs.microsoft.com/en-us/cpp/build/reference/ob-inline-function-expansion?view=msvc-170
# * Enable UNICODE support,
# https://docs.microsoft.com/en-us/windows/win32/learnwin32/working-with-strings#unicode-and-ansi-functions
# * DISABLE warnings about using POSIX function names,
# https://docs.microsoft.com/en-us/cpp/error-messages/compiler-warnings/compiler-warning-level-3-c4996?view=msvc-170#posix-function-names
# * DISABLE warnings about unsafe CRT library functions,
# https://docs.microsoft.com/en-us/cpp/error-messages/compiler-warnings/compiler-warning-level-3-c4996?view=msvc-170#unsafe-crt-library-functions
# * DISABLE warnings about nonstandard nameless structs/unions,
# https://docs.microsoft.com/en-us/cpp/error-messages/compiler-warnings/compiler-warning-level-4-c4201?view=msvc-170
target_compile_options(
${CMAKE_PROJECT_NAME}
PRIVATE /MP
/W3
/WX
/wd4201
"$<$<CONFIG:RELWITHDEBINFO>:/Ob2>"
"$<$<CONFIG:DEBUG>:/DDEBUG=1;/D_DEBUG=1>"
/DUNICODE
/D_UNICODE
/D_CRT_SECURE_NO_WARNINGS
/D_CRT_NONSTDC_NO_WARNINGS)
# Set default Visual Studio linker options.
#
# * Enable removal of functions and data that are never used,
# https://docs.microsoft.com/en-us/cpp/build/reference/opt-optimizations?view=msvc-170
# * Enable treating all warnings as errors,
# https://docs.microsoft.com/en-us/cpp/build/reference/wx-treat-linker-warnings-as-errors?view=msvc-170
# * x64 ONLY - DISABLE creation of table of safe exception handlers,
# https://docs.microsoft.com/en-us/cpp/build/reference/safeseh-image-has-safe-exception-handlers?view=msvc-170
# * Debug ONLY - DISABLE incremental linking,
# https://docs.microsoft.com/en-us/cpp/build/reference/incremental-link-incrementally?view=msvc-170
# * RelWithDebInfo ONLY - Disable incremental linking, but enable COMDAT folding,
# https://docs.microsoft.com/en-us/cpp/build/reference/opt-optimizations?view=msvc-170
target_link_options(
${CMAKE_PROJECT_NAME}
PRIVATE
"LINKER:/OPT:REF"
"LINKER:/WX"
"$<$<NOT:$<EQUAL:${CMAKE_SIZEOF_VOID_P},8>>:LINKER\:/SAFESEH\:NO>"
"$<$<CONFIG:DEBUG>:LINKER\:/INCREMENTAL\:NO>"
"$<$<CONFIG:RELWITHDEBINFO>:LINKER\:/INCREMENTAL\:NO;/OPT\:ICF>")
endif()
endif()
# Helper function for plugin targets (Windows and Linux version)
function(setup_plugin_target target)
# Set prefix to empty string to avoid automatic naming of generated library, i.e.
# "lib<YOUR_PLUGIN_NAME>"
set_target_properties(${target} PROPERTIES PREFIX "")
# Set install directories
install(
TARGETS ${target}
RUNTIME DESTINATION "${OBS_PLUGIN_DESTINATION}" COMPONENT ${target}_Runtime
LIBRARY DESTINATION "${OBS_PLUGIN_DESTINATION}"
COMPONENT ${target}_Runtime
NAMELINK_COMPONENT ${target}_Development)
# Set rundir install directory
install(
FILES $<TARGET_FILE:${target}>
DESTINATION $<CONFIG>/${OBS_PLUGIN_DESTINATION}
COMPONENT obs_rundir
EXCLUDE_FROM_ALL)
if(OS_WINDOWS)
# Set install directory for optional PDB symbol files
install(
FILES $<TARGET_PDB_FILE:${target}>
CONFIGURATIONS "RelWithDebInfo" "Debug"
DESTINATION ${OBS_PLUGIN_DESTINATION}
COMPONENT ${target}_Runtime
OPTIONAL)
# Set rundir install directory for optional PDB symbol files
install(
FILES $<TARGET_PDB_FILE:${target}>
CONFIGURATIONS "RelWithDebInfo" "Debug"
DESTINATION $<CONFIG>/${OBS_PLUGIN_DESTINATION}
COMPONENT obs_rundir
OPTIONAL EXCLUDE_FROM_ALL)
endif()
# Add resources from data directory
setup_target_resources(${target} obs-plugins/${target})
# Set up plugin for testing in available OBS build on Windows
if(OS_WINDOWS AND DEFINED OBS_BUILD_DIR)
setup_target_for_testing(${target} obs-plugins/${target})
endif()
# Custom command to install generated plugin into rundir
add_custom_command(
TARGET ${target}
POST_BUILD
COMMAND
"${CMAKE_COMMAND}" -DCMAKE_INSTALL_PREFIX=${OBS_OUTPUT_DIR}
-DCMAKE_INSTALL_COMPONENT=obs_rundir -DCMAKE_INSTALL_CONFIG_NAME=$<CONFIG> -P
${CMAKE_CURRENT_BINARY_DIR}/cmake_install.cmake
COMMENT "Installing to plugin rundir"
VERBATIM)
endfunction()
# Helper function to add resources from "data" directory
function(setup_target_resources target destination)
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/data)
install(
DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/data/
DESTINATION ${OBS_DATA_DESTINATION}/${destination}
USE_SOURCE_PERMISSIONS
COMPONENT obs_plugins)
install(
DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/data
DESTINATION $<CONFIG>/${OBS_DATA_DESTINATION}/${destination}
USE_SOURCE_PERMISSIONS
COMPONENT obs_rundir
EXCLUDE_FROM_ALL)
endif()
endfunction()
if(OS_WINDOWS)
# Additional Windows-only helper function to copy plugin to existing OBS development directory:
#
# Copies plugin with associated PDB symbol files as well as contents of data directory into the
# OBS rundir as specified by "OBS_BUILD_DIR".
function(setup_target_for_testing target destination)
install(
FILES $<TARGET_FILE:${target}>
DESTINATION $<CONFIG>/${OBS_PLUGIN_DESTINATION}
COMPONENT obs_testing
EXCLUDE_FROM_ALL)
install(
FILES $<TARGET_PDB_FILE:${target}>
CONFIGURATIONS "RelWithDebInfo" "Debug"
DESTINATION $<CONFIG>/${OBS_PLUGIN_DESTINATION}
COMPONENT obs_testing
OPTIONAL EXCLUDE_FROM_ALL)
install(
DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/data/
DESTINATION $<CONFIG>/${OBS_DATA_DESTINATION}/${destination}
USE_SOURCE_PERMISSIONS
COMPONENT obs_testing
EXCLUDE_FROM_ALL)
add_custom_command(
TARGET ${target}
POST_BUILD
COMMAND
"${CMAKE_COMMAND}" -DCMAKE_INSTALL_PREFIX=${OBS_BUILD_DIR}/rundir
-DCMAKE_INSTALL_COMPONENT=obs_testing -DCMAKE_INSTALL_CONFIG_NAME=$<CONFIG> -P
${CMAKE_CURRENT_BINARY_DIR}/cmake_install.cmake
COMMENT "Installing to OBS test directory"
VERBATIM)
endfunction()
endif()
endif()

View File

@ -0,0 +1,75 @@
cmake_minimum_required(VERSION 3.16...3.26)
include_guard(GLOBAL)
# Enable automatic PUSH and POP of policies to parent scope
if(POLICY CMP0011)
cmake_policy(SET CMP0011 NEW)
endif()
# Enable distinction between Clang and AppleClang
if(POLICY CMP0025)
cmake_policy(SET CMP0025 NEW)
endif()
# Enable strict checking of "break()" usage
if(POLICY CMP0055)
cmake_policy(SET CMP0055 NEW)
endif()
# Honor visibility presets for all target types (executable, shared, module, static)
if(POLICY CMP0063)
cmake_policy(SET CMP0063 NEW)
endif()
# Disable export function calls to populate package registry by default
if(POLICY CMP0090)
cmake_policy(SET CMP0090 NEW)
endif()
# Prohibit in-source builds
if("${CMAKE_CURRENT_BINARY_DIR}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}")
message(FATAL_ERROR "In-source builds are not supported. "
"Specify a build directory via 'cmake -S <SOURCE DIRECTORY> -B <BUILD_DIRECTORY>' instead.")
file(REMOVE_RECURSE "${CMAKE_CURRENT_SOURCE_DIR}/CMakeCache.txt" "${CMAKE_CURRENT_SOURCE_DIR}/CMakeFiles")
endif()
# Use folders for source file organization with IDE generators (Visual Studio/Xcode)
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
# Add common module directories to default search path
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/common")
file(READ "${CMAKE_CURRENT_SOURCE_DIR}/buildspec.json" buildspec)
# cmake-format: off
string(JSON _name GET ${buildspec} name)
string(JSON _website GET ${buildspec} website)
string(JSON _author GET ${buildspec} author)
string(JSON _email GET ${buildspec} email)
string(JSON _version GET ${buildspec} version)
string(JSON _bundleId GET ${buildspec} platformConfig macos bundleId)
string(JSON _windowsAppUUID GET ${buildspec} uuids windowsApp)
# cmake-format: on
set(PLUGIN_AUTHOR ${_author})
set(PLUGIN_WEBSITE ${_website})
set(PLUGIN_EMAIL ${_email})
set(PLUGIN_VERSION ${_version})
set(MACOS_BUNDLEID ${_bundleId})
include(buildnumber)
include(osconfig)
# Allow selection of common build types via UI
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE
"RelWithDebInfo"
CACHE STRING "OBS build type [Release, RelWithDebInfo, Debug, MinSizeRel]" FORCE)
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS Release RelWithDebInfo Debug MinSizeRel)
endif()
# Disable exports automatically going into the CMake package registry
set(CMAKE_EXPORT_PACKAGE_REGISTRY FALSE)
# Enable default inclusion of targets' source and binary directory
set(CMAKE_INCLUDE_CURRENT_DIR TRUE)

View File

@ -0,0 +1,21 @@
# CMake build number module
include_guard(GLOBAL)
# Define build number cache file
set(_BUILD_NUMBER_CACHE
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/.CMakeBuildNumber"
CACHE INTERNAL "OBS build number cache file")
# Read build number from cache file or manual override
if(NOT DEFINED PLUGIN_BUILD_NUMBER AND EXISTS "${_BUILD_NUMBER_CACHE}")
file(READ "${_BUILD_NUMBER_CACHE}" PLUGIN_BUILD_NUMBER)
math(EXPR PLUGIN_BUILD_NUMBER "${PLUGIN_BUILD_NUMBER}+1")
elseif(NOT DEFINED PLUGIN_BUILD_NUMBER)
if($ENV{CI} AND $ENV{GITHUB_RUN_ID})
set(PLUGIN_BUILD_NUMBER "$ENV{GITHUB_RUN_ID}")
else()
set(PLUGIN_BUILD_NUMBER "1")
endif()
endif()
file(WRITE "${_BUILD_NUMBER_CACHE}" "${PLUGIN_BUILD_NUMBER}")

View File

@ -0,0 +1,215 @@
# Common build dependencies module
# cmake-format: off
# cmake-lint: disable=C0103
# cmake-lint: disable=E1126
# cmake-lint: disable=R0912
# cmake-lint: disable=R0915
# cmake-format: on
include_guard(GLOBAL)
# _check_deps_version: Checks for obs-deps VERSION file in prefix paths
function(_check_deps_version version)
# cmake-format: off
set(found FALSE PARENT_SCOPE)
# cmake-format: on
foreach(path IN LISTS CMAKE_PREFIX_PATH)
if(EXISTS "${path}/share/obs-deps/VERSION")
if(dependency STREQUAL qt6 AND NOT EXISTS "${path}/lib/cmake/Qt6/Qt6Config.cmake")
# cmake-format: off
set(found FALSE PARENT_SCOPE)
# cmake-format: on
continue()
endif()
file(READ "${path}/share/obs-deps/VERSION" _check_version)
string(REPLACE "\n" "" _check_version "${_check_version}")
string(REPLACE "-" "." _check_version "${_check_version}")
string(REPLACE "-" "." version "${version}")
if(_check_version VERSION_EQUAL version)
# cmake-format: off
set(found TRUE PARENT_SCOPE)
# cmake-format: on
break()
elseif(_check_version VERSION_LESS version)
message(AUTHOR_WARNING "Older ${label} version detected in ${path}: \n"
"Found ${_check_version}, require ${version}")
list(REMOVE_ITEM CMAKE_PREFIX_PATH "${path}")
list(APPEND CMAKE_PREFIX_PATH "${path}")
# cmake-format: off
set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} PARENT_SCOPE)
# cmake-format: on
continue()
else()
message(AUTHOR_WARNING "Newer ${label} version detected in ${path}: \n"
"Found ${_check_version}, require ${version}")
# cmake-format: off
set(found TRUE PARENT_SCOPE)
# cmake-format: on
break()
endif()
endif()
endforeach()
endfunction()
# _setup_obs_studio: Create obs-studio build project, then build libobs and obs-frontend-api
function(_setup_obs_studio)
if(NOT libobs_DIR)
set(_is_fresh --fresh)
endif()
if(OS_WINDOWS)
set(_cmake_generator "${CMAKE_GENERATOR}")
set(_cmake_arch "-A ${arch}")
set(_cmake_extra "-DCMAKE_SYSTEM_VERSION=${CMAKE_SYSTEM_VERSION} -DCMAKE_ENABLE_SCRIPTING=OFF")
set(_cmake_version "2.0.0")
elseif(OS_MACOS)
set(_cmake_generator "Xcode")
set(_cmake_arch "-DCMAKE_OSX_ARCHITECTURES:STRING='arm64;x86_64'")
set(_cmake_extra "-DCMAKE_OSX_DEPLOYMENT_TARGET=${CMAKE_OSX_DEPLOYMENT_TARGET}")
set(_cmake_version "3.0.0")
endif()
message(STATUS "Configure ${label} (${arch})")
execute_process(
COMMAND
"${CMAKE_COMMAND}" -S "${dependencies_dir}/${_obs_destination}" -B
"${dependencies_dir}/${_obs_destination}/build_${arch}" -G ${_cmake_generator} "${_cmake_arch}"
-DOBS_CMAKE_VERSION:STRING=${_cmake_version} -DENABLE_PLUGINS:BOOL=OFF -DENABLE_UI:BOOL=OFF
-DOBS_VERSION_OVERRIDE:STRING=${_obs_version} "-DCMAKE_PREFIX_PATH='${CMAKE_PREFIX_PATH}'" ${_is_fresh}
${_cmake_extra}
RESULT_VARIABLE _process_result COMMAND_ERROR_IS_FATAL ANY
OUTPUT_QUIET)
message(STATUS "Configure ${label} (${arch}) - done")
message(STATUS "Build ${label} (${arch})")
execute_process(
COMMAND "${CMAKE_COMMAND}" --build build_${arch} --target obs-frontend-api --config Debug --parallel
WORKING_DIRECTORY "${dependencies_dir}/${_obs_destination}"
RESULT_VARIABLE _process_result COMMAND_ERROR_IS_FATAL ANY
OUTPUT_QUIET)
message(STATUS "Build ${label} (${arch}) - done")
message(STATUS "Install ${label} (${arch})")
if(OS_WINDOWS)
set(_cmake_extra "--component obs_libraries")
else()
set(_cmake_extra "")
endif()
execute_process(
COMMAND "${CMAKE_COMMAND}" --install build_${arch} --component Development --config Debug --prefix
"${dependencies_dir}" ${_cmake_extra}
WORKING_DIRECTORY "${dependencies_dir}/${_obs_destination}"
RESULT_VARIABLE _process_result COMMAND_ERROR_IS_FATAL ANY
OUTPUT_QUIET)
message(STATUS "Install ${label} (${arch}) - done")
endfunction()
# _check_dependencies: Fetch and extract pre-built OBS build dependencies
function(_check_dependencies)
if(NOT buildspec)
file(READ "${CMAKE_CURRENT_SOURCE_DIR}/buildspec.json" buildspec)
endif()
# cmake-format: off
string(JSON dependency_data GET ${buildspec} dependencies)
# cmake-format: on
foreach(dependency IN LISTS dependencies_list)
# cmake-format: off
string(JSON data GET ${dependency_data} ${dependency})
string(JSON version GET ${data} version)
string(JSON hash GET ${data} hashes ${platform})
string(JSON url GET ${data} baseUrl)
string(JSON label GET ${data} label)
string(JSON revision ERROR_VARIABLE error GET ${data} revision ${platform})
# cmake-format: on
message(STATUS "Setting up ${label} (${arch})")
set(file "${${dependency}_filename}")
set(destination "${${dependency}_destination}")
string(REPLACE "VERSION" "${version}" file "${file}")
string(REPLACE "VERSION" "${version}" destination "${destination}")
string(REPLACE "ARCH" "${arch}" file "${file}")
string(REPLACE "ARCH" "${arch}" destination "${destination}")
if(revision)
string(REPLACE "_REVISION" "_v${revision}" file "${file}")
string(REPLACE "-REVISION" "-v${revision}" file "${file}")
else()
string(REPLACE "_REVISION" "" file "${file}")
string(REPLACE "-REVISION" "" file "${file}")
endif()
set(skip FALSE)
if(dependency STREQUAL prebuilt OR dependency STREQUAL qt6)
_check_deps_version(${version})
if(found)
set(skip TRUE)
endif()
endif()
if(skip)
message(STATUS "Setting up ${label} (${arch}) - skipped")
continue()
endif()
if(dependency STREQUAL obs-studio)
set(url ${url}/${file})
else()
set(url ${url}/${version}/${file})
endif()
if(NOT EXISTS "${dependencies_dir}/${file}")
message(STATUS "Downloading ${url}")
file(
DOWNLOAD "${url}" "${dependencies_dir}/${file}"
STATUS download_status
EXPECTED_HASH SHA256=${hash})
list(GET download_status 0 error_code)
list(GET download_status 1 error_message)
if(error_code GREATER 0)
message(STATUS "Downloading ${url} - Failure")
message(FATAL_ERROR "Unable to download ${url}, failed with error: ${error_message}")
file(REMOVE "${dependencies_dir}/${file}")
else()
message(STATUS "Downloading ${url} - done")
endif()
endif()
if(NOT EXISTS "${dependencies_dir}/${destination}")
file(MAKE_DIRECTORY "${dependencies_dir}/${destination}")
if(dependency STREQUAL obs-studio)
file(ARCHIVE_EXTRACT INPUT "${dependencies_dir}/${file}" DESTINATION "${dependencies_dir}")
else()
file(ARCHIVE_EXTRACT INPUT "${dependencies_dir}/${file}" DESTINATION "${dependencies_dir}/${destination}")
endif()
endif()
if(dependency STREQUAL prebuilt)
list(APPEND CMAKE_PREFIX_PATH "${dependencies_dir}/${destination}")
elseif(dependency STREQUAL qt6)
list(APPEND CMAKE_PREFIX_PATH "${dependencies_dir}/${destination}")
elseif(dependency STREQUAL obs-studio)
set(_obs_version ${version})
set(_obs_destination "${destination}")
list(APPEND CMAKE_PREFIX_PATH "${dependencies_dir}")
endif()
message(STATUS "Setting up ${label} (${arch}) - done")
endforeach()
list(REMOVE_DUPLICATES CMAKE_PREFIX_PATH)
# cmake-format: off
set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} CACHE PATH "CMake prefix search path" FORCE)
# cmake-format: on
_setup_obs_studio()
endfunction()

22
cmake/common/ccache.cmake Normal file
View File

@ -0,0 +1,22 @@
# CMake ccache module
include_guard(GLOBAL)
if(NOT DEFINED CCACHE_PROGRAM)
message(DEBUG "Trying to find ccache on build host...")
find_program(CCACHE_PROGRAM "ccache")
mark_as_advanced(CCACHE_PROGRAM)
endif()
if(CCACHE_PROGRAM)
message(DEBUG "Ccache found as ${CCACHE_PROGRAM}...")
option(ENABLE_CCACHE "Enable compiler acceleration with ccache" ON)
if(ENABLE_CCACHE)
set(CMAKE_C_COMPILER_LAUNCHER "${CCACHE_PROGRAM}")
set(CMAKE_CXX_COMPILER_LAUNCHER "${CCACHE_PROGRAM}")
set(CMAKE_OBJC_COMPILER_LAUNCHER "${CCACHE_PROGRAM}")
set(CMAKE_OBJCXX_COMPILER_LAUNCHER "${CCACHE_PROGRAM}")
set(CMAKE_CUDA_COMPILER_LAUNCHER "${CCACHE_PROGRAM}")
endif()
endif()

View File

@ -0,0 +1,87 @@
# CMake common compiler options module
include_guard(GLOBAL)
# Set C and C++ language standards to C17 and C++17
if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.21)
set(CMAKE_C_STANDARD 17)
else()
set(CMAKE_C_STANDARD 11)
endif()
set(CMAKE_C_STANDARD_REQUIRED TRUE)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
# Set symbols to be hidden by default for C and C++
set(CMAKE_C_VISIBILITY_PRESET hidden)
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
set(CMAKE_VISIBILITY_INLINES_HIDDEN TRUE)
# clang options for C
set(_obs_clang_c_options
# cmake-format: sortable
-fno-strict-aliasing
-Wbool-conversion
-Wcomma
-Wconstant-conversion
-Wdeprecated-declarations
-Wempty-body
-Wenum-conversion
-Werror=return-type
-Wextra
-Wformat
-Wformat-security
-Wfour-char-constants
-Winfinite-recursion
-Wint-conversion
-Wnewline-eof
-Wno-conversion
-Wno-float-conversion
-Wno-implicit-fallthrough
-Wno-missing-braces
-Wno-missing-field-initializers
-Wno-missing-prototypes
-Wno-semicolon-before-method-body
-Wno-shadow
-Wno-sign-conversion
-Wno-strict-prototypes
-Wno-trigraphs
-Wno-unknown-pragmas
-Wno-unused-function
-Wno-unused-label
-Wnon-literal-null-conversion
-Wobjc-literal-conversion
-Wparentheses
-Wpointer-sign
-Wquoted-include-in-framework-header
-Wshadow
-Wshorten-64-to-32
-Wuninitialized
-Wunreachable-code
-Wunused-parameter
-Wunused-value
-Wunused-variable
-Wvla)
# clang options for C++
set(_obs_clang_cxx_options
# cmake-format: sortable
${_obs_clang_c_options}
-Wconversion
-Wdeprecated-implementations
-Wduplicate-method-match
-Wfloat-conversion
-Wfour-char-constants
-Wimplicit-retain-self
-Winvalid-offsetof
-Wmove
-Wno-c++11-extensions
-Wno-exit-time-destructors
-Wno-implicit-atomic-properties
-Wno-objc-interface-ivars
-Wno-overloaded-virtual
-Wrange-loop-analysis)
if(NOT DEFINED CMAKE_COMPILE_WARNING_AS_ERROR)
set(CMAKE_COMPILE_WARNING_AS_ERROR ON)
endif()

View File

@ -0,0 +1,143 @@
# CMake common helper functions module
# cmake-format: off
# cmake-lint: disable=C0103
# cmake-format: on
include_guard(GLOBAL)
# * Use QT_VERSION value as a hint for desired Qt version
# * If "AUTO" was specified, prefer Qt6 over Qt5
# * Creates versionless targets of desired component if none had been created by Qt itself (Qt versions < 5.15)
if(NOT QT_VERSION)
set(QT_VERSION
AUTO
CACHE STRING "OBS Qt version [AUTO, 5, 6]" FORCE)
set_property(CACHE QT_VERSION PROPERTY STRINGS AUTO 5 6)
endif()
# find_qt: Macro to find best possible Qt version for use with the project:
macro(find_qt)
set(multiValueArgs COMPONENTS COMPONENTS_WIN COMPONENTS_MAC COMPONENTS_LINUX)
cmake_parse_arguments(find_qt "" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
# Do not use versionless targets in the first step to avoid Qt::Core being clobbered by later opportunistic
# find_package runs
set(QT_NO_CREATE_VERSIONLESS_TARGETS TRUE)
message(DEBUG "Start Qt version discovery...")
# Loop until _QT_VERSION is set or FATAL_ERROR aborts script execution early
while(NOT _QT_VERSION)
message(DEBUG "QT_VERSION set to ${QT_VERSION}")
if(QT_VERSION STREQUAL AUTO AND NOT qt_test_version)
set(qt_test_version 6)
elseif(NOT QT_VERSION STREQUAL AUTO)
set(qt_test_version ${QT_VERSION})
endif()
message(DEBUG "Attempting to find Qt${qt_test_version}")
find_package(
Qt${qt_test_version}
COMPONENTS Core
QUIET)
if(TARGET Qt${qt_test_version}::Core)
set(_QT_VERSION
${qt_test_version}
CACHE INTERNAL "")
message(STATUS "Qt version found: ${_QT_VERSION}")
unset(qt_test_version)
break()
elseif(QT_VERSION STREQUAL AUTO)
if(qt_test_version EQUAL 6)
message(WARNING "Qt6 was not found, falling back to Qt5")
set(qt_test_version 5)
continue()
endif()
endif()
message(FATAL_ERROR "Neither Qt6 nor Qt5 found.")
endwhile()
# Enable versionless targets for the remaining Qt components
set(QT_NO_CREATE_VERSIONLESS_TARGETS FALSE)
set(qt_components ${find_qt_COMPONENTS})
if(OS_WINDOWS)
list(APPEND qt_components ${find_qt_COMPONENTS_WIN})
elseif(OS_MACOS)
list(APPEND qt_components ${find_qt_COMPONENTS_MAC})
else()
list(APPEND qt_components ${find_qt_COMPONENTS_LINUX})
endif()
message(DEBUG "Trying to find Qt components ${qt_components}...")
find_package(Qt${_QT_VERSION} REQUIRED ${qt_components})
list(APPEND qt_components Core)
if("Gui" IN_LIST find_qt_COMPONENTS_LINUX)
list(APPEND qt_components "GuiPrivate")
endif()
# Check for versionless targets of each requested component and create if necessary
foreach(component IN LISTS qt_components)
message(DEBUG "Checking for target Qt::${component}")
if(NOT TARGET Qt::${component} AND TARGET Qt${_QT_VERSION}::${component})
add_library(Qt::${component} INTERFACE IMPORTED)
set_target_properties(Qt::${component} PROPERTIES INTERFACE_LINK_LIBRARIES Qt${_QT_VERSION}::${component})
endif()
set_property(TARGET Qt::${component} PROPERTY INTERFACE_COMPILE_FEATURES "")
endforeach()
endmacro()
# check_uuid: Helper function to check for valid UUID
function(check_uuid uuid_string return_value)
set(valid_uuid TRUE)
set(uuid_token_lengths 8 4 4 4 12)
set(token_num 0)
string(REPLACE "-" ";" uuid_tokens ${uuid_string})
list(LENGTH uuid_tokens uuid_num_tokens)
if(uuid_num_tokens EQUAL 5)
message(DEBUG "UUID ${uuid_string} is valid with 5 tokens.")
foreach(uuid_token IN LISTS uuid_tokens)
list(GET uuid_token_lengths ${token_num} uuid_target_length)
string(LENGTH "${uuid_token}" uuid_actual_length)
if(uuid_actual_length EQUAL uuid_target_length)
string(REGEX MATCH "[0-9a-fA-F]+" uuid_hex_match ${uuid_token})
if(NOT uuid_hex_match STREQUAL uuid_token)
set(valid_uuid FALSE)
break()
endif()
else()
set(valid_uuid FALSE)
break()
endif()
math(EXPR token_num "${token_num}+1")
endforeach()
else()
set(valid_uuid FALSE)
endif()
message(DEBUG "UUID ${uuid_string} valid: ${valid_uuid}")
set(${return_value}
${valid_uuid}
PARENT_SCOPE)
endfunction()
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/src/plugin-support.c.in")
configure_file(src/plugin-support.c.in plugin-support.c @ONLY)
add_library(plugin-support STATIC)
target_sources(
plugin-support
PRIVATE plugin-support.c
PUBLIC src/plugin-support.h)
target_include_directories(plugin-support PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/src")
if(OS_LINUX
OR OS_FREEBSD
OR OS_OPENBSD)
# add fPIC on Linux to prevent shared object errors
set_property(TARGET plugin-support PROPERTY POSITION_INDEPENDENT_CODE ON)
endif()
endif()

View File

@ -0,0 +1,22 @@
# CMake operating system bootstrap module
include_guard(GLOBAL)
# Set minimum CMake version specific to host operating system, add OS-specific module directory to default search paths,
# and set helper variables for OS detection in other CMake list files.
if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows")
set(CMAKE_C_EXTENSIONS FALSE)
set(CMAKE_CXX_EXTENSIONS FALSE)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/windows")
set(OS_WINDOWS TRUE)
elseif(CMAKE_HOST_SYSTEM_NAME STREQUAL "Darwin")
set(CMAKE_C_EXTENSIONS FALSE)
set(CMAKE_CXX_EXTENSIONS FALSE)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/macos")
set(OS_MACOS TRUE)
elseif(CMAKE_HOST_SYSTEM_NAME MATCHES "Linux|FreeBSD|OpenBSD")
set(CMAKE_CXX_EXTENSIONS FALSE)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/linux")
string(TOUPPER "${CMAKE_HOST_SYSTEM_NAME}" _SYSTEM_NAME_U)
set(OS_${_SYSTEM_NAME_U} TRUE)
endif()

View File

@ -0,0 +1,85 @@
# CMake Linux compiler configuration module
include_guard(GLOBAL)
include(ccache)
include(compiler_common)
option(ENABLE_COMPILER_TRACE "Enable Clang time-trace (required Clang and Ninja)" OFF)
mark_as_advanced(ENABLE_COMPILER_TRACE)
# gcc options for C
set(_obs_gcc_c_options
# cmake-format: sortable
-fno-strict-aliasing
-fopenmp-simd
-Wdeprecated-declarations
-Wempty-body
-Wenum-conversion
-Werror=return-type
-Wextra
-Wformat
-Wformat-security
-Wno-conversion
-Wno-float-conversion
-Wno-implicit-fallthrough
-Wno-missing-braces
-Wno-missing-field-initializers
-Wno-shadow
-Wno-sign-conversion
-Wno-trigraphs
-Wno-unknown-pragmas
-Wno-unused-function
-Wno-unused-label
-Wparentheses
-Wshadow
-Wuninitialized
-Wunreachable-code
-Wunused-parameter
-Wunused-value
-Wunused-variable
-Wvla)
# gcc options for C++
set(_obs_gcc_cxx_options
# cmake-format: sortable
${_obs_gcc_c_options} -Wconversion -Wfloat-conversion -Winvalid-offsetof -Wno-overloaded-virtual)
add_compile_options(
-fopenmp-simd
"$<$<COMPILE_LANG_AND_ID:C,GNU>:${_obs_gcc_c_options}>"
"$<$<COMPILE_LANG_AND_ID:C,GNU>:-Wint-conversion;-Wno-missing-prototypes;-Wno-strict-prototypes;-Wpointer-sign>"
"$<$<COMPILE_LANG_AND_ID:CXX,GNU>:${_obs_gcc_cxx_options}>"
"$<$<COMPILE_LANG_AND_ID:C,Clang>:${_obs_clang_c_options}>"
"$<$<COMPILE_LANG_AND_ID:CXX,Clang>:${_obs_clang_cxx_options}>")
# Add support for color diagnostics and CMake switch for warnings as errors to CMake < 3.24
if(CMAKE_VERSION VERSION_LESS 3.24.0)
add_compile_options($<$<C_COMPILER_ID:Clang>:-fcolor-diagnostics> $<$<CXX_COMPILER_ID:Clang>:-fcolor-diagnostics>)
if(CMAKE_COMPILE_WARNING_AS_ERROR)
add_compile_options(-Werror)
endif()
else()
set(CMAKE_COLOR_DIAGNOSTICS ON)
endif()
if(CMAKE_CXX_COMPILER_ID STREQUAL GNU)
# Disable false-positive warning in GCC 12.1.0 and later
add_compile_options(-Wno-error=maybe-uninitialized)
# Add warning for infinite recursion (added in GCC 12)
if(CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 12.0.0)
add_compile_options(-Winfinite-recursion)
endif()
endif()
# Enable compiler and build tracing (requires Ninja generator)
if(ENABLE_COMPILER_TRACE AND CMAKE_GENERATOR STREQUAL "Ninja")
add_compile_options($<$<COMPILE_LANG_AND_ID:C,Clang>:-ftime-trace> $<$<COMPILE_LANG_AND_ID:CXX,Clang>:-ftime-trace>)
else()
set(ENABLE_COMPILER_TRACE
OFF
CACHE STRING "Enable Clang time-trace (required Clang and Ninja)" FORCE)
endif()
add_compile_definitions($<$<CONFIG:DEBUG>:DEBUG> $<$<CONFIG:DEBUG>:_DEBUG> SIMDE_ENABLE_OPENMP)

View File

@ -0,0 +1,86 @@
# CMake Linux defaults module
# cmake-format: off
# cmake-lint: disable=C0103
# cmake-lint: disable=C0111
# cmake-format: on
include_guard(GLOBAL)
include(GNUInstallDirs)
# Enable find_package targets to become globally available targets
set(CMAKE_FIND_PACKAGE_TARGETS_GLOBAL TRUE)
set(CPACK_PACKAGE_NAME "${CMAKE_PROJECT_NAME}")
set(CPACK_PACKAGE_VERSION "${CMAKE_PROJECT_VERSION}")
set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-${CMAKE_C_LIBRARY_ARCHITECTURE}")
set(CPACK_GENERATOR "DEB")
set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON)
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "${PLUGIN_EMAIL}")
set(CPACK_SET_DESTDIR ON)
if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.25.0 OR NOT CMAKE_CROSSCOMPILING)
set(CPACK_DEBIAN_DEBUGINFO_PACKAGE ON)
endif()
set(CPACK_OUTPUT_FILE_PREFIX "${CMAKE_CURRENT_SOURCE_DIR}/release")
set(CPACK_SOURCE_GENERATOR "TXZ")
set(CPACK_SOURCE_IGNORE_FILES
# cmake-format: sortable
".*~$"
\\.git/
\\.github/
\\.gitignore
build_.*
cmake/\\.CMakeBuildNumber
release/)
set(CPACK_VERBATIM_VARIABLES YES)
set(CPACK_SOURCE_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-source")
set(CPACK_ARCHIVE_THREADS 0)
include(CPack)
find_package(libobs QUIET)
if(NOT TARGET OBS::libobs)
find_package(LibObs REQUIRED)
add_library(OBS::libobs ALIAS libobs)
if(ENABLE_FRONTEND_API)
find_path(
obs-frontend-api_INCLUDE_DIR
NAMES obs-frontend-api.h
PATHS /usr/include /usr/local/include
PATH_SUFFIXES obs)
find_library(
obs-frontend-api_LIBRARY
NAMES obs-frontend-api
PATHS /usr/lib /usr/local/lib)
if(obs-frontend-api_LIBRARY)
if(NOT TARGET OBS::obs-frontend-api)
if(IS_ABSOLUTE "${obs-frontend-api_LIBRARY}")
add_library(OBS::obs-frontend-api UNKNOWN IMPORTED)
set_property(TARGET OBS::obs-frontend-api PROPERTY IMPORTED_LOCATION "${obs-frontend-api_LIBRARY}")
else()
add_library(OBS::obs-frontend-api INTERFACE IMPORTED)
set_property(TARGET OBS::obs-frontend-api PROPERTY IMPORTED_LIBNAME "${obs-frontend-api_LIBRARY}")
endif()
set_target_properties(OBS::obs-frontend-api PROPERTIES INTERFACE_INCLUDE_DIRECTORIES
"${obs-frontend-api_INCLUDE_DIR}")
endif()
endif()
endif()
macro(find_package)
if(NOT "${ARGV0}" STREQUAL libobs AND NOT "${ARGV0}" STREQUAL obs-frontend-api)
_find_package(${ARGV})
endif()
endmacro()
endif()

74
cmake/linux/helpers.cmake Normal file
View File

@ -0,0 +1,74 @@
# CMake Linux helper functions module
include_guard(GLOBAL)
include(helpers_common)
# set_target_properties_plugin: Set target properties for use in obs-studio
function(set_target_properties_plugin target)
set(options "")
set(oneValueArgs "")
set(multiValueArgs PROPERTIES)
cmake_parse_arguments(PARSE_ARGV 0 _STPO "${options}" "${oneValueArgs}" "${multiValueArgs}")
message(DEBUG "Setting additional properties for target ${target}...")
while(_STPO_PROPERTIES)
list(POP_FRONT _STPO_PROPERTIES key value)
set_property(TARGET ${target} PROPERTY ${key} "${value}")
endwhile()
set_target_properties(
${target}
PROPERTIES VERSION 0
SOVERSION ${PLUGIN_VERSION}
PREFIX "")
install(
TARGETS ${target}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/obs-plugins)
if(TARGET plugin-support)
target_link_libraries(${target} PRIVATE plugin-support)
endif()
target_install_resources(${target})
get_target_property(target_sources ${target} SOURCES)
set(target_ui_files ${target_sources})
list(FILTER target_ui_files INCLUDE REGEX ".+\\.(ui|qrc)")
source_group(
TREE "${CMAKE_CURRENT_SOURCE_DIR}"
PREFIX "UI Files"
FILES ${target_ui_files})
endfunction()
# Helper function to add resources into bundle
function(target_install_resources target)
message(DEBUG "Installing resources for target ${target}...")
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/data")
file(GLOB_RECURSE data_files "${CMAKE_CURRENT_SOURCE_DIR}/data/*")
foreach(data_file IN LISTS data_files)
cmake_path(RELATIVE_PATH data_file BASE_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/data/" OUTPUT_VARIABLE
relative_path)
cmake_path(GET relative_path PARENT_PATH relative_path)
target_sources(${target} PRIVATE "${data_file}")
source_group("Resources/${relative_path}" FILES "${data_file}")
endforeach()
install(
DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/data/"
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/obs/obs-plugins/${target}
USE_SOURCE_PERMISSIONS)
endif()
endfunction()
# Helper function to add a specific resource to a bundle
function(target_add_resource target resource)
message(DEBUG "Add resource '${resource}' to target ${target} at destination '${target_destination}'...")
install(FILES "${resource}" DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/obs/obs-plugins/${target})
source_group("Resources" FILES "${resource}")
endfunction()

View File

@ -0,0 +1,56 @@
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR aarch64)
set(CMAKE_CROSSCOMPILING TRUE)
set(CMAKE_C_COMPILER /usr/bin/clang)
set(CMAKE_CXX_COMPILER /usr/bin/clang++)
set(CMAKE_C_COMPILER_TARGET aarch64-linux-gnu)
set(CMAKE_CXX_COMPILER_TARGET aarch64-linux-gnu)
set(CMAKE_FIND_ROOT_PATH /usr/aarch64-linux-gnu)
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(PKG_CONFIG_EXECUTABLE
/usr/bin/aarch64-linux-gnu-pkg-config
CACHE FILEPATH "pkg-config executable")
execute_process(
COMMAND ${CMAKE_C_COMPILER} -print-prog-name=llvm-ranlib
OUTPUT_VARIABLE CMAKE_RANLIB
OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process(
COMMAND ${CMAKE_C_COMPILER} -print-prog-name=llvm-ar
OUTPUT_VARIABLE CMAKE_LLVM_AR
OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process(
COMMAND ${CMAKE_C_COMPILER} -print-prog-name=llvm-readelf
OUTPUT_VARIABLE READELF
OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process(
COMMAND ${CMAKE_C_COMPILER} -print-prog-name=llvm-objcopy
OUTPUT_VARIABLE CMAKE_LLVM_OBJCOPY
OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process(
COMMAND ${CMAKE_C_COMPILER} -print-prog-name=llvm-objdump
OUTPUT_VARIABLE CMAKE_LLVM_OBJDUMP
OUTPUT_STRIP_TRAILING_WHITESPACE)
set(CMAKE_AR
"${CMAKE_LLVM_AR}"
CACHE INTERNAL "${CMAKE_SYSTEM_NAME} ar" FORCE)
set(CMAKE_OBJCOPY
"${CMAKE_LLVM_OBJCOPY}"
CACHE INTERNAL "${CMAKE_SYSTEM_NAME} objcopy" FORCE)
set(CMAKE_OBJDUMP
"${CMAKE_LLVM_OBJDUMP}"
CACHE INTERNAL "${CMAKE_SYSTEM_NAME} objdump" FORCE)
set(CPACK_READELF_EXECUTABLE "${READELF}")
set(CPACK_OBJCOPY_EXECUTABLE "${CMAKE_LLVM_OBJCOPY}")
set(CPACK_OBJDUMP_EXECUTABLE "${CMAKE_LLVM_OBJDUMP}")
set(CPACK_PACKAGE_ARCHITECTURE arm64)
set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE arm64)

View File

@ -0,0 +1,20 @@
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR aarch64)
set(CMAKE_CROSSCOMPILING TRUE)
set(CMAKE_C_COMPILER /usr/bin/aarch64-linux-gnu-gcc)
set(CMAKE_CXX_COMPILER /usr/bin/aarch64-linux-gnu-g++)
set(CMAKE_FIND_ROOT_PATH /usr/aarch64-linux-gnu)
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(PKG_CONFIG_EXECUTABLE
/usr/bin/aarch64-linux-gnu-pkg-config
CACHE FILEPATH "pkg-config executable")
set(CPACK_READELF_EXECUTABLE /usr/bin/aarch64-linux-gnu-readelf)
set(CPACK_OBJCOPY_EXECUTABLE /usr/bin/aarch64-linux-gnu-objcopy)
set(CPACK_OBJDUMP_EXECUTABLE /usr/bin/aarch64-linux-gnu-objdump)
set(CPACK_PACKAGE_ARCHITECTURE arm64)
set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE arm64)

View File

@ -0,0 +1,56 @@
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR x86_64)
set(CMAKE_CROSSCOMPILING TRUE)
set(CMAKE_C_COMPILER /usr/bin/clang)
set(CMAKE_CXX_COMPILER /usr/bin/clang++)
set(CMAKE_C_COMPILER_TARGET x86_64-linux-gnu)
set(CMAKE_CXX_COMPILER_TARGET x86_64-linux-gnu)
set(CMAKE_FIND_ROOT_PATH /usr/x86_64-linux-gnu)
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(PKG_CONFIG_EXECUTABLE
/usr/bin/x86_64-linux-gnu-pkg-config
CACHE FILEPATH "pkg-config executable")
execute_process(
COMMAND ${CMAKE_C_COMPILER} -print-prog-name=llvm-ranlib
OUTPUT_VARIABLE CMAKE_RANLIB
OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process(
COMMAND ${CMAKE_C_COMPILER} -print-prog-name=llvm-ar
OUTPUT_VARIABLE CMAKE_LLVM_AR
OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process(
COMMAND ${CMAKE_C_COMPILER} -print-prog-name=llvm-readelf
OUTPUT_VARIABLE READELF
OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process(
COMMAND ${CMAKE_C_COMPILER} -print-prog-name=llvm-objcopy
OUTPUT_VARIABLE CMAKE_LLVM_OBJCOPY
OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process(
COMMAND ${CMAKE_C_COMPILER} -print-prog-name=llvm-objdump
OUTPUT_VARIABLE CMAKE_LLVM_OBJDUMP
OUTPUT_STRIP_TRAILING_WHITESPACE)
set(CMAKE_AR
"${CMAKE_LLVM_AR}"
CACHE INTERNAL "${CMAKE_SYSTEM_NAME} ar" FORCE)
set(CMAKE_OBJCOPY
"${CMAKE_LLVM_OBJCOPY}"
CACHE INTERNAL "${CMAKE_SYSTEM_NAME} objcopy" FORCE)
set(CMAKE_OBJDUMP
"${CMAKE_LLVM_OBJDUMP}"
CACHE INTERNAL "${CMAKE_SYSTEM_NAME} objdump" FORCE)
set(CPACK_READELF_EXECUTABLE "${READELF}")
set(CPACK_OBJCOPY_EXECUTABLE "${CMAKE_LLVM_OBJCOPY}")
set(CPACK_OBJDUMP_EXECUTABLE "${CMAKE_LLVM_OBJDUMP}")
set(CPACK_PACKAGE_ARCHITECTURE x86_64)
set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE x86_64)

View File

@ -0,0 +1,20 @@
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR x86_64)
set(CMAKE_CROSSCOMPILING TRUE)
set(CMAKE_C_COMPILER /usr/bin/x86_64-linux-gnu-gcc)
set(CMAKE_CXX_COMPILER /usr/bin/x86_64-linux-gnu-g++)
set(CMAKE_FIND_ROOT_PATH /usr/x86_64-linux-gnu)
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(PKG_CONFIG_EXECUTABLE
/usr/bin/x86_64-linux-gnu-pkg-config
CACHE FILEPATH "pkg-config executable")
set(CPACK_READELF_EXECUTABLE /usr/bin/x86_64-linux-gnu-readelf)
set(CPACK_OBJCOPY_EXECUTABLE /usr/bin/x86_64-linux-gnu-objcopy)
set(CPACK_OBJDUMP_EXECUTABLE /usr/bin/x86_64-linux-gnu-objdump)
set(CPACK_PACKAGE_ARCHITECTURE x86_64)
set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE x86_64)

View File

@ -0,0 +1,34 @@
# CMake macOS build dependencies module
include_guard(GLOBAL)
include(buildspec_common)
# _check_dependencies_macos: Set up macOS slice for _check_dependencies
function(_check_dependencies_macos)
set(arch universal)
set(platform macos)
file(READ "${CMAKE_CURRENT_SOURCE_DIR}/buildspec.json" buildspec)
set(dependencies_dir "${CMAKE_CURRENT_SOURCE_DIR}/.deps")
set(prebuilt_filename "macos-deps-VERSION-ARCH_REVISION.tar.xz")
set(prebuilt_destination "obs-deps-VERSION-ARCH")
set(qt6_filename "macos-deps-qt6-VERSION-ARCH-REVISION.tar.xz")
set(qt6_destination "obs-deps-qt6-VERSION-ARCH")
set(obs-studio_filename "VERSION.tar.gz")
set(obs-studio_destination "obs-studio-VERSION")
set(dependencies_list prebuilt qt6 obs-studio)
_check_dependencies()
execute_process(COMMAND "xattr" -r -d com.apple.quarantine "${dependencies_dir}"
RESULT_VARIABLE result COMMAND_ERROR_IS_FATAL ANY)
list(APPEND CMAKE_FRAMEWORK_PATH "${dependencies_dir}/Frameworks")
set(CMAKE_FRAMEWORK_PATH
${CMAKE_FRAMEWORK_PATH}
PARENT_SCOPE)
endfunction()
_check_dependencies_macos()

View File

@ -0,0 +1,57 @@
# CMake macOS compiler configuration module
include_guard(GLOBAL)
include(ccache)
include(compiler_common)
add_compile_options(-fopenmp-simd)
if(XCODE)
# Use Xcode's standard architecture selection
set(CMAKE_OSX_ARCHITECTURES "$(ARCHS_STANDARD)")
# Enable dSYM generation for Release builds
string(APPEND CMAKE_C_FLAGS_RELEASE " -g")
string(APPEND CMAKE_CXX_FLAGS_RELEASE " -g")
else()
option(ENABLE_COMPILER_TRACE "Enable clang time-trace (requires Ninja)" OFF)
mark_as_advanced(ENABLE_COMPILER_TRACE)
# clang options for ObjC
set(_obs_clang_objc_options
# cmake-format: sortable
-Werror=block-capture-autoreleasing -Wno-selector -Wno-strict-selector-match -Wnon-virtual-dtor -Wprotocol
-Wundeclared-selector)
# clang options for ObjC++
set(_obs_clang_objcxx_options
# cmake-format: sortable
${_obs_clang_objc_options} -Warc-repeated-use-of-weak -Wno-arc-maybe-repeated-use-of-weak)
add_compile_options(
"$<$<COMPILE_LANGUAGE:C>:${_obs_clang_c_options}>" "$<$<COMPILE_LANGUAGE:CXX>:${_obs_clang_cxx_options}>"
"$<$<COMPILE_LANGUAGE:OBJC>:${_obs_clang_objc_options}>"
"$<$<COMPILE_LANGUAGE:OBJCXX>:${_obs_clang_objcxx_options}>")
# Enable stripping of dead symbols when not building for Debug configuration
set(_release_configs RelWithDebInfo Release MinSizeRel)
if(CMAKE_BUILD_TYPE IN_LIST _release_configs)
add_link_options(LINKER:-dead_strip)
endif()
# Enable color diagnostics for AppleClang
set(CMAKE_COLOR_DIAGNOSTICS ON)
# Set universal architectures via CMake flag for non-Xcode generators
set(CMAKE_OSX_ARCHITECTURES "arm64;x86_64")
# Enable compiler and build tracing (requires Ninja generator)
if(ENABLE_COMPILER_TRACE AND CMAKE_GENERATOR STREQUAL "Ninja")
add_compile_options($<$<COMPILE_LANGUAGE:C>:-ftime-trace> $<$<COMPILE_LANGUAGE:CXX>:-ftime-trace>)
else()
set(ENABLE_COMPILER_TRACE
OFF
CACHE STRING "Enable clang time-trace (requires Ninja)" FORCE)
endif()
endif()
add_compile_definitions($<$<CONFIG:DEBUG>:DEBUG> $<$<CONFIG:DEBUG>:_DEBUG> SIMDE_ENABLE_OPENMP)

View File

@ -0,0 +1,49 @@
# CMake macOS defaults module
include_guard(GLOBAL)
# Set empty codesigning team if not specified as cache variable
if(NOT CODESIGN_TEAM)
set(CODESIGN_TEAM
""
CACHE STRING "OBS code signing team for macOS" FORCE)
# Set ad-hoc codesigning identity if not specified as cache variable
if(NOT CODESIGN_IDENTITY)
set(CODESIGN_IDENTITY
"-"
CACHE STRING "OBS code signing identity for macOS" FORCE)
endif()
endif()
if(XCODE)
include(xcode)
endif()
include(buildspec)
# Set default deployment target to 11.0 if not set and enable selection in GUI up to 13.0
if(NOT CMAKE_OSX_DEPLOYMENT_TARGET)
set(CMAKE_OSX_DEPLOYMENT_TARGET
11.0
CACHE STRING "Minimum macOS version to target for deployment (at runtime). Newer APIs will be weak-linked." FORCE)
endif()
set_property(CACHE CMAKE_OSX_DEPLOYMENT_TARGET PROPERTY STRINGS 13.0 12.0 11.0)
# Use Applications directory as default install destination
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX
"$ENV{HOME}/Library/Application Support/obs-studio/plugins"
CACHE STRING "Directory to install OBS after building" FORCE)
endif()
# Enable find_package targets to become globally available targets
set(CMAKE_FIND_PACKAGE_TARGETS_GLOBAL TRUE)
# Enable RPATH support for generated binaries
set(CMAKE_MACOSX_RPATH TRUE)
# Use RPATHs from build tree _in_ the build tree
set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
# Do not add default linker search paths to RPATH
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH FALSE)
# Use common bundle-relative RPATH for installed targets
set(CMAKE_INSTALL_RPATH "@executable_path/../Frameworks")

94
cmake/macos/helpers.cmake Normal file
View File

@ -0,0 +1,94 @@
# CMake macOS helper functions module
# cmake-format: off
# cmake-lint: disable=C0103
# cmake-lint: disable=C0307
# cmake-format: on
include_guard(GLOBAL)
include(helpers_common)
# set_target_properties_obs: Set target properties for use in obs-studio
function(set_target_properties_plugin target)
set(options "")
set(oneValueArgs "")
set(multiValueArgs PROPERTIES)
cmake_parse_arguments(PARSE_ARGV 0 _STPO "${options}" "${oneValueArgs}" "${multiValueArgs}")
message(DEBUG "Setting additional properties for target ${target}...")
while(_STPO_PROPERTIES)
list(POP_FRONT _STPO_PROPERTIES key value)
set_property(TARGET ${target} PROPERTY ${key} "${value}")
endwhile()
string(TIMESTAMP CURRENT_YEAR "%Y")
set_target_properties(
${target}
PROPERTIES BUNDLE TRUE
BUNDLE_EXTENSION plugin
XCODE_ATTRIBUTE_PRODUCT_NAME ${target}
XCODE_ATTRIBUTE_PRODUCT_BUNDLE_IDENTIFIER ${MACOS_BUNDLEID}
XCODE_ATTRIBUTE_CURRENT_PROJECT_VERSION ${PLUGIN_BUILD_NUMBER}
XCODE_ATTRIBUTE_MARKETING_VERSION ${PLUGIN_VERSION}
XCODE_ATTRIBUTE_GENERATE_INFOPLIST_FILE YES
XCODE_ATTRIBUTE_INFOPLIST_FILE ""
XCODE_ATTRIBUTE_INFOPLIST_KEY_CFBundleDisplayName ${target}
XCODE_ATTRIBUTE_INFOPLIST_KEY_NSHumanReadableCopyright "(c) ${CURRENT_YEAR} ${PLUGIN_AUTHOR}"
XCODE_ATTRIBUTE_INSTALL_PATH "$(USER_LIBRARY_DIR)/Application Support/obs-studio/plugins")
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/cmake/macos/entitlements.plist")
set_target_properties(${target} PROPERTIES XCODE_ATTRIBUTE_CODE_SIGN_ENTITLEMENTS
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/macos/entitlements.plist")
endif()
if(TARGET plugin-support)
target_link_libraries(${target} PRIVATE plugin-support)
endif()
target_install_resources(${target})
get_target_property(target_sources ${target} SOURCES)
set(target_ui_files ${target_sources})
list(FILTER target_ui_files INCLUDE REGEX ".+\\.(ui|qrc)")
source_group(
TREE "${CMAKE_CURRENT_SOURCE_DIR}"
PREFIX "UI Files"
FILES ${target_ui_files})
install(TARGETS ${target} LIBRARY DESTINATION .)
install(
FILES "$<TARGET_BUNDLE_DIR:${target}>.dsym"
CONFIGURATIONS Release
DESTINATION .
OPTIONAL)
configure_file(cmake/macos/resources/distribution.in "${CMAKE_CURRENT_BINARY_DIR}/distribution" @ONLY)
configure_file(cmake/macos/resources/create-package.cmake.in "${CMAKE_CURRENT_BINARY_DIR}/create-package.cmake" @ONLY)
install(SCRIPT "${CMAKE_CURRENT_BINARY_DIR}/create-package.cmake")
endfunction()
# target_install_resources: Helper function to add resources into bundle
function(target_install_resources target)
message(DEBUG "Installing resources for target ${target}...")
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/data")
file(GLOB_RECURSE data_files "${CMAKE_CURRENT_SOURCE_DIR}/data/*")
foreach(data_file IN LISTS data_files)
cmake_path(RELATIVE_PATH data_file BASE_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/data/" OUTPUT_VARIABLE
relative_path)
cmake_path(GET relative_path PARENT_PATH relative_path)
target_sources(${target} PRIVATE "${data_file}")
set_property(SOURCE "${data_file}" PROPERTY MACOSX_PACKAGE_LOCATION "Resources/${relative_path}")
source_group("Resources/${relative_path}" FILES "${data_file}")
endforeach()
endif()
endfunction()
# target_add_resource: Helper function to add a specific resource to a bundle
function(target_add_resource target resource)
message(DEBUG "Add resource ${resource} to target ${target} at destination ${destination}...")
target_sources(${target} PRIVATE "${resource}")
set_property(SOURCE "${resource}" PROPERTY MACOSX_PACKAGE_LOCATION Resources)
source_group("Resources" FILES "${resource}")
endfunction()

View File

@ -0,0 +1,17 @@
#!/bin/sh
if [[ "$1" == "${CMAKE_C_COMPILER}" ]] ; then
shift
fi
export CCACHE_CPP2=true
export CCACHE_DEPEND=true
export CCACHE_DIRECT=true
export CCACHE_FILECLONE=true
export CCACHE_INODECACHE=true
export CCACHE_NOCOMPILERCHECK='content'
export CCACHE_SLOPPINESS='include_file_mtime,include_file_ctime,clang_index_store,system_headers'
if [[ "${CI}" ]]; then
export CCACHE_NOHASHDIR=true
fi
exec "${CMAKE_C_COMPILER_LAUNCHER}" "${CMAKE_C_COMPILER}" "$@"

View File

@ -0,0 +1,17 @@
#!/bin/sh
if [[ "$1" == "${CMAKE_CXX_COMPILER}" ]] ; then
shift
fi
export CCACHE_CPP2=true
export CCACHE_NODEPEND=true
export CCACHE_DIRECT=true
export CCACHE_FILECLONE=true
export CCACHE_INODECACHE=true
export CCACHE_NOCOMPILERCHECK='content'
export CCACHE_SLOPPINESS='include_file_mtime,include_file_ctime,clang_index_store,system_headers'
if [[ "${CI}" ]]; then
export CCACHE_NOHASHDIR=true
fi
exec "${CMAKE_CXX_COMPILER_LAUNCHER}" "${CMAKE_CXX_COMPILER}" "$@"

View File

@ -0,0 +1,35 @@
make_directory("$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/package/Library/Application Support/obs-studio/plugins")
if(EXISTS "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/@CMAKE_PROJECT_NAME@.plugin" AND NOT IS_SYMLINK "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/@CMAKE_PROJECT_NAME@.plugin")
file(INSTALL DESTINATION "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/package/Library/Application Support/obs-studio/plugins"
TYPE DIRECTORY FILES "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/@CMAKE_PROJECT_NAME@.plugin" USE_SOURCE_PERMISSIONS)
if(CMAKE_INSTALL_CONFIG_NAME MATCHES "^([Rr][Ee][Ll][Ee][Aa][Ss][Ee])$" OR CMAKE_INSTALL_CONFIG_NAME MATCHES "^([Mm][Ii][Nn][Ss][Ii][Zz][Ee][Rr][Ee][Ll])$")
if(EXISTS "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/@CMAKE_PROJECT_NAME@.plugin.dSYM" AND NOT IS_SYMLINK "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/@CMAKE_PROJECT_NAME@.plugin.dSYM")
file(INSTALL DESTINATION "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/package/Library/Application Support/obs-studio/plugins" TYPE DIRECTORY FILES "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/@CMAKE_PROJECT_NAME@.plugin.dSYM" USE_SOURCE_PERMISSIONS)
endif()
endif()
endif()
make_directory("$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/temp")
execute_process(
COMMAND /usr/bin/pkgbuild
--identifier '@MACOS_BUNDLEID@'
--version '@CMAKE_PROJECT_VERSION@'
--root "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/package"
"$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/temp/@CMAKE_PROJECT_NAME@.pkg"
COMMAND_ERROR_IS_FATAL ANY
)
execute_process(
COMMAND /usr/bin/productbuild
--distribution "@CMAKE_CURRENT_BINARY_DIR@/distribution"
--package-path "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/temp"
"$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/@CMAKE_PROJECT_NAME@.pkg"
COMMAND_ERROR_IS_FATAL ANY)
if(EXISTS "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/@CMAKE_PROJECT_NAME@.pkg")
file(REMOVE_RECURSE "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/temp")
file(REMOVE_RECURSE "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/package")
endif()

View File

@ -0,0 +1,33 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<installer-gui-script minSpecVersion="1.0">
<options
rootVolumeOnly="true"
hostArchitectures="arm64,x86_64"
customize="never"
allow-external-scripts="no" />
<domains enable_currentUserHome="true" enable_anywhere="false" enable_localSystem="false" />
<title>@CMAKE_PROJECT_NAME@</title>
<choices-outline>
<line choice="obs-plugin" />
</choices-outline>
<choice id="obs-plugin" title="@CMAKE_PROJECT_NAME@" description="">
<pkg-ref id="@MACOS_BUNDLEID@" />
</choice>
<pkg-ref id="@MACOS_BUNDLEID@" version="@CMAKE_PROJECT_VERSION@">#@CMAKE_PROJECT_NAME@.pkg</pkg-ref>
<installation-check script="installCheck();" />
<script>
function installCheck() {
var macOSVersion = system.version.ProductVersion
if (system.compareVersions(macOSVersion, '@CMAKE_OSX_DEPLOYMENT_TARGET@') == -1) {
my.result.title = system.localizedStandardStringWithFormat(
'InstallationCheckError',
system.localizedString('DISTRIBUTION_TITLE')
);
my.result.message = ' ';
my.result.type = 'Fatal';
return false;
}
}
</script>
</installer-gui-script>

View File

@ -63,7 +63,7 @@
<key>GID</key> <key>GID</key>
<integer>80</integer> <integer>80</integer>
<key>PATH</key> <key>PATH</key>
<string>../@RELATIVE_INSTALL_PATH@/@CMAKE_PROJECT_NAME@.plugin</string> <string>../release/@CMAKE_INSTALL_CONFIG_NAME@/@CMAKE_PROJECT_NAME@.plugin</string>
<key>PATH_TYPE</key> <key>PATH_TYPE</key>
<integer>1</integer> <integer>1</integer>
<key>PERMISSIONS</key> <key>PERMISSIONS</key>
@ -538,7 +538,7 @@
<key>TYPE</key> <key>TYPE</key>
<integer>0</integer> <integer>0</integer>
<key>UUID</key> <key>UUID</key>
<string>@MACOS_PACKAGE_UUID@</string> <string>@UUID_PACKAGE@</string>
</dict> </dict>
</array> </array>
<key>PROJECT</key> <key>PROJECT</key>
@ -584,13 +584,13 @@
<integer>1</integer> <integer>1</integer>
</dict> </dict>
<key>PACKAGE_UUID</key> <key>PACKAGE_UUID</key>
<string>@MACOS_PACKAGE_UUID@</string> <string>@UUID_PACKAGE@</string>
<key>TITLE</key> <key>TITLE</key>
<array/> <array/>
<key>TYPE</key> <key>TYPE</key>
<integer>0</integer> <integer>0</integer>
<key>UUID</key> <key>UUID</key>
<string>@MACOS_INSTALLER_UUID@</string> <string>@UUID_INSTALLER@</string>
</dict> </dict>
</array> </array>
<key>REMOVED</key> <key>REMOVED</key>
@ -732,7 +732,7 @@
<key>BUILD_PATH</key> <key>BUILD_PATH</key>
<dict> <dict>
<key>PATH</key> <key>PATH</key>
<string>../@RELATIVE_BUILD_PATH@</string> <string>.</string>
<key>PATH_TYPE</key> <key>PATH_TYPE</key>
<integer>1</integer> <integer>1</integer>
</dict> </dict>

174
cmake/macos/xcode.cmake Normal file
View File

@ -0,0 +1,174 @@
# CMake macOS Xcode module
include_guard(GLOBAL)
# Use a compiler wrapper to enable ccache in Xcode projects
if(ENABLE_CCACHE AND CCACHE_PROGRAM)
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake/macos/resources/ccache-launcher-c.in" ccache-launcher-c)
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake/macos/resources/ccache-launcher-cxx.in" ccache-launcher-cxx)
execute_process(COMMAND chmod a+rx "${CMAKE_CURRENT_BINARY_DIR}/ccache-launcher-c"
"${CMAKE_CURRENT_BINARY_DIR}/ccache-launcher-cxx")
set(CMAKE_XCODE_ATTRIBUTE_CC "${CMAKE_CURRENT_BINARY_DIR}/ccache-launcher-c")
set(CMAKE_XCODE_ATTRIBUTE_CXX "${CMAKE_CURRENT_BINARY_DIR}/ccache-launcher-cxx")
set(CMAKE_XCODE_ATTRIBUTE_LD "${CMAKE_C_COMPILER}")
set(CMAKE_XCODE_ATTRIBUTE_LDPLUSPLUS "${CMAKE_CXX_COMPILER}")
endif()
# Set project variables
set(CMAKE_XCODE_ATTRIBUTE_CURRENT_PROJECT_VERSION ${PLUGIN_BUILD_NUMBER})
set(CMAKE_XCODE_ATTRIBUTE_DYLIB_COMPATIBILITY_VERSION 1.0.0)
set(CMAKE_XCODE_ATTRIBUTE_MARKETING_VERSION ${PLUGIN_VERSION})
# Set deployment target
set(CMAKE_XCODE_ATTRIBUTE_MACOSX_DEPLOYMENT_TARGET ${CMAKE_OSX_DEPLOYMENT_TARGET})
if(NOT CODESIGN_TEAM)
# Switch to manual codesigning if no codesigning team is provided
set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGN_STYLE Manual)
set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "${CODESIGN_IDENTITY}")
else()
if(CODESIGN_IDENTITY AND NOT CODESIGN_IDENTITY STREQUAL "-")
# Switch to manual codesigning if a non-adhoc codesigning identity is provided
set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGN_STYLE Manual)
set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "${CODESIGN_IDENTITY}")
else()
# Switch to automatic codesigning via valid team ID
set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGN_STYLE Automatic)
set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "Apple Development")
endif()
set(CMAKE_XCODE_ATTRIBUTE_DEVELOPMENT_TEAM "${CODESIGN_TEAM}")
endif()
# Only create a single Xcode project file
set(CMAKE_XCODE_GENERATE_TOP_LEVEL_PROJECT_ONLY TRUE)
# Add all libraries to project link phase (lets Xcode handle linking)
set(CMAKE_XCODE_LINK_BUILD_PHASE_MODE KNOWN_LOCATION)
# Enable codesigning with secure timestamp when not in Debug configuration (required for Notarization)
set(CMAKE_XCODE_ATTRIBUTE_OTHER_CODE_SIGN_FLAGS[variant=Release] "--timestamp")
set(CMAKE_XCODE_ATTRIBUTE_OTHER_CODE_SIGN_FLAGS[variant=RelWithDebInfo] "--timestamp")
set(CMAKE_XCODE_ATTRIBUTE_OTHER_CODE_SIGN_FLAGS[variant=MinSizeRel] "--timestamp")
# Enable codesigning with hardened runtime option when not in Debug configuration (required for Notarization)
set(CMAKE_XCODE_ATTRIBUTE_ENABLE_HARDENED_RUNTIME[variant=Release] YES)
set(CMAKE_XCODE_ATTRIBUTE_ENABLE_HARDENED_RUNTIME[variant=RelWithDebInfo] YES)
set(CMAKE_XCODE_ATTRIBUTE_ENABLE_HARDENED_RUNTIME[variant=MinSizeRel] YES)
# Disable injection of Xcode's base entitlements used for debugging when not in Debug configuration (required for
# Notarization)
set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGN_INJECT_BASE_ENTITLEMENTS[variant=Release] NO)
set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGN_INJECT_BASE_ENTITLEMENTS[variant=RelWithDebInfo] NO)
set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGN_INJECT_BASE_ENTITLEMENTS[variant=MinSizeRel] NO)
# Use Swift version 5.0 by default
set(CMAKE_XCODE_ATTRIBUTE_SWIFT_VERSION 5.0)
# Use DWARF with separate dSYM files when in Release or MinSizeRel configuration.
#
# * Currently overruled by CMake's Xcode generator, requires adding '-g' flag to raw compiler command line for desired
# output configuration. Report to KitWare.
#
set(CMAKE_XCODE_ATTRIBUTE_DEBUG_INFORMATION_FORMAT[variant=Debug] dwarf)
set(CMAKE_XCODE_ATTRIBUTE_DEBUG_INFORMATION_FORMAT[variant=RelWithDebInfo] dwarf)
set(CMAKE_XCODE_ATTRIBUTE_DEBUG_INFORMATION_FORMAT[variant=Release] dwarf-with-dsym)
set(CMAKE_XCODE_ATTRIBUTE_DEBUG_INFORMATION_FORMAT[variant=MinSizeRel] dwarf-with-dsym)
# Make all symbols hidden by default (currently overriden by CMake's compiler flags)
set(CMAKE_XCODE_ATTRIBUTE_GCC_SYMBOLS_PRIVATE_EXTERN YES)
set(CMAKE_XCODE_ATTRIBUTE_GCC_INLINES_ARE_PRIVATE_EXTERN YES)
# Strip unused code
set(CMAKE_XCODE_ATTRIBUTE_DEAD_CODE_STRIPPING YES)
# Display mangled names in Debug configuration
set(CMAKE_XCODE_ATTRIBUTE_LINKER_DISPLAYS_MANGLED_NAMES[variant=Debug] YES)
# Build active architecture only in Debug configuration
set(CMAKE_XCODE_ATTRIBUTE_ONLY_ACTIVE_ARCH[variant=Debug] YES)
# Enable testability in Debug configuration
set(CMAKE_XCODE_ATTRIBUTE_ENABLE_TESTABILITY[variant=Debug] YES)
# Enable using ARC in ObjC by default
set(CMAKE_XCODE_ATTRIBUTE_CLANG_ENABLE_OBJC_ARC YES)
# Enable weak references in manual retain release
set(CMAKE_XCODE_ATTRIBUTE_CLANG_ENABLE_OBJC_WEAK YES)
# Disable strict aliasing
set(CMAKE_XCODE_ATTRIBUTE_GCC_STRICT_ALIASING NO)
# Set C++ language default to c17
#
# * CMake explicitly sets the version via compiler flag when transitive dependencies require specific compiler feature
# set, resulting in the flag being added twice. Report to KitWare as a feature request for Xcode generator
# * See also: https://gitlab.kitware.com/cmake/cmake/-/issues/17183
#
# set(CMAKE_XCODE_ATTRIBUTE_GCC_C_LANGUAGE_STANDARD c17)
#
# Set C++ language default to c++17
#
# * See above. Report to KitWare as a feature request for Xcode generator
#
# set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LANGUAGE_STANDARD c++17)
# Enable support for module imports in ObjC
set(CMAKE_XCODE_ATTRIBUTE_CLANG_ENABLE_MODULES YES)
# Enable automatic linking of imported modules in ObjC
set(CMAKE_XCODE_ATTRIBUTE_CLANG_MODULES_AUTOLINK YES)
# Enable strict msg_send rules for ObjC
set(CMAKE_XCODE_ATTRIBUTE_ENABLE_STRICT_OBJC_MSGSEND YES)
# Set default warnings for ObjC and C++
set(CMAKE_XCODE_ATTRIBUTE_CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING YES_ERROR)
set(CMAKE_XCODE_ATTRIBUTE_CLANG_WARN_BOOL_CONVERSION YES)
set(CMAKE_XCODE_ATTRIBUTE_CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS YES)
set(CMAKE_XCODE_ATTRIBUTE_CLANG_WARN_COMMA YES)
set(CMAKE_XCODE_ATTRIBUTE_CLANG_WARN_CONSTANT_CONVERSION YES)
set(CMAKE_XCODE_ATTRIBUTE_CLANG_WARN_EMPTY_BODY YES)
set(CMAKE_XCODE_ATTRIBUTE_CLANG_WARN_ENUM_CONVERSION YES)
set(CMAKE_XCODE_ATTRIBUTE_CLANG_WARN_INFINITE_RECURSION YES)
set(CMAKE_XCODE_ATTRIBUTE_CLANG_WARN_INT_CONVERSION YES)
set(CMAKE_XCODE_ATTRIBUTE_CLANG_WARN_NON_LITERAL_NULL_CONVERSION YES)
set(CMAKE_XCODE_ATTRIBUTE_CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF YES)
set(CMAKE_XCODE_ATTRIBUTE_CLANG_WARN_OBJC_LITERAL_CONVERSION YES)
set(CMAKE_XCODE_ATTRIBUTE_CLANG_WARN_OBJC_REPEATED_USE_OF_WEAK YES)
set(CMAKE_XCODE_ATTRIBUTE_CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER YES)
set(CMAKE_XCODE_ATTRIBUTE_CLANG_WARN_RANGE_LOOP_ANALYSIS YES)
set(CMAKE_XCODE_ATTRIBUTE_CLANG_WARN_STRICT_PROTOTYPES NO)
set(CMAKE_XCODE_ATTRIBUTE_CLANG_WARN_SUSPICIOUS_IMPLICIT_CONVERSION NO)
set(CMAKE_XCODE_ATTRIBUTE_CLANG_WARN_SUSPICIOUS_MOVE YES)
set(CMAKE_XCODE_ATTRIBUTE_CLANG_WARN_UNREACHABLE_CODE YES)
set(CMAKE_XCODE_ATTRIBUTE_CLANG_WARN__DUPLICATE_METHOD_MATCH YES)
# Set default warnings for C and C++
set(CMAKE_XCODE_ATTRIBUTE_GCC_NO_COMMON_BLOCKS YES)
set(CMAKE_XCODE_ATTRIBUTE_GCC_WARN_64_TO_32_BIT_CONVERSION YES)
set(CMAKE_XCODE_ATTRIBUTE_GCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS NO)
set(CMAKE_XCODE_ATTRIBUTE_GCC_WARN_ABOUT_MISSING_NEWLINE YES)
set(CMAKE_XCODE_ATTRIBUTE_GCC_WARN_ABOUT_RETURN_TYPE YES_ERROR)
set(CMAKE_XCODE_ATTRIBUTE_GCC_WARN_CHECK_SWITCH_STATEMENTS YES)
set(CMAKE_XCODE_ATTRIBUTE_GCC_WARN_FOUR_CHARACTER_CONSTANTS YES)
set(CMAKE_XCODE_ATTRIBUTE_GCC_WARN_SHADOW NO)
set(CMAKE_XCODE_ATTRIBUTE_GCC_WARN_SIGN_COMPARE YES)
set(CMAKE_XCODE_ATTRIBUTE_GCC_WARN_TYPECHECK_CALLS_TO_PRINTF YES)
set(CMAKE_XCODE_ATTRIBUTE_GCC_WARN_UNDECLARED_SELECTOR YES)
set(CMAKE_XCODE_ATTRIBUTE_GCC_WARN_UNINITIALIZED_AUTOS YES)
set(CMAKE_XCODE_ATTRIBUTE_GCC_WARN_UNUSED_FUNCTION NO)
set(CMAKE_XCODE_ATTRIBUTE_GCC_WARN_UNUSED_PARAMETER YES)
set(CMAKE_XCODE_ATTRIBUTE_GCC_WARN_UNUSED_VALUE YES)
set(CMAKE_XCODE_ATTRIBUTE_GCC_WARN_UNUSED_VARIABLE YES)
# Add additional warning compiler flags
set(CMAKE_XCODE_ATTRIBUTE_WARNING_CFLAGS "-Wvla -Wformat-security")
if(CMAKE_COMPILE_WARNING_AS_ERROR)
set(CMAKE_XCODE_ATTRIBUTE_GCC_TREAT_WARNINGS_AS_ERRORS YES)
endif()
# Enable color diagnostics
set(CMAKE_COLOR_DIAGNOSTICS TRUE)
# Disable usage of RPATH in build or install configurations
set(CMAKE_SKIP_RPATH TRUE)
# Have Xcode set default RPATH entries
set(CMAKE_XCODE_ATTRIBUTE_LD_RUNPATH_SEARCH_PATHS "@executable_path/../Frameworks")

View File

@ -0,0 +1,24 @@
# CMake Windows build dependencies module
include_guard(GLOBAL)
include(buildspec_common)
# _check_dependencies_windows: Set up Windows slice for _check_dependencies
function(_check_dependencies_windows)
set(arch ${CMAKE_GENERATOR_PLATFORM})
set(platform windows-${arch})
set(dependencies_dir "${CMAKE_CURRENT_SOURCE_DIR}/.deps")
set(prebuilt_filename "windows-deps-VERSION-ARCH-REVISION.zip")
set(prebuilt_destination "obs-deps-VERSION-ARCH")
set(qt6_filename "windows-deps-qt6-VERSION-ARCH-REVISION.zip")
set(qt6_destination "obs-deps-qt6-VERSION-ARCH")
set(obs-studio_filename "VERSION.zip")
set(obs-studio_destination "obs-studio-VERSION")
set(dependencies_list prebuilt qt6 obs-studio)
_check_dependencies()
endfunction()
_check_dependencies_windows()

View File

@ -0,0 +1,53 @@
# CMake Windows compiler configuration module
include_guard(GLOBAL)
include(compiler_common)
# CMake 3.24 introduces a bug mistakenly interpreting MSVC as supporting the '-pthread' compiler flag
if(CMAKE_VERSION VERSION_EQUAL 3.24.0)
set(THREADS_HAVE_PTHREAD_ARG FALSE)
endif()
# CMake 3.25 changed the way symbol generation is handled on Windows
if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.25.0)
if(CMAKE_C_COMPILER_ID STREQUAL "MSVC")
set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT ProgramDatabase)
else()
set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT Embedded)
endif()
endif()
message(DEBUG "Current Windows API version: ${CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION}")
if(CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION_MAXIMUM)
message(DEBUG "Maximum Windows API version: ${CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION_MAXIMUM}")
endif()
if(CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION VERSION_LESS 10.0.20348)
message(FATAL_ERROR "OBS requires Windows 10 SDK version 10.0.20348.0 or more recent.\n"
"Please download and install the most recent Windows platform SDK.")
endif()
add_compile_options(
/W3
/utf-8
"$<$<COMPILE_LANG_AND_ID:C,MSVC>:/MP>"
"$<$<COMPILE_LANG_AND_ID:CXX,MSVC>:/MP>"
"$<$<COMPILE_LANG_AND_ID:C,Clang>:${_obs_clang_c_options}>"
"$<$<COMPILE_LANG_AND_ID:CXX,Clang>:${_obs_clang_cxx_options}>"
$<$<NOT:$<CONFIG:Debug>>:/Gy>)
add_compile_definitions(UNICODE _UNICODE _CRT_SECURE_NO_WARNINGS _CRT_NONSTDC_NO_WARNINGS $<$<CONFIG:DEBUG>:DEBUG>
$<$<CONFIG:DEBUG>:_DEBUG>)
# cmake-format: off
add_link_options($<$<NOT:$<CONFIG:Debug>>:/OPT:REF>
$<$<NOT:$<CONFIG:Debug>>:/OPT:ICF>
$<$<NOT:$<CONFIG:Debug>>:/INCREMENTAL:NO>
/DEBUG
/Brepro)
# cmake-format: on
if(CMAKE_COMPILE_WARNING_AS_ERROR)
add_link_options(/WX)
endif()

View File

@ -0,0 +1,8 @@
# CMake Windows defaults module
include_guard(GLOBAL)
# Enable find_package targets to become globally available targets
set(CMAKE_FIND_PACKAGE_TARGETS_GLOBAL TRUE)
include(buildspec)

131
cmake/windows/helpers.cmake Normal file
View File

@ -0,0 +1,131 @@
# CMake Windows helper functions module
# cmake-format: off
# cmake-lint: disable=C0103
# cmake-format: on
include_guard(GLOBAL)
include(helpers_common)
# set_target_properties_plugin: Set target properties for use in obs-studio
function(set_target_properties_plugin target)
set(options "")
set(oneValueArgs "")
set(multiValueArgs PROPERTIES)
cmake_parse_arguments(PARSE_ARGV 0 _STPO "${options}" "${oneValueArgs}" "${multiValueArgs}")
message(DEBUG "Setting additional properties for target ${target}...")
while(_STPO_PROPERTIES)
list(POP_FRONT _STPO_PROPERTIES key value)
set_property(TARGET ${target} PROPERTY ${key} "${value}")
endwhile()
string(TIMESTAMP CURRENT_YEAR "%Y")
set_target_properties(${target} PROPERTIES VERSION 0 SOVERSION ${PLUGIN_VERSION})
install(
TARGETS ${target}
RUNTIME DESTINATION bin/64bit
LIBRARY DESTINATION obs-plugins/64bit)
install(
FILES "$<TARGET_PDB_FILE:${target}>"
CONFIGURATIONS RelWithDebInfo Debug Release
DESTINATION obs-plugins/64bit
OPTIONAL)
if(OBS_BUILD_DIR)
add_custom_command(
TARGET ${target}
POST_BUILD
COMMAND "${CMAKE_COMMAND}" -E make_directory "${OBS_BUILD_DIR}/obs-plugins/64bit"
COMMAND
"${CMAKE_COMMAND}" -E copy_if_different "$<TARGET_FILE:${target}>"
"$<$<CONFIG:Debug,RelWithDebInfo,Release>:$<TARGET_PDB_FILE:${target}>>" "${OBS_BUILD_DIR}/obs-plugins/64bit"
COMMENT "Copy ${target} to obs-studio directory ${OBS_BUILD_DIR}"
VERBATIM)
endif()
if(TARGET plugin-support)
target_link_libraries(${target} PRIVATE plugin-support)
endif()
target_install_resources(${target})
get_target_property(target_sources ${target} SOURCES)
set(target_ui_files ${target_sources})
list(FILTER target_ui_files INCLUDE REGEX ".+\\.(ui|qrc)")
source_group(
TREE "${CMAKE_CURRENT_SOURCE_DIR}"
PREFIX "UI Files"
FILES ${target_ui_files})
set(valid_uuid FALSE)
check_uuid(${_windowsAppUUID} valid_uuid)
if(NOT valid_uuid)
message(FATAL_ERROR "Specified Windows package UUID is not a valid UUID value: ${_windowsAppUUID}")
else()
set(UUID_APP ${_windowsAppUUID})
endif()
configure_file(cmake/windows/resources/installer-Windows.iss.in
"${CMAKE_CURRENT_BINARY_DIR}/installer-Windows.generated.iss")
configure_file(cmake/windows/resources/resource.rc.in "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_PROJECT_NAME}.rc")
target_sources(${CMAKE_PROJECT_NAME} PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_PROJECT_NAME}.rc")
endfunction()
# Helper function to add resources into bundle
function(target_install_resources target)
message(DEBUG "Installing resources for target ${target}...")
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/data")
file(GLOB_RECURSE data_files "${CMAKE_CURRENT_SOURCE_DIR}/data/*")
foreach(data_file IN LISTS data_files)
cmake_path(RELATIVE_PATH data_file BASE_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/data/" OUTPUT_VARIABLE
relative_path)
cmake_path(GET relative_path PARENT_PATH relative_path)
target_sources(${target} PRIVATE "${data_file}")
source_group("Resources/${relative_path}" FILES "${data_file}")
endforeach()
install(
DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/data/"
DESTINATION data/obs-plugins/${target}
USE_SOURCE_PERMISSIONS)
if(OBS_BUILD_DIR)
add_custom_command(
TARGET ${target}
POST_BUILD
COMMAND "${CMAKE_COMMAND}" -E make_directory "${OBS_BUILD_DIR}/data/obs-plugins/${target}"
COMMAND "${CMAKE_COMMAND}" -E copy_directory "${CMAKE_CURRENT_SOURCE_DIR}/data"
"${OBS_BUILD_DIR}/data/obs-plugins/${target}"
COMMENT "Copy ${target} resources to data directory"
VERBATIM)
endif()
endif()
endfunction()
# Helper function to add a specific resource to a bundle
function(target_add_resource target resource)
message(DEBUG "Add resource '${resource}' to target ${target} at destination '${target_destination}'...")
install(
FILES "${resource}"
DESTINATION data/obs-plugins/${target}
COMPONENT Runtime)
if(OBS_BUILD_DIR)
add_custom_command(
TARGET ${target}
POST_BUILD
COMMAND "${CMAKE_COMMAND}" -E make_directory "${OBS_BUILD_DIR}/data/obs-plugins/${target}"
COMMAND "${CMAKE_COMMAND}" -E copy "${resource}" "${OBS_BUILD_DIR}/data/obs-plugins/${target}"
COMMENT "Copy ${target} resource ${resource} to library directory"
VERBATIM)
endif()
source_group("Resources" FILES "${resource}")
endfunction()

View File

@ -0,0 +1,64 @@
#define MyAppName "@CMAKE_PROJECT_NAME@"
#define MyAppVersion "@CMAKE_PROJECT_VERSION@"
#define MyAppPublisher "@PLUGIN_AUTHOR@"
#define MyAppURL "@PLUGIN_WEBSITE@"
[Setup]
; NOTE: The value of AppId uniquely identifies this application.
; Do not use the same AppId value in installers for other applications.
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
AppId={{@UUID_APP@}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName={code:GetDirName}
DefaultGroupName={#MyAppName}
OutputBaseFilename={#MyAppName}-{#MyAppVersion}-Windows-Installer
Compression=lzma
SolidCompression=yes
DirExistsWarning=no
[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"
[Files]
Source: "..\release\Package\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
Source: "..\LICENSE"; Flags: dontcopy
; NOTE: Don't use "Flags: ignoreversion" on any shared system files
[Icons]
Name: "{group}\{cm:ProgramOnTheWeb,{#MyAppName}}"; Filename: "{#MyAppURL}"
Name: "{group}\{cm:UninstallProgram,{#MyAppName}}"; Filename: "{uninstallexe}"
[Code]
procedure InitializeWizard();
var
GPLText: AnsiString;
Page: TOutputMsgMemoWizardPage;
begin
ExtractTemporaryFile('LICENSE');
LoadStringFromFile(ExpandConstant('{tmp}\LICENSE'), GPLText);
Page := CreateOutputMsgMemoPage(wpWelcome,
'License Information', 'Please review the license terms before installing {#MyAppName}',
'Press Page Down to see the rest of the agreement. Once you are aware of your rights, click Next to continue.',
String(GPLText)
);
end;
// credit where it's due :
// following function come from https://github.com/Xaymar/obs-studio_amf-encoder-plugin/blob/master/%23Resources/Installer.in.iss#L45
function GetDirName(Value: string): string;
var
InstallPath: string;
begin
// initialize default path, which will be returned when the following registry
// key queries fail due to missing keys or for some different reason
Result := '{autopf}\obs-studio';
// query the first registry value; if this succeeds, return the obtained value
if RegQueryStringValue(HKLM32, 'SOFTWARE\OBS Studio', '', InstallPath) then
Result := InstallPath
end;

View File

@ -0,0 +1,32 @@
1 VERSIONINFO
FILEVERSION ${PROJECT_VERSION_MAJOR},${PROJECT_VERSION_MINOR},${PROJECT_VERSION_PATCH},0
PRODUCTVERSION ${PROJECT_VERSION_MAJOR},${PROJECT_VERSION_MINOR},${PROJECT_VERSION_PATCH},0
FILEFLAGSMASK 0x0L
#ifdef _DEBUG
FILEFLAGS 0x1L
#else
FILEFLAGS 0x0L
#endif
FILEOS 0x0L
FILETYPE 0x2L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904b0"
BEGIN
VALUE "CompanyName", "${PLUGIN_AUTHOR}"
VALUE "FileDescription", "${PROJECT_NAME}"
VALUE "FileVersion", "${PROJECT_VERSION}"
VALUE "InternalName", "${PROJECT_NAME}"
VALUE "LegalCopyright", "(C) ${CURRENT_YEAR} ${PLUGIN_AUTHOR}"
VALUE "OriginalFilename", "${PROJECT_NAME}"
VALUE "ProductName", "${PROJECT_NAME}"
VALUE "ProductVersion", "${PROJECT_VERSION}"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x409, 1200
END
END

Some files were not shown because too many files have changed in this diff Show More