Skip to content
Merged
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
1 change: 1 addition & 0 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ PenaltyReturnTypeOnItsOwnLine: 60

PointerAlignment: Right
ReflowComments: false
SkipMacroDefinitionBody: true
SortIncludes: false
SortUsingDeclarations: false
SpaceAfterCStyleCast: false
Expand Down
8 changes: 4 additions & 4 deletions .github/actions/run-clang-format/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ runs:
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@17/bin" >> $GITHUB_PATH
echo "/home/linuxbrew/.linuxbrew/opt/clang-format@19/bin" >> $GITHUB_PATH
brew install --quiet zsh
echo ::endgroup::

Expand All @@ -50,11 +50,11 @@ runs:
: Run clang-format 🐉
if (( ${+RUNNER_DEBUG} )) setopt XTRACE

print ::group::Install clang-format-17
brew install --quiet obsproject/tools/clang-format@17
print ::group::Install clang-format-19
brew install --quiet obsproject/tools/clang-format@19
print ::endgroup::

print ::group::Run clang-format-17
print ::group::Run clang-format-19
local -a changes=(${(s:,:)CHANGED_FILES//[\[\]\'\"]/})
./build-aux/run-clang-format --fail-${{ inputs.failCondition }} --check ${changes}
print ::endgroup::
33 changes: 19 additions & 14 deletions build-aux/.run-format.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -33,28 +33,28 @@ invoke_formatter() {

case ${formatter} {
clang)
if (( ${+commands[clang-format-17]} )) {
local formatter=clang-format-17
if (( ${+commands[clang-format-19]} )) {
local formatter=clang-format-19
} elif (( ${+commands[clang-format]} )) {
local formatter=clang-format
} else {
log_error "No viable clang-format version found (required 17.0.3)"
log_error "No viable clang-format version found (required 19.1.1)"
exit 2
}

local -a formatter_version=($(${formatter} --version))

if ! is-at-least 17.0.3 ${formatter_version[-1]}; then
log_error "clang-format is not version 17.0.3 or above (found ${formatter_version[-1]}."
if ! is-at-least 19.1.1 ${formatter_version[-1]}; then
log_error "clang-format is not version 19.1.1 or above (found ${formatter_version[-1]}."
exit 2
fi

if ! is-at-least ${formatter_version[-1]} 17.0.3; then
log_error "clang-format is more recent than version 17.0.3 (found ${formatter_version[-1]})."
if ! is-at-least ${formatter_version[-1]} 19.1.1; then
log_error "clang-format is more recent than version 19.1.1 (found ${formatter_version[-1]})."
exit 2
fi

if (( ! #source_files )) source_files=((libobs|libobs-*|UI|plugins|deps|shared)/**/*.(c|cpp|h|hpp|m|mm)(.N))
if (( ! #source_files )) source_files=((libobs|libobs-*|frontend|plugins|deps|shared|test)/**/*.(c|cpp|h|hpp|m|mm)(.N))

source_files=(${source_files:#*/(obs-websocket/deps|decklink/*/decklink-sdk|mac-syphon/syphon-framework|libdshowcapture)/*})

Expand Down Expand Up @@ -96,13 +96,13 @@ invoke_formatter() {
if (( ${+commands[gersemi]} )) {
local gersemi_version=($(gersemi --version))

if ! is-at-least 0.12.0 ${gersemi_version[2]}; then
log_error "gersemi is not version 0.12.0 or above (found ${gersemi_version[2]}."
if ! is-at-least 0.21.0 ${gersemi_version[2]}; then
log_error "gersemi is not version 0.21.0 or above (found ${gersemi_version[2]}."
exit 2
fi
}

if (( ! #source_files )) source_files=(CMakeLists.txt (libobs|libobs-*|UI|plugins|deps|shared|cmake|test)/**/(CMakeLists.txt|*.cmake)(.N))
if (( ! #source_files )) source_files=(CMakeLists.txt (libobs|libobs-*|frontend|plugins|deps|shared|cmake|test)/**/(CMakeLists.txt|*.cmake)(.N))

source_files=(${source_files:#*/(jansson|decklink/*/decklink-sdk|obs-websocket|obs-browser|libdshowcapture)/*})
source_files=(${source_files:#(cmake/Modules/*|*/legacy.cmake)})
Expand All @@ -116,9 +116,13 @@ invoke_formatter() {
if (( ${#source_files} )) {
while read -r line; do
local -a line_tokens=(${(z)line})
file=${line_tokens[1]//*obs-studio\//}
if (( #line_tokens )) {
file=${line_tokens[1]//*${project_root}\//}

log_error "${file} requires formatting changes."
log_error "${file} requires formatting changes."
} else {
log_error "${line}"
}

if (( fail_on_error == 2 )) return 2
num_failures=$(( num_failures + 1 ))
Expand Down Expand Up @@ -150,7 +154,7 @@ invoke_formatter() {
exit 2
}

if (( ! #source_files )) source_files=((libobs|libobs-*|UI|plugins)/**/*.swift(.N))
if (( ! #source_files )) source_files=((libobs|libobs-*|frontend|plugins)/**/*.swift(.N))

check_files() {
local -i num_failures=0
Expand Down Expand Up @@ -205,6 +209,7 @@ invoke_formatter() {
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]}
local project_root=${SCRIPT_HOME:A:h}

typeset -g host_os=${${(L)$(uname -s)}//darwin/macos}
local -i fail_on_error=0
Expand Down
4 changes: 2 additions & 2 deletions obs-browser-plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -454,10 +454,10 @@ void RegisterBrowserSource()
static_cast<BrowserSource *>(data)->Update(settings);
};
info.get_width = [](void *data) {
return (uint32_t) static_cast<BrowserSource *>(data)->width;
return (uint32_t)static_cast<BrowserSource *>(data)->width;
};
info.get_height = [](void *data) {
return (uint32_t) static_cast<BrowserSource *>(data)->height;
return (uint32_t)static_cast<BrowserSource *>(data)->height;
};
info.video_tick = [](void *data, float) {
static_cast<BrowserSource *>(data)->Tick();
Expand Down