[code-style] require clang-format-5.0 (#2645)

This commit is contained in:
Yakun Xu
2018-04-04 09:28:00 -07:00
committed by Jonathan Hui
parent 8b66cb0fe8
commit ab55bece52
4 changed files with 56 additions and 7 deletions
+1 -1
View File
@@ -357,7 +357,7 @@ fi
# Code style
#
AC_SUBST(PRETTY, ["clang-format"])
AC_SUBST(PRETTY, ["\${abs_top_srcdir}/script/clang-format.sh"])
AC_SUBST(PRETTY_ARGS, ["-style=file -i"])
AC_SUBST(PRETTY_CHECK, ["\${abs_top_srcdir}/script/clang-format-check.sh"])
AC_SUBST(PRETTY_CHECK_ARGS, [""])
+3
View File
@@ -47,6 +47,9 @@ install_packages_apt()
sudo add-apt-repository -y ppa:team-gcc-arm-embedded/ppa
sudo apt-get update
sudo apt-get install gcc-arm-embedded
# add clang-format for pretty
sudo apt-get install clang-format-5.0
}
install_packages_opkg()
+1 -6
View File
@@ -33,14 +33,9 @@
# replacements.
#
die() {
echo " *** ERROR: " $*
exit 1
}
set -x
# from `man diff`:
# Exit status is 0 if inputs are the same, 1 if different, 2 if trouble.
clang-format -style=file $@ | diff -u $@ -
$(dirname "$0")/clang-format.sh -style=file $@ | diff -u $@ -
+51
View File
@@ -0,0 +1,51 @@
#!/bin/sh
#
# Copyright (c) 2018, The OpenThread Authors.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# 3. Neither the name of the copyright holder nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
CLANG_FORMAT_VERSION="clang-format version 5.0"
die() {
echo " *** ERROR: " $*
exit 1
}
if which clang-format > /dev/null; then
case "$(clang-format --version)" in
"$CLANG_FORMAT_VERSION"*)
;;
*)
die "clang-format 5.0 required"
;;
esac
elif which clang-format-5.0 > /dev/null; then
alias clang-format=clang-format-5.0
else
die "clang-format 5.0 required"
fi
clang-format $@