diff --git a/.clang-format b/.clang-format index a10cf9586..73c5b0faa 100644 --- a/.clang-format +++ b/.clang-format @@ -81,6 +81,7 @@ PenaltyReturnTypeOnItsOwnLine: 60 PointerAlignment: Right ReflowComments: false +SkipMacroDefinitionBody: true SortIncludes: false SortUsingDeclarations: false SpaceAfterCStyleCast: false diff --git a/.github/actions/run-clang-format/action.yaml b/.github/actions/run-clang-format/action.yaml index 94dea0840..669fe8e10 100644 --- a/.github/actions/run-clang-format/action.yaml +++ b/.github/actions/run-clang-format/action.yaml @@ -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:: @@ -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:: diff --git a/build-aux/.run-format.zsh b/build-aux/.run-format.zsh index 26c92f8f1..ab74d2835 100755 --- a/build-aux/.run-format.zsh +++ b/build-aux/.run-format.zsh @@ -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)/*}) @@ -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)}) @@ -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 )) @@ -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 @@ -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 diff --git a/obs-browser-plugin.cpp b/obs-browser-plugin.cpp index 63ac62bfb..4d9233e37 100644 --- a/obs-browser-plugin.cpp +++ b/obs-browser-plugin.cpp @@ -454,10 +454,10 @@ void RegisterBrowserSource() static_cast(data)->Update(settings); }; info.get_width = [](void *data) { - return (uint32_t) static_cast(data)->width; + return (uint32_t)static_cast(data)->width; }; info.get_height = [](void *data) { - return (uint32_t) static_cast(data)->height; + return (uint32_t)static_cast(data)->height; }; info.video_tick = [](void *data, float) { static_cast(data)->Tick();