Meta+Docs+CI: Require clang-format >= 11

This commit is contained in:
Linus Groh 2020-12-30 22:45:54 +01:00 committed by Andreas Kling
parent bbe787a0af
commit fb220d5678
6 changed files with 19 additions and 15 deletions

View file

@ -21,13 +21,17 @@ jobs:
# sudo apt-get update -qq
- name: Purge interfering packages
# Remove GCC 9 (installed by default)
run: sudo apt-get purge -y gcc-9 g++-9 libstdc++-9-dev
# Remove GCC 9 and clang-format 10 (installed by default)
run: sudo apt-get purge -y gcc-9 g++-9 libstdc++-9-dev clang-format-10
- name: Install dependencies
# These packages are already part of the ubuntu-20.04 image:
# clang-format-10 cmake gcc-10 g++-10 shellcheck libgmp-dev
# cmake gcc-10 g++-10 shellcheck libgmp-dev
# These aren't:
run: sudo apt-get install libstdc++-10-dev libmpfr-dev libmpc-dev ninja-build npm
run: |
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-11 main"
sudo apt-get update
sudo apt-get install clang-format-11 libstdc++-10-dev libmpfr-dev libmpc-dev ninja-build npm
# If we ever do any qemu-emulation on Github Actions, we should re-enable this:
# e2fsprogs qemu-system-i386 qemu-utils
- name: Install prettier
@ -35,7 +39,7 @@ jobs:
- name: Use GCC 10 instead
run: sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-10 60 --slave /usr/bin/g++ g++ /usr/bin/g++-10
- name: Check versions
run: set +e; g++ --version; g++-10 --version; clang-format --version; clang-format-10 --version; prettier --version; python --version; python3 --version; ninja --version
run: set +e; g++ --version; g++-10 --version; clang-format --version; clang-format-11 --version; prettier --version; python --version; python3 --version; ninja --version
# === PREPARE FOR BUILDING ===

View file

@ -34,7 +34,7 @@ Nobody is perfect, and sometimes we mess things up. That said, here are some goo
**Do:**
* Write in idiomatic Serenity 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). Please use `clang-format` (version 10 or later) to automatically format C++ files.
* Conform to the project coding style found in [CodingStyle.md](https://github.com/SerenityOS/serenity/blob/master/Documentation/CodingStyle.md). Please use `clang-format` (version 11 or later) to automatically format C++ files.
* 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.
* Make sure your commits are rebased on the master branch.

View file

@ -32,7 +32,7 @@ apt-get install curl cmake libmpc-devel gmp-devel e2fsprogs libmpfr-devel patch
Ensure your gcc version is >= 10 with `gcc --version`. Otherwise, install it.
On Ubuntu it's in the repositories of 20.04 (Focal) - add the `ubuntu-toolchain-r/test` PPA if you're running an older version:
On Ubuntu it's in the repositories of 20.04 (Focal) and later - add the `ubuntu-toolchain-r/test` PPA if you're running an older version:
```bash
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
```

View file

@ -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.
**Important: Make sure you use `clang-format` version 10 or later!**
**Important: Make sure you use `clang-format` version 11 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.

View file

@ -21,7 +21,7 @@ Qt Creator should be set up correctly now, go ahead and explore the project and
## Auto-Formatting
You can use `clang-format` to help you with the [style guide](https://github.com/SerenityOS/serenity/blob/master/Documentation/CodingStyle.md). Before you proceed, check that you're actually using clang-format version 10, as some OSes still ship clang-format version 9 by default.
You can use `clang-format` to help you with the [style guide](https://github.com/SerenityOS/serenity/blob/master/Documentation/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.
- In QtCreator, go to "Help > About Plugins…"
- Find the `Beautifier (experimental)` row (for example, by typing `beau` into the search)

View file

@ -6,17 +6,17 @@ script_path=$(cd -P -- "$(dirname -- "$0")" && pwd -P)
cd "${script_path}/.." || exit 1
CLANG_FORMAT=false
if command -v clang-format-10 >/dev/null 2>&1 ; then
CLANG_FORMAT=clang-format-10
if command -v clang-format-11 >/dev/null 2>&1 ; then
CLANG_FORMAT=clang-format-11
elif command -v clang-format >/dev/null 2>&1 ; then
CLANG_FORMAT=clang-format
if ! "${CLANG_FORMAT}" --version | grep -qF ' 10.' ; then
echo "You are using '$("${CLANG_FORMAT}" --version)', which appears to not be clang-format 10."
if ! "${CLANG_FORMAT}" --version | grep -qF ' 11.' ; then
echo "You are using '$("${CLANG_FORMAT}" --version)', which appears to not be clang-format 11."
echo "It is very likely that the resulting changes are not what you wanted."
fi
else
echo "clang-format-10 is not available. Either skip this script, or install clang-format-10."
echo "(If you install a package 'clang-format', please make sure it's version 10.)"
echo "clang-format-10 is not available. Either skip this script, or install clang-format-11."
echo "(If you install a package 'clang-format', please make sure it's version 11.)"
exit 1
fi