mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-25 09:00:22 +00:00
Meta: Switch to clang-format-15 as the standard formatter
The two major changes noticeable on the SerenityOS codebase are: - Much improved support for const placement, clang-format-14 ignored our east-const configuration in various places - Different formatting for requires clauses, now breaking them onto their own line, which helps with readability a bit Current versions of CLion also ship LLVM 15, so the built-in formatting now matches CI formatting again :^)
This commit is contained in:
parent
0d63b7a515
commit
8639d8bc21
Notes:
sideshowbarker
2024-07-17 10:39:39 +09:00
Author: https://github.com/linusg Commit: https://github.com/SerenityOS/serenity/commit/8639d8bc21 Pull-request: https://github.com/SerenityOS/serenity/pull/15654 Reviewed-by: https://github.com/ADKaster Reviewed-by: https://github.com/alimpfard
7 changed files with 22 additions and 20 deletions
|
@ -12,3 +12,5 @@ BraceWrapping:
|
||||||
AfterFunction: true
|
AfterFunction: true
|
||||||
NamespaceIndentation: None
|
NamespaceIndentation: None
|
||||||
QualifierAlignment: Right
|
QualifierAlignment: Right
|
||||||
|
RequiresClausePosition: WithFollowing
|
||||||
|
IndentRequiresClause: false
|
||||||
|
|
6
.github/workflows/cmake.yml
vendored
6
.github/workflows/cmake.yml
vendored
|
@ -57,9 +57,9 @@ jobs:
|
||||||
# Packages below aren't.
|
# Packages below aren't.
|
||||||
run: |
|
run: |
|
||||||
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
|
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
|
||||||
sudo add-apt-repository 'deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-14 main'
|
sudo add-apt-repository 'deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-15 main'
|
||||||
sudo apt-get update
|
sudo apt-get update
|
||||||
sudo apt-get install -y clang-format-14 ccache e2fsprogs gcc-12 g++-12 libstdc++-12-dev libmpfr-dev libmpc-dev ninja-build optipng qemu-utils qemu-system-i386 unzip
|
sudo apt-get install -y clang-format-15 ccache e2fsprogs gcc-12 g++-12 libstdc++-12-dev libmpfr-dev libmpc-dev ninja-build optipng qemu-utils qemu-system-i386 unzip
|
||||||
- name: Install JS dependencies
|
- name: Install JS dependencies
|
||||||
run: sudo npm install -g prettier@2.7.1
|
run: sudo npm install -g prettier@2.7.1
|
||||||
- name: Install Python dependencies
|
- name: Install Python dependencies
|
||||||
|
@ -68,7 +68,7 @@ jobs:
|
||||||
python -m pip install --upgrade pip
|
python -m pip install --upgrade pip
|
||||||
pip install flake8 requests
|
pip install flake8 requests
|
||||||
- name: Check versions
|
- name: Check versions
|
||||||
run: set +e; g++ --version; g++-12 --version; clang-format --version; clang-format-14 --version; prettier --version; python --version; python3 --version; ninja --version; flake8 --version; ccache --version; qemu-system-i386 --version
|
run: set +e; g++ --version; g++-12 --version; clang-format --version; clang-format-15 --version; prettier --version; python --version; python3 --version; ninja --version; flake8 --version; ccache --version; qemu-system-i386 --version
|
||||||
|
|
||||||
# === PREPARE FOR BUILDING ===
|
# === PREPARE FOR BUILDING ===
|
||||||
|
|
||||||
|
|
|
@ -26,9 +26,9 @@ jobs:
|
||||||
#
|
#
|
||||||
run: |
|
run: |
|
||||||
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
|
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
|
||||||
sudo add-apt-repository 'deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-14 main'
|
sudo add-apt-repository 'deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-15 main'
|
||||||
sudo apt-get update
|
sudo apt-get update
|
||||||
sudo apt-get install -y clang-format-14 gcc-12 g++-12 libstdc++-12-dev libmpfr-dev libmpc-dev ninja-build unzip pvs-studio
|
sudo apt-get install -y clang-format-15 gcc-12 g++-12 libstdc++-12-dev libmpfr-dev libmpc-dev ninja-build unzip pvs-studio
|
||||||
|
|
||||||
- name: Check versions
|
- name: Check versions
|
||||||
run: set +e; g++ --version; g++-12 --version; ninja --version;
|
run: set +e; g++ --version; g++-12 --version; ninja --version;
|
||||||
|
|
|
@ -59,9 +59,9 @@ jobs:
|
||||||
# Packages below aren't.
|
# Packages below aren't.
|
||||||
run: |
|
run: |
|
||||||
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
|
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
|
||||||
sudo add-apt-repository 'deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-14 main'
|
sudo add-apt-repository 'deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-15 main'
|
||||||
sudo apt-get update
|
sudo apt-get update
|
||||||
sudo apt-get install -y clang-format-14 gcc-12 g++-12 libstdc++-12-dev libmpfr-dev libmpc-dev ninja-build unzip
|
sudo apt-get install -y clang-format-15 gcc-12 g++-12 libstdc++-12-dev libmpfr-dev libmpc-dev ninja-build unzip
|
||||||
|
|
||||||
- name: Check versions
|
- name: Check versions
|
||||||
run: set +e; g++ --version; g++-12 --version; ninja --version;
|
run: set +e; g++ --version; g++-12 --version; ninja --version;
|
||||||
|
|
|
@ -20,9 +20,9 @@ These instructions assume the OS installed is Ubuntu 22.04 (Jammy), so they migh
|
||||||
```shell
|
```shell
|
||||||
sudo add-apt-repository ppa:canonical-server/server-backports
|
sudo add-apt-repository ppa:canonical-server/server-backports
|
||||||
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
|
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
|
||||||
sudo add-apt-repository 'deb http://apt.llvm.org/jammy/ llvm-toolchain-focal-14 main'
|
sudo add-apt-repository 'deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-15 main'
|
||||||
apt update
|
apt update
|
||||||
apt install git build-essential make cmake clang-format-14 gcc-12 g++-12 libstdc++-12-dev libgmp-dev ccache libmpfr-dev libmpc-dev ninja-build e2fsprogs qemu-utils qemu-system-i386 wabt
|
apt install git build-essential make cmake clang-format-15 gcc-12 g++-12 libstdc++-12-dev libgmp-dev ccache libmpfr-dev libmpc-dev ninja-build e2fsprogs qemu-utils qemu-system-i386 wabt
|
||||||
```
|
```
|
||||||
### Force usage of GCC 12
|
### Force usage of GCC 12
|
||||||
```shell
|
```shell
|
||||||
|
|
|
@ -8,9 +8,9 @@ steps:
|
||||||
- ${{ if eq(parameters.os, 'Serenity') }}:
|
- ${{ if eq(parameters.os, 'Serenity') }}:
|
||||||
- script: |
|
- script: |
|
||||||
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
|
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
|
||||||
sudo add-apt-repository 'deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-14 main'
|
sudo add-apt-repository 'deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-15 main'
|
||||||
sudo apt-get update
|
sudo apt-get update
|
||||||
sudo apt-get install clang-format-14 ccache e2fsprogs gcc-12 g++-12 libstdc++-12-dev libmpfr-dev libmpc-dev ninja-build qemu-utils qemu-system-i386 unzip lld
|
sudo apt-get install clang-format-15 ccache e2fsprogs gcc-12 g++-12 libstdc++-12-dev libmpfr-dev libmpc-dev ninja-build qemu-utils qemu-system-i386 unzip lld
|
||||||
displayName: 'Install Dependencies'
|
displayName: 'Install Dependencies'
|
||||||
|
|
||||||
- ${{ if eq(parameters.os, 'Linux') }}:
|
- ${{ if eq(parameters.os, 'Linux') }}:
|
||||||
|
|
|
@ -28,21 +28,21 @@ fi
|
||||||
if (( ${#files[@]} )); then
|
if (( ${#files[@]} )); then
|
||||||
TOOLCHAIN_DIR=Toolchain/Local/clang/bin
|
TOOLCHAIN_DIR=Toolchain/Local/clang/bin
|
||||||
CLANG_FORMAT=false
|
CLANG_FORMAT=false
|
||||||
if command -v clang-format-14 >/dev/null 2>&1 ; then
|
if command -v clang-format-15 >/dev/null 2>&1 ; then
|
||||||
CLANG_FORMAT=clang-format-14
|
CLANG_FORMAT=clang-format-15
|
||||||
elif command -v brew >/dev/null 2>&1 && command -v "$(brew --prefix llvm@14)"/bin/clang-format >/dev/null 2>&1 ; then
|
elif command -v brew >/dev/null 2>&1 && command -v "$(brew --prefix llvm@15)"/bin/clang-format >/dev/null 2>&1 ; then
|
||||||
CLANG_FORMAT="$(brew --prefix llvm@14)"/bin/clang-format
|
CLANG_FORMAT="$(brew --prefix llvm@15)"/bin/clang-format
|
||||||
elif command -v $TOOLCHAIN_DIR/clang-format >/dev/null 2>&1 && $TOOLCHAIN_DIR/clang-format --version | grep -qF ' 14.' ; then
|
elif command -v $TOOLCHAIN_DIR/clang-format >/dev/null 2>&1 && $TOOLCHAIN_DIR/clang-format --version | grep -qF ' 15.' ; then
|
||||||
CLANG_FORMAT=$TOOLCHAIN_DIR/clang-format
|
CLANG_FORMAT=$TOOLCHAIN_DIR/clang-format
|
||||||
elif command -v clang-format >/dev/null 2>&1 ; then
|
elif command -v clang-format >/dev/null 2>&1 ; then
|
||||||
CLANG_FORMAT=clang-format
|
CLANG_FORMAT=clang-format
|
||||||
if ! "${CLANG_FORMAT}" --version | awk '{ if (substr($NF, 1, index($NF, ".") - 1) < 14) exit 1; }'; then
|
if ! "${CLANG_FORMAT}" --version | awk '{ if (substr($NF, 1, index($NF, ".") - 1) < 15) exit 1; }'; then
|
||||||
echo "You are using '$("${CLANG_FORMAT}" --version)', which appears to not be clang-format 14 or later."
|
echo "You are using '$("${CLANG_FORMAT}" --version)', which appears to not be clang-format 15 or later."
|
||||||
echo "It is very likely that the resulting changes are not what you wanted."
|
echo "It is very likely that the resulting changes are not what you wanted."
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo "clang-format-14 is not available, but C or C++ files need linting! Either skip this script, or install clang-format-14."
|
echo "clang-format-15 is not available, but C or C++ files need linting! Either skip this script, or install clang-format-15."
|
||||||
echo "(If you install a package 'clang-format', please make sure it's version 14 or later.)"
|
echo "(If you install a package 'clang-format', please make sure it's version 15 or later.)"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue