From 4ee80105581c097fc97575ef3e476a60b79b1caf Mon Sep 17 00:00:00 2001 From: Jonathan Hui Date: Wed, 18 Mar 2020 19:04:10 -0700 Subject: [PATCH] [script] update make-pretty to bash (#4698) - Also update CONTRIBUTING.md and STYLE_GUIDE.md. --- CONTRIBUTING.md | 2 +- STYLE_GUIDE.md | 4 ++-- script/{clang-format.sh => clang-format} | 2 +- script/{clang-format-check.sh => clang-format-check} | 2 +- script/make-pretty | 4 ++-- 5 files changed, 7 insertions(+), 7 deletions(-) rename script/{clang-format.sh => clang-format} (99%) rename script/{clang-format-check.sh => clang-format-check} (94%) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index af7c501bb..5535c6eb6 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 the `script/make-pretty` and `script/make-pretty check` targets to automatically reformat code and check for code-style compliance, respectively. OpenThread currently requires [clang-format v6.0.0](http://releases.llvm.org/download.html#6.0.0) and [yapf](https://github.com/google/yapf) for `script/make-pretty` and `script/make-pretty check`. +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 v6.0.0](http://releases.llvm.org/download.html#6.0.0) for C/C++ and [yapf](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 233e8de91..25076ca0c 100644 --- a/STYLE_GUIDE.md +++ b/STYLE_GUIDE.md @@ -114,9 +114,9 @@ ## Format and Style -- OpenThread uses the `make pretty` build target to reformat code and enforce code format and style. The `make pretty-check` build target is included in OpenThread's continuous integration and must pass before a pull request is merged. +- 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. -- The `make pretty` and `make pretty-check` build targets require [clang-format v6.0.0](http://releases.llvm.org/download.html#6.0.0). +- `script/make-pretty` requires [clang-format v6.0.0](http://releases.llvm.org/download.html#6.0.0) for C/C++ and [yapf](https://github.com/google/yapf) for Python. ### File Names - File names should match the names and types of what is described in the file. If a file contains many declarations and definitions, the author should choose the one that predominantly describes or that makes the most sense. diff --git a/script/clang-format.sh b/script/clang-format similarity index 99% rename from script/clang-format.sh rename to script/clang-format index 8b16ee13e..1266d85b5 100755 --- a/script/clang-format.sh +++ b/script/clang-format @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # # Copyright (c) 2018, The OpenThread Authors. # All rights reserved. diff --git a/script/clang-format-check.sh b/script/clang-format-check similarity index 94% rename from script/clang-format-check.sh rename to script/clang-format-check index afe1768a1..4ea729e3b 100755 --- a/script/clang-format-check.sh +++ b/script/clang-format-check @@ -45,6 +45,6 @@ die() { for file in "$@"; do echo "Checking ${file}" - "$(dirname "$0")"/clang-format.sh -style=file "${file}" | diff -u "${file}" - || die "${file} is not pretty." + "$(dirname "$0")"/clang-format -style=file "${file}" | diff -u "${file}" - || die "${file} is not pretty." [ -z "$(tail -c1 "${file}")" ] || die "${file} misses EOF newline." done diff --git a/script/make-pretty b/script/make-pretty index 24275c9d9..6709eadb7 100755 --- a/script/make-pretty +++ b/script/make-pretty @@ -62,7 +62,7 @@ do_clang_format() echo -e '=====================' git ls-files "${OT_CLANG_SOURCES[@]}" | grep -E "^($(echo "${OT_CLANG_DIRS[@]}" | tr ' ' '|'))" \ - | xargs -n3 -P"${OT_BUILD_JOBS}" script/clang-format.sh -style=file -i -verbose + | xargs -n3 -P"${OT_BUILD_JOBS}" script/clang-format -style=file -i -verbose } do_clang_check() @@ -72,7 +72,7 @@ do_clang_check() echo -e '=====================' git ls-files "${OT_CLANG_SOURCES[@]}" | grep -E "^($(echo "${OT_CLANG_DIRS[@]}" | tr ' ' '|'))" \ - | xargs -n3 -P"${OT_BUILD_JOBS}" script/clang-format-check.sh + | xargs -n3 -P"${OT_BUILD_JOBS}" script/clang-format-check } do_python_format()