build-aux: Update formatter and linter scripts - #13743
Open
PatTheMav wants to merge 6 commits into
Open
Conversation
Suppresses some warnings emitted by swift-format's linting report: * "AlwaysUseLowerCamelCase" does not apply to functions exposed via C ABI for interoperability with libobs * "AvoidRetroactiveConformances" has to be violated in the select instances in code (the decoration itself is used to silence a compiler warning).
Version 0.28.0 of gersemi has support for "REGEX REPLACE" string operations and thus reverts the worse formatting introduced by a prior version.
The updated script works as a formatter and linter launcher and is now available for Zsh, Bash, and Powershell. Symbolic links serve as easy entry points for the linter and use the same universal launcher script (which is compatible with Csh and Powershell) and identifies the desired linter by the used file name. Because Powershell only executes script files that carry the ".ps1" suffix, separate variants for Windows need to be provided, but still all point to the same universal launcher under the hood. New features: * Bash version for linting and formatting * Powershell version for linting and formatting * Zizmor linting for GitHub Actions workflows * Xmllint linting * Linting only checks files but does not format them * Linting mode has special "GitHub" syntax to annotate failed files
Updates invocations of the underlying format check script to the new version of the script.
PatTheMav
force-pushed
the
formatter-update
branch
from
August 6, 2026 14:31
8426d7b to
95e4c65
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds updated Bash, Zsh, and PowerShell scripts to run linters on the repository and adds support for Zizmor and
xmllint.The linter scripts are also capable of producing annotations in GitHub Actions format for later use in updated GitHub Actions workflows.
Because
swift-formatis now used inlintmode, additional code changes had to be made to meet the stricter demands of its linting mode.Changes to CMake files are in preparation for current
gersemiversions which can now handlestring'sREGEX REPLACEcommand correctly.Motivation and Context
The main motivation is to provide linting and formatting scripts that can be used on the main supported platforms (Windows, macOS, and Linux) within their "native" scripting environments (Powershell, Zsh, and Bash, respectively).
The scripts will not install the formatters or linters (this exercise is left to the developer), but attempt to detect if the necessary linter is installed on the system.
A single launcher script is available to handle invocations on all platforms (using the symlink name to detect the desired linter), alternatively linters can be invoked directly:
Example
Invoking
clang-formatcan be done either viabuild-aux/run-clang-format [--verbose] [--check] [--github]on macOS and Linux,.\build-aux\run-clang-format.ps1 [-Verbose] [-Check] [-GitHubStyle](if symlink support is enabled for git on Windows).\build-aux\.run-format.ps1 -Linter clang-format [-Verbose] [-Check] [-GitHubStyle](if symlink support is not enabled).While
clang-formatis commonly available in a Visual Studio Developer Shell,zizmorandgersemican simply be installed viawingetand are then available via these scripts.Both
xmllintandswift-formatare only available on macOS and Linux (the latter can be installed via Homebrew).How Has This Been Tested?
Powershell variants have been tested on Windows 11, macOS variants on macOS 26, Linux variants were tested on Ubuntu 26.
In each case, formatting were deliberately misformatted and the linters then run on either files explicitly or across the entire repository.
Types of changes
Checklist: