mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 07:30:19 +00:00
Meta: Switch to clang-format-18 as the standard formatter
This commit is contained in:
parent
891c4ac68e
commit
823fdb83db
Notes:
sideshowbarker
2024-07-17 01:10:58 +09:00
Author: https://github.com/trflynn89 Commit: https://github.com/SerenityOS/serenity/commit/823fdb83db Pull-request: https://github.com/SerenityOS/serenity/pull/24096 Reviewed-by: https://github.com/ADKaster Reviewed-by: https://github.com/Hendiadyoin1 Reviewed-by: https://github.com/alimpfard ✅
9 changed files with 22 additions and 22 deletions
|
@ -13,7 +13,7 @@
|
||||||
18,
|
18,
|
||||||
"trunk"
|
"trunk"
|
||||||
],
|
],
|
||||||
"default": 16,
|
"default": 18,
|
||||||
"description": "Select LLVM compiler version to use"
|
"description": "Select LLVM compiler version to use"
|
||||||
},
|
},
|
||||||
"enable_ladybird": {
|
"enable_ladybird": {
|
||||||
|
|
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-16 main'
|
sudo add-apt-repository 'deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-18 main'
|
||||||
sudo apt-get update
|
sudo apt-get update
|
||||||
sudo apt-get install -y clang-format-16 ccache e2fsprogs gcc-13 g++-13 libstdc++-13-dev libmpfr-dev libmpc-dev ninja-build optipng qemu-utils qemu-system-i386 unzip generate-ninja libegl1-mesa-dev
|
sudo apt-get install -y clang-format-18 ccache e2fsprogs gcc-13 g++-13 libstdc++-13-dev libmpfr-dev libmpc-dev ninja-build optipng qemu-utils qemu-system-i386 unzip generate-ninja libegl1-mesa-dev
|
||||||
if ${{ matrix.arch == 'aarch64' }}; then
|
if ${{ matrix.arch == 'aarch64' }}; then
|
||||||
# FIXME: Remove this when we no longer build our own Qemu binary.
|
# FIXME: Remove this when we no longer build our own Qemu binary.
|
||||||
sudo apt-get install libgtk-3-dev libpixman-1-dev libsdl2-dev libslirp-dev
|
sudo apt-get install libgtk-3-dev libpixman-1-dev libsdl2-dev libslirp-dev
|
||||||
|
@ -72,7 +72,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++-13 --version; clang-format --version; clang-format-16 --version; prettier --version; python --version; python3 --version; ninja --version; flake8 --version; ccache --version; qemu-system-i386 --version; gn --version
|
run: set +e; g++ --version; g++-13 --version; clang-format --version; clang-format-18 --version; prettier --version; python --version; python3 --version; ninja --version; flake8 --version; ccache --version; qemu-system-i386 --version; gn --version
|
||||||
|
|
||||||
- name: Enable KVM group perms
|
- name: Enable KVM group perms
|
||||||
run: |
|
run: |
|
||||||
|
|
|
@ -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-16 main'
|
sudo add-apt-repository 'deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-18 main'
|
||||||
sudo apt-get update
|
sudo apt-get update
|
||||||
sudo apt-get install -y clang-format-16 gcc-13 g++-13 libstdc++-13-dev libmpfr-dev libmpc-dev ninja-build unzip pvs-studio
|
sudo apt-get install -y clang-format-18 gcc-13 g++-13 libstdc++-13-dev libmpfr-dev libmpc-dev ninja-build unzip pvs-studio
|
||||||
|
|
||||||
- name: Check versions
|
- name: Check versions
|
||||||
run: set +e; g++ --version; g++-13 --version; ninja --version;
|
run: set +e; g++ --version; g++-13 --version; ninja --version;
|
||||||
|
|
|
@ -58,9 +58,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-16 main'
|
sudo add-apt-repository 'deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-18 main'
|
||||||
sudo apt-get update
|
sudo apt-get update
|
||||||
sudo apt-get install -y clang-format-16 gcc-13 g++-13 libstdc++-13-dev libmpfr-dev libmpc-dev ninja-build unzip
|
sudo apt-get install -y clang-format-18 gcc-13 g++-13 libstdc++-13-dev libmpfr-dev libmpc-dev ninja-build unzip
|
||||||
|
|
||||||
- name: Check versions
|
- name: Check versions
|
||||||
run: set +e; g++ --version; g++-13 --version; ninja --version;
|
run: set +e; g++ --version; g++-13 --version; ninja --version;
|
||||||
|
|
|
@ -44,7 +44,7 @@ Nobody is perfect, and sometimes we mess things up. That said, here are some goo
|
||||||
**Do:**
|
**Do:**
|
||||||
|
|
||||||
* Write in idiomatic SerenityOS C++20, using the `AK` containers in all code.
|
* Write in idiomatic SerenityOS C++20, using the `AK` containers in all code.
|
||||||
* Conform to the project coding style found in [CodingStyle.md](https://github.com/SerenityOS/serenity/blob/master/Documentation/CodingStyle.md). Use `clang-format` (version 16 or later) to automatically format C++ files. See [AdvancedBuildInstructions.md](https://github.com/SerenityOS/serenity/blob/master/Documentation/AdvancedBuildInstructions.md#clang-format-updates) for instructions on how to get an up-to-date version if your OS distribution does not ship clang-format-16.
|
* Conform to the project coding style found in [CodingStyle.md](https://github.com/SerenityOS/serenity/blob/master/Documentation/CodingStyle.md). Use `clang-format` (version 18 or later) to automatically format C++ files. See [AdvancedBuildInstructions.md](https://github.com/SerenityOS/serenity/blob/master/Documentation/AdvancedBuildInstructions.md#clang-format-updates) for instructions on how to get an up-to-date version if your OS distribution does not ship clang-format-18.
|
||||||
* Choose expressive variable, function and class names. Make it as obvious as possible what the code is doing.
|
* Choose expressive variable, function and class names. Make it as obvious as possible what the code is doing.
|
||||||
* Split your changes into separate, atomic commits (i.e. A commit per feature or fix, where the build, tests and the system are all functioning).
|
* Split your changes into separate, atomic commits (i.e. A commit per feature or fix, where the build, tests and the system are all functioning).
|
||||||
* Make sure your commits are rebased on the master branch.
|
* Make sure your commits are rebased on the master branch.
|
||||||
|
|
|
@ -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 16 or later!**
|
**Important: Make sure you use `clang-format` version 18 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.
|
||||||
|
|
||||||
|
|
|
@ -48,7 +48,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 16, as some OSes will ship older clang-format versions 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 18, 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,9 +9,9 @@ steps:
|
||||||
- script: |
|
- script: |
|
||||||
set -e
|
set -e
|
||||||
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-16 main'
|
sudo add-apt-repository 'deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-18 main'
|
||||||
sudo apt-get update
|
sudo apt-get update
|
||||||
sudo apt-get install clang-format-16 ccache e2fsprogs gcc-13 g++-13 libstdc++-13-dev libmpfr-dev libmpc-dev ninja-build qemu-utils qemu-system-i386 unzip lld
|
sudo apt-get install clang-format-18 ccache e2fsprogs gcc-13 g++-13 libstdc++-13-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') }}:
|
||||||
|
|
|
@ -29,21 +29,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-16 >/dev/null 2>&1 ; then
|
if command -v clang-format-18 >/dev/null 2>&1 ; then
|
||||||
CLANG_FORMAT=clang-format-16
|
CLANG_FORMAT=clang-format-18
|
||||||
elif command -v brew >/dev/null 2>&1 && command -v "$(brew --prefix llvm@16)"/bin/clang-format >/dev/null 2>&1 ; then
|
elif command -v brew >/dev/null 2>&1 && command -v "$(brew --prefix llvm@18)"/bin/clang-format >/dev/null 2>&1 ; then
|
||||||
CLANG_FORMAT="$(brew --prefix llvm@16)"/bin/clang-format
|
CLANG_FORMAT="$(brew --prefix llvm@18)"/bin/clang-format
|
||||||
elif command -v $TOOLCHAIN_DIR/clang-format >/dev/null 2>&1 && $TOOLCHAIN_DIR/clang-format --version | grep -qF ' 16.' ; then
|
elif command -v $TOOLCHAIN_DIR/clang-format >/dev/null 2>&1 && $TOOLCHAIN_DIR/clang-format --version | grep -qF ' 18.' ; 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) < 16) exit 1; }'; then
|
if ! "${CLANG_FORMAT}" --version | awk '{ if (substr($NF, 1, index($NF, ".") - 1) < 18) exit 1; }'; then
|
||||||
echo "You are using '$("${CLANG_FORMAT}" --version)', which appears to not be clang-format 16 or later."
|
echo "You are using '$("${CLANG_FORMAT}" --version)', which appears to not be clang-format 18 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-16 is not available, but C or C++ files need linting! Either skip this script, or install clang-format-16."
|
echo "clang-format-18 is not available, but C or C++ files need linting! Either skip this script, or install clang-format-18."
|
||||||
echo "(If you install a package 'clang-format', please make sure it's version 16 or later.)"
|
echo "(If you install a package 'clang-format', please make sure it's version 18 or later.)"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue