Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Update plugin template repository with code changes from obs-studio repository #126

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ BreakBeforeBraces: Custom
BreakBeforeTernaryOperators: true
BreakConstructorInitializers: BeforeColon
BreakStringLiterals: false # apparently unpredictable
ColumnLimit: 80
ColumnLimit: 120
CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: true
ConstructorInitializerIndentWidth: 8
Expand Down
31 changes: 0 additions & 31 deletions .cmake-format.json

This file was deleted.

11 changes: 11 additions & 0 deletions .gersemirc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# yaml-language-server: $schema=https://raw.githubusercontent.com/BlankSpruce/gersemi/master/gersemi/configuration.schema.json

color: false
definitions: []
line_length: 120
indent: 2
list_expansion: favour-inlining
quiet: false
unsafe: false
workers: 10
warn_about_unknown_commands: false
25 changes: 14 additions & 11 deletions .github/actions/build-plugin/action.yaml
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
name: 'Set up and build plugin'
description: 'Builds the plugin for specified architecture and build config'
name: Set up and build plugin
description: Builds the plugin for specified architecture and build config
inputs:
target:
description: 'Target architecture for dependencies'
description: Target architecture for dependencies
required: true
config:
description: 'Build configuration'
description: Build configuration
required: false
default: 'RelWithDebInfo'
default: RelWithDebInfo
codesign:
description: 'Enable codesigning (macOS only)'
description: Enable codesigning (macOS only)
required: false
default: 'false'
codesignIdent:
description: 'Developer ID for application codesigning (macOS only)'
description: Developer ID for application codesigning (macOS only)
required: false
default: '-'
workingDirectory:
description: 'Working directory for packaging'
description: Working directory for packaging
required: false
default: ${{ github.workspace }}
runs:
Expand All @@ -28,6 +28,7 @@ runs:
shell: zsh --no-rcs --errexit --pipefail {0}
working-directory: ${{ inputs.workingDirectory }}
env:
CCACHE_DIR: ${{ inputs.workingDirectory }}/.ccache
CODESIGN_IDENT: ${{ inputs.codesignIdent }}
CODESIGN_TEAM: ${{ inputs.codesignTeam }}
run: |
Expand Down Expand Up @@ -55,16 +56,18 @@ runs:
if: runner.os == 'Linux'
shell: zsh --no-rcs --errexit --pipefail {0}
working-directory: ${{ inputs.workingDirectory }}
env:
CCACHE_DIR: ${{ inputs.workingDirectory }}/.ccache
run: |
: Run Ubuntu Build

local -a build_args=(
--target linux-${{ inputs.target }}
--target ubuntu-${{ inputs.target }}
--config ${{ inputs.config }}
)
if (( ${+RUNNER_DEBUG} )) build_args+=(--debug)

.github/scripts/build-linux ${build_args}
.github/scripts/build-ubuntu ${build_args}

- name: Run Windows Build
if: runner.os == 'Windows'
Expand All @@ -86,7 +89,7 @@ runs:
if: contains(fromJSON('["Linux", "macOS"]'),runner.os)
shell: zsh --no-rcs --errexit --pipefail {0}
env:
CCACHE_CONFIGPATH: ${{ inputs.workingDirectory }}/.ccache.conf
CCACHE_DIR: ${{ inputs.workingDirectory }}/.ccache
run: |
: Create Summary 📊

Expand Down
77 changes: 77 additions & 0 deletions .github/actions/check-changes/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
name: Check For Changed Files
description: Checks for changed files compared to specific git reference and glob expression
inputs:
baseRef:
description: Git reference to check against
required: false
ref:
description: Git reference to check with
required: false
default: HEAD
checkGlob:
description: Glob expression to limit check to specific files
required: false
useFallback:
description: Use fallback compare against prior commit
required: false
default: 'true'
diffFilter:
description: git diff-filter string to use
required: false
default: ''
outputs:
hasChangedFiles:
value: ${{ steps.checks.outputs.hasChangedFiles }}
description: True if specified files were changed in comparison to specified git reference
changedFiles:
value: ${{ steps.checks.outputs.changedFiles }}
description: List of changed files
runs:
using: composite
steps:
- name: Check For Changed Files ✅
shell: bash
id: checks
env:
GIT_BASE_REF: ${{ inputs.baseRef }}
GIT_REF: ${{ inputs.ref }}
GITHUB_EVENT_FORCED: ${{ github.event.forced }}
GITHUB_REF_BEFORE: ${{ github.event.before }}
USE_FALLBACK: ${{ inputs.useFallback }}
DIFF_FILTER: ${{ inputs.diffFilter }}
run: |
: Check for Changed Files ✅
if [[ "${RUNNER_DEBUG}" ]]; then set -x; fi
shopt -s extglob
shopt -s dotglob

if [[ "${GIT_BASE_REF}" ]]; then
if ! git cat-file -e "${GIT_BASE_REF}" &> /dev/null; then
echo "::warning::Provided base reference ${GIT_BASE_REF} is invalid"
if [[ "${USE_FALLBACK}" == 'true' ]]; then
GIT_BASE_REF='HEAD~1'
fi
fi
else
if ! git cat-file -e ${GITHUB_REF_BEFORE} &> /dev/null; then
GITHUB_REF_BEFORE='4b825dc642cb6eb9a060e54bf8d69288fbee4904'
fi

GIT_BASE_REF='HEAD~1'
case "${GITHUB_EVENT_NAME}" in
pull_request) GIT_BASE_REF="origin/${GITHUB_BASE_REF}" ;;
push) if [[ "${GITHUB_EVENT_FORCED}" != 'true' ]]; then GIT_BASE_REF="${GITHUB_REF_BEFORE}"; fi ;;
*) ;;
esac
fi

changes=($(git diff --name-only --diff-filter="${DIFF_FILTER}" ${GIT_BASE_REF} ${GIT_REF} -- ${{ inputs.checkGlob }}))

if (( ${#changes[@]} )); then
file_string="${changes[*]}"
echo "hasChangedFiles=true" >> $GITHUB_OUTPUT
echo "changedFiles=[\"${file_string// /\",\"}\"]" >> $GITHUB_OUTPUT
else
echo "hasChangedFiles=false" >> $GITHUB_OUTPUT
echo "changedFiles=[]" >> GITHUB_OUTPUT
fi
36 changes: 16 additions & 20 deletions .github/actions/package-plugin/action.yaml
Original file line number Diff line number Diff line change
@@ -1,47 +1,47 @@
name: 'Package plugin'
description: 'Packages the plugin for specified architecture and build config.'
name: Package plugin
description: Packages the plugin for specified architecture and build config.
inputs:
target:
description: 'Build target for dependencies'
description: Build target for dependencies
required: true
config:
description: 'Build configuration'
description: Build configuration
required: false
default: 'RelWithDebInfo'
default: RelWithDebInfo
codesign:
description: 'Enable codesigning (macOS only)'
description: Enable codesigning (macOS only)
required: false
default: 'false'
notarize:
description: 'Enable notarization (macOS only)'
description: Enable notarization (macOS only)
required: false
default: 'false'
codesignIdent:
description: 'Developer ID for application codesigning (macOS only)'
description: Developer ID for application codesigning (macOS only)
required: false
default: '-'
installerIdent:
description: 'Developer ID for installer package codesigning (macOS only)'
description: Developer ID for installer package codesigning (macOS only)
required: false
default: ''
codesignTeam:
description: 'Developer team for codesigning (macOS only)'
description: Developer team for codesigning (macOS only)
required: false
default: ''
codesignUser:
description: 'Apple ID username for notarization (macOS only)'
description: Apple ID username for notarization (macOS only)
required: false
default: ''
codesignPass:
description: 'Apple ID password for notarization (macOS only)'
description: Apple ID password for notarization (macOS only)
required: false
default: ''
package:
description: 'Create Windows or macOS installation package'
description: Create Windows or macOS installation package
required: false
default: 'false'
workingDirectory:
description: 'Working directory for packaging'
description: Working directory for packaging
required: false
default: ${{ github.workspace }}
runs:
Expand Down Expand Up @@ -87,14 +87,14 @@ runs:
run: |
: Run Ubuntu Packaging
package_args=(
--target linux-${{ inputs.target }}
--target ubuntu-${{ inputs.target }}
--config ${{ inputs.config }}
)
if (( ${+RUNNER_DEBUG} )) build_args+=(--debug)

if [[ '${{ inputs.package }}' == 'true' ]] package_args+=(--package)

.github/scripts/package-linux ${package_args}
.github/scripts/package-ubuntu ${package_args}

- name: Run Windows Packaging
if: runner.os == 'Windows'
Expand All @@ -110,8 +110,4 @@ runs:
Configuration = '${{ inputs.config }}'
}

if ( '${{ inputs.package }}' -eq 'true' ) {
$PackageArgs += @{BuildInstaller = $true}
}

.github/scripts/Package-Windows.ps1 @PackageArgs
37 changes: 18 additions & 19 deletions .github/actions/run-clang-format/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ inputs:
failCondition:
description: Controls whether failed checks also fail the workflow run
required: false
default: 'never'
default: never
workingDirectory:
description: Working directory for checks
required: false
Expand All @@ -20,8 +20,15 @@ runs:
echo "::notice::run-clang-format action requires a macOS-based or Linux-based runner."
exit 2

- name: Check for Changed Files ✅
uses: ./.github/actions/check-changes
id: checks
with:
checkGlob: "'*.c' '*.h' '*.cpp' '*.hpp' '*.m' '*.mm'"
diffFilter: 'ACM'

- name: Install Dependencies 🛍️
if: runner.os == 'Linux'
if: runner.os == 'Linux' && fromJSON(steps.checks.outputs.hasChangedFiles)
shell: bash
run: |
: Install Dependencies 🛍️
Expand All @@ -33,29 +40,21 @@ runs:
echo ::endgroup::

- name: Run clang-format 🐉
if: fromJSON(steps.checks.outputs.hasChangedFiles)
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 }}
CHANGED_FILES: ${{ steps.checks.outputs.changedFiles }}
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-17
brew install --quiet obsproject/tools/clang-format@17
echo ::endgroup::
print ::group::Install clang-format-17
brew install --quiet obsproject/tools/clang-format@17
print ::endgroup::

echo ::group::Run clang-format-17
./build-aux/run-clang-format --fail-${{ inputs.failCondition }} --check
echo ::endgroup::
}
print ::group::Run clang-format-17
local -a changes=(${(s:,:)CHANGED_FILES//[\[\]\'\"]/})
./build-aux/run-clang-format --fail-${{ inputs.failCondition }} --check ${changes}
print ::endgroup::
Loading
Loading