mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 07:30:19 +00:00
Meta: Switch to clang-format-14 as the standard formatter
Now that clang-format-14 ubuntu packages are available, it's time to finally upgrade our clang-format version. This version brings with it a bunch of useful features with const-placement being the most notable. These will be enabled in the following commits.
This commit is contained in:
parent
ed9ddf79ff
commit
852ae6c195
Notes:
sideshowbarker
2024-07-17 16:21:18 +09:00
Author: https://github.com/IdanHo Commit: https://github.com/SerenityOS/serenity/commit/852ae6c195 Pull-request: https://github.com/SerenityOS/serenity/pull/12321 Reviewed-by: https://github.com/BertalanD Reviewed-by: https://github.com/bgianfo ✅
9 changed files with 30 additions and 20 deletions
|
@ -2,7 +2,7 @@
|
||||||
Language: Cpp
|
Language: Cpp
|
||||||
BasedOnStyle: WebKit
|
BasedOnStyle: WebKit
|
||||||
SpaceAfterTemplateKeyword: false
|
SpaceAfterTemplateKeyword: false
|
||||||
AlignEscapedNewlines: true
|
AlignEscapedNewlines: Left
|
||||||
AlignTrailingComments: true
|
AlignTrailingComments: true
|
||||||
BreakBeforeInheritanceComma: true
|
BreakBeforeInheritanceComma: true
|
||||||
BreakConstructorInitializers: BeforeComma
|
BreakConstructorInitializers: BeforeComma
|
||||||
|
|
8
.github/workflows/cmake.yml
vendored
8
.github/workflows/cmake.yml
vendored
|
@ -40,7 +40,7 @@ jobs:
|
||||||
# sudo apt-get update -qq
|
# sudo apt-get update -qq
|
||||||
- name: "Install Ubuntu dependencies"
|
- name: "Install Ubuntu dependencies"
|
||||||
# These packages are already part of the ubuntu-20.04 image:
|
# These packages are already part of the ubuntu-20.04 image:
|
||||||
# cmake clang-format-11 libgmp-dev npm shellcheck
|
# cmake libgmp-dev npm shellcheck
|
||||||
# Packages below aren't.
|
# Packages below aren't.
|
||||||
#
|
#
|
||||||
# We add the canonical-server/server-backports PPA to get updated QEMU releases without having to manage
|
# We add the canonical-server/server-backports PPA to get updated QEMU releases without having to manage
|
||||||
|
@ -49,8 +49,10 @@ jobs:
|
||||||
run: |
|
run: |
|
||||||
sudo add-apt-repository ppa:canonical-server/server-backports
|
sudo add-apt-repository ppa:canonical-server/server-backports
|
||||||
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
|
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
|
||||||
|
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
|
||||||
|
sudo add-apt-repository 'deb http://apt.llvm.org/focal/ llvm-toolchain-focal-14 main'
|
||||||
sudo apt-get update
|
sudo apt-get update
|
||||||
sudo apt-get install -y ccache e2fsprogs gcc-11 g++-11 libstdc++-11-dev libmpfr-dev libmpc-dev ninja-build qemu-utils qemu-system-i386 unzip
|
sudo apt-get install -y clang-format-14 ccache e2fsprogs gcc-11 g++-11 libstdc++-11-dev libmpfr-dev libmpc-dev ninja-build qemu-utils qemu-system-i386 unzip
|
||||||
- name: Install JS dependencies
|
- name: Install JS dependencies
|
||||||
run: sudo npm install -g prettier@2.5.1
|
run: sudo npm install -g prettier@2.5.1
|
||||||
- name: Install Python dependencies
|
- name: Install Python dependencies
|
||||||
|
@ -59,7 +61,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++-11 --version; clang-format --version; clang-format-11 --version; prettier --version; python --version; python3 --version; ninja --version; flake8 --version; ccache --version; qemu-system-i386 --version
|
run: set +e; g++ --version; g++-11 --version; clang-format --version; clang-format-14 --version; prettier --version; python --version; python3 --version; ninja --version; flake8 --version; ccache --version; qemu-system-i386 --version
|
||||||
|
|
||||||
# === PREPARE FOR BUILDING ===
|
# === PREPARE FOR BUILDING ===
|
||||||
|
|
||||||
|
|
|
@ -21,13 +21,15 @@ jobs:
|
||||||
|
|
||||||
- name: "Install Ubuntu dependencies"
|
- name: "Install Ubuntu dependencies"
|
||||||
# These packages are already part of the ubuntu-20.04 image:
|
# These packages are already part of the ubuntu-20.04 image:
|
||||||
# cmake clang-format-11 libgmp-dev npm shellcheck
|
# cmake libgmp-dev npm shellcheck
|
||||||
# Packages below aren't.
|
# Packages below aren't.
|
||||||
#
|
#
|
||||||
run: |
|
run: |
|
||||||
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
|
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
|
||||||
|
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
|
||||||
|
sudo add-apt-repository 'deb http://apt.llvm.org/focal/ llvm-toolchain-focal-14 main'
|
||||||
sudo apt-get update
|
sudo apt-get update
|
||||||
sudo apt-get install -y gcc-11 g++-11 libstdc++-11-dev libmpfr-dev libmpc-dev ninja-build unzip pvs-studio
|
sudo apt-get install -y clang-format-14 gcc-11 g++-11 libstdc++-11-dev libmpfr-dev libmpc-dev ninja-build unzip pvs-studio
|
||||||
|
|
||||||
- name: Check versions
|
- name: Check versions
|
||||||
run: set +e; g++ --version; g++-11 --version; ninja --version;
|
run: set +e; g++ --version; g++-11 --version; ninja --version;
|
||||||
|
|
|
@ -55,12 +55,14 @@ jobs:
|
||||||
|
|
||||||
- name: "Install Ubuntu dependencies"
|
- name: "Install Ubuntu dependencies"
|
||||||
# These packages are already part of the ubuntu-20.04 image:
|
# These packages are already part of the ubuntu-20.04 image:
|
||||||
# cmake clang-format-11 libgmp-dev npm shellcheck
|
# cmake libgmp-dev npm shellcheck
|
||||||
# Packages below aren't.
|
# Packages below aren't.
|
||||||
run: |
|
run: |
|
||||||
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
|
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
|
||||||
|
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
|
||||||
|
sudo add-apt-repository 'deb http://apt.llvm.org/focal/ llvm-toolchain-focal-14 main'
|
||||||
sudo apt-get update
|
sudo apt-get update
|
||||||
sudo apt-get install -y gcc-11 g++-11 libstdc++-11-dev libmpfr-dev libmpc-dev ninja-build unzip
|
sudo apt-get install -y clang-format-14 gcc-11 g++-11 libstdc++-11-dev libmpfr-dev libmpc-dev ninja-build unzip
|
||||||
|
|
||||||
- name: Check versions
|
- name: Check versions
|
||||||
run: set +e; g++ --version; g++-11 --version; ninja --version;
|
run: set +e; g++ --version; g++-11 --version; ninja --version;
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
For low-level styling (spaces, parentheses, brace placement, etc), all code should follow the format specified in `.clang-format` in the project root.
|
For low-level styling (spaces, parentheses, brace placement, etc), all code should follow the format specified in `.clang-format` in the project root.
|
||||||
|
|
||||||
**Important: Make sure you use `clang-format` version 11 or later!**
|
**Important: Make sure you use `clang-format` version 14 or later!**
|
||||||
|
|
||||||
This document describes the coding style used for C++ code in the Serenity Operating System project. All new code should conform to this style.
|
This document describes the coding style used for C++ code in the Serenity Operating System project. All new code should conform to this style.
|
||||||
|
|
||||||
|
|
|
@ -18,10 +18,12 @@ These instructions assume the OS installed is Ubuntu 20.04 (Focal), so they migh
|
||||||
|
|
||||||
### Install base dependencies
|
### Install base dependencies
|
||||||
```shell
|
```shell
|
||||||
add-apt-repository ppa:canonical-server/server-backports
|
sudo add-apt-repository ppa:canonical-server/server-backports
|
||||||
add-apt-repository ppa:ubuntu-toolchain-r/test
|
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
|
||||||
|
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
|
||||||
|
sudo add-apt-repository 'deb http://apt.llvm.org/focal/ llvm-toolchain-focal-14 main'
|
||||||
apt update
|
apt update
|
||||||
apt install git build-essential make cmake clang-format-11 gcc-11 g++-11 libstdc++-11-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-14 gcc-11 g++-11 libstdc++-11-dev libgmp-dev ccache libmpfr-dev libmpc-dev ninja-build e2fsprogs qemu-utils qemu-system-i386 wabt
|
||||||
```
|
```
|
||||||
### Force usage of GCC 11
|
### Force usage of GCC 11
|
||||||
```shell
|
```shell
|
||||||
|
|
|
@ -40,7 +40,7 @@ Qt Creator should be set up correctly now, go ahead and explore the project and
|
||||||
|
|
||||||
## Auto-Formatting
|
## Auto-Formatting
|
||||||
|
|
||||||
You can use `clang-format` to help you with the [style guide](CodingStyle.md). Before you proceed, check that you're actually using clang-format version 11, as some OSes still ship clang-format version 9 or 10 by default.
|
You can use `clang-format` to help you with the [style guide](CodingStyle.md). Before you proceed, check that you're actually using clang-format version 14, as some OSes will ship older clang-format versions by default.
|
||||||
|
|
||||||
- In QtCreator, go to "Help > About Plugins…"
|
- In QtCreator, go to "Help > About Plugins…"
|
||||||
- Find the `Beautifier (experimental)` row (for example, by typing `beau` into the search)
|
- Find the `Beautifier (experimental)` row (for example, by typing `beau` into the search)
|
||||||
|
|
|
@ -9,8 +9,10 @@ steps:
|
||||||
- script: |
|
- script: |
|
||||||
sudo add-apt-repository ppa:canonical-server/server-backports
|
sudo add-apt-repository ppa:canonical-server/server-backports
|
||||||
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
|
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
|
||||||
|
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
|
||||||
|
sudo add-apt-repository 'deb http://apt.llvm.org/focal/ llvm-toolchain-focal-14 main'
|
||||||
sudo apt-get update
|
sudo apt-get update
|
||||||
sudo apt-get install ccache e2fsprogs gcc-11 g++-11 libstdc++-11-dev libmpfr-dev libmpc-dev ninja-build qemu-utils qemu-system-i386 unzip lld
|
sudo apt-get install clang-format-14 ccache e2fsprogs gcc-11 g++-11 libstdc++-11-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') }}:
|
||||||
|
|
|
@ -27,17 +27,17 @@ fi
|
||||||
|
|
||||||
if (( ${#files[@]} )); then
|
if (( ${#files[@]} )); then
|
||||||
CLANG_FORMAT=false
|
CLANG_FORMAT=false
|
||||||
if command -v clang-format-11 >/dev/null 2>&1 ; then
|
if command -v clang-format-14 >/dev/null 2>&1 ; then
|
||||||
CLANG_FORMAT=clang-format-11
|
CLANG_FORMAT=clang-format-14
|
||||||
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) < 11) exit 1; }'; then
|
if ! "${CLANG_FORMAT}" --version | awk '{ if (substr($NF, 1, index($NF, ".") - 1) < 14) exit 1; }'; then
|
||||||
echo "You are using '$("${CLANG_FORMAT}" --version)', which appears to not be clang-format 11 or later."
|
echo "You are using '$("${CLANG_FORMAT}" --version)', which appears to not be clang-format 14 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-11 is not available, but C or C++ files need linting! Either skip this script, or install clang-format-11."
|
echo "clang-format-14 is not available, but C or C++ files need linting! Either skip this script, or install clang-format-14."
|
||||||
echo "(If you install a package 'clang-format', please make sure it's version 11 or later.)"
|
echo "(If you install a package 'clang-format', please make sure it's version 14 or later.)"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue