From fb220d567861cf27424e1196702a47fe7e1a0928 Mon Sep 17 00:00:00 2001 From: Linus Groh Date: Wed, 30 Dec 2020 22:45:54 +0100 Subject: [PATCH] Meta+Docs+CI: Require clang-format >= 11 --- .github/workflows/cmake.yml | 14 +++++++++----- CONTRIBUTING.md | 2 +- Documentation/BuildInstructions.md | 2 +- Documentation/CodingStyle.md | 2 +- Documentation/UsingQtCreator.md | 2 +- Meta/lint-clang-format.sh | 12 ++++++------ 6 files changed, 19 insertions(+), 15 deletions(-) diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index 0c2e978a92a..d8dd659c466 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -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 === diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e58d47feec9..dda484fabd0 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -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. diff --git a/Documentation/BuildInstructions.md b/Documentation/BuildInstructions.md index 3a842d8c717..e88e5ff4273 100644 --- a/Documentation/BuildInstructions.md +++ b/Documentation/BuildInstructions.md @@ -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 ``` diff --git a/Documentation/CodingStyle.md b/Documentation/CodingStyle.md index cccec91033e..9873e13e73f 100644 --- a/Documentation/CodingStyle.md +++ b/Documentation/CodingStyle.md @@ -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. diff --git a/Documentation/UsingQtCreator.md b/Documentation/UsingQtCreator.md index 3535170fd2f..c7e2af71ed9 100644 --- a/Documentation/UsingQtCreator.md +++ b/Documentation/UsingQtCreator.md @@ -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) diff --git a/Meta/lint-clang-format.sh b/Meta/lint-clang-format.sh index 2359639071f..00a34c228ed 100755 --- a/Meta/lint-clang-format.sh +++ b/Meta/lint-clang-format.sh @@ -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