diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b9ceaac69..8f754a2bc 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -43,7 +43,7 @@ concurrency: jobs: pretty: - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v3 with: @@ -51,7 +51,7 @@ jobs: - name: Bootstrap run: | sudo rm /etc/apt/sources.list.d/* && sudo apt-get update - sudo apt-get --no-install-recommends install -y clang-format-9 clang-tidy-9 shellcheck + sudo apt-get --no-install-recommends install -y clang-format-14 clang-tidy-9 shellcheck python3 -m pip install yapf==0.31.0 sudo snap install shfmt - name: Check diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 2e99d4d45..ae564f227 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -109,7 +109,7 @@ This will open up a text editor where you can specify which commits to squash. #### Coding Conventions and Style -OpenThread uses and enforces the [OpenThread Coding Conventions and Style](STYLE_GUIDE.md) on all code, except for code located in [third_party](third_party). Use `script/make-pretty` and `script/make-pretty check` to automatically reformat code and check for code-style compliance, respectively. OpenThread currently requires [clang-format v9.0.0](https://releases.llvm.org/download.html#9.0.0) for C/C++ and [yapf v0.31.0](https://github.com/google/yapf) for Python. +OpenThread uses and enforces the [OpenThread Coding Conventions and Style](STYLE_GUIDE.md) on all code, except for code located in [third_party](third_party). Use `script/make-pretty` and `script/make-pretty check` to automatically reformat code and check for code-style compliance, respectively. OpenThread currently requires [clang-format v14.0.0](https://releases.llvm.org/download.html#14.0.0) for C/C++ and [yapf v0.31.0](https://github.com/google/yapf) for Python. As part of the cleanup process, you should also run `script/make-pretty check` to ensure that your code passes the baseline code style checks. diff --git a/STYLE_GUIDE.md b/STYLE_GUIDE.md index d8ea62496..c409c32bd 100644 --- a/STYLE_GUIDE.md +++ b/STYLE_GUIDE.md @@ -116,7 +116,7 @@ - OpenThread uses `script/make-pretty` to reformat code and enforce code format and style. `script/make-pretty check` build target is included in OpenThread's continuous integration and must pass before a pull request is merged. -- `script/make-pretty` requires [clang-format v9.0.0](https://releases.llvm.org/download.html#9.0.0) for C/C++ and [yapf v0.31.0](https://github.com/google/yapf) for Python. +- `script/make-pretty` requires [clang-format v14.0.0](https://releases.llvm.org/download.html#14.0.0) for C/C++ and [yapf v0.31.0](https://github.com/google/yapf) for Python. ### File Names diff --git a/script/bootstrap b/script/bootstrap index cf4fff962..d25f3d2db 100755 --- a/script/bootstrap +++ b/script/bootstrap @@ -38,7 +38,7 @@ install_packages_pretty_format() echo 'Installing pretty tools useful for code contributions...' # add clang-format and clang-tidy for pretty - sudo apt-get --no-install-recommends install -y clang-format-9 clang-tidy-9 || echo 'WARNING: could not install clang-format-9 and clang-tidy-9, which is useful if you plan to contribute C/C++ code to the OpenThread project.' + sudo apt-get --no-install-recommends install -y clang-format-14 clang-tidy-9 || echo 'WARNING: could not install clang-format-14 and clang-tidy-9, which is useful if you plan to contribute C/C++ code to the OpenThread project.' # add yapf for pretty python3 -m pip install yapf==0.31.0 || echo 'WARNING: could not install yapf, which is useful if you plan to contribute python code to the OpenThread project.' @@ -111,11 +111,11 @@ install_packages_brew() echo 'Installing pretty tools useful for code contributions...' # add clang-format for pretty - CLANG_FORMAT_VERSION="clang-format version 9" - command -v clang-format-9 || (command -v clang-format && (clang-format --version | grep -q "${CLANG_FORMAT_VERSION}")) || { - brew install llvm@9 - sudo ln -s "$(brew --prefix llvm@9)/bin/clang-format" /usr/local/bin/clang-format-9 - } || echo 'WARNING: could not install llvm@9, which is useful if you plan to contribute C/C++ code to the OpenThread project.' + CLANG_FORMAT_VERSION="clang-format version 14" + command -v clang-format-14 || (command -v clang-format && (clang-format --version | grep -q "${CLANG_FORMAT_VERSION}")) || { + brew install llvm@14 + sudo ln -s "$(brew --prefix llvm@14)/bin/clang-format" /usr/local/bin/clang-format-14 + } || echo 'WARNING: could not install llvm@14, which is useful if you plan to contribute C/C++ code to the OpenThread project.' # add yapf for pretty python3 -m pip install yapf || echo 'Failed to install python code formatter yapf. Install it manually if you need.' diff --git a/script/clang-format b/script/clang-format index 01b9535e0..1d58a925c 100755 --- a/script/clang-format +++ b/script/clang-format @@ -27,7 +27,7 @@ # POSSIBILITY OF SUCH DAMAGE. # -CLANG_FORMAT_VERSION="clang-format version 9.0" +CLANG_FORMAT_VERSION="clang-format version 14.0" die() { @@ -39,18 +39,18 @@ die() # expand_aliases shell option is set using shopt. shopt -s expand_aliases -if command -v clang-format-9 >/dev/null; then - alias clang-format=clang-format-9 +if command -v clang-format-14 >/dev/null; then + alias clang-format=clang-format-14 elif command -v clang-format >/dev/null; then case "$(clang-format --version)" in "$CLANG_FORMAT_VERSION"*) ;; *) - die "$(clang-format --version); clang-format 9.0 required" + die "$(clang-format --version); clang-format 14.0 required" ;; esac else - die "clang-format 9.0 required" + die "clang-format 14.0 required" fi clang-format "$@" || die