From: Rafal Walczyna
Date: Mon, 24 May 2021 13:02:02 +0000 (+0200)
Subject: [Tools] Force clang-format version to 3.9
X-Git-Tag: submit/tizen/20210609.101925~2
X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F06%2F258706%2F2;p=platform%2Fcore%2Fapi%2Fwebapi-plugins.git
[Tools] Force clang-format version to 3.9
Using version newer than 3.9 results in a lot of format changes.
As user may want to use newer clang-format version for different
projects, script has been changed to use clang-format-3.9 executable.
[Verification] No change in C++ formatting
Change-Id: I4f569644549db8104bb39efc6bc1eca23ac6bbd6
Signed-off-by: Rafal Walczyna
---
diff --git a/doc/html/index.html b/doc/html/index.html
index 7253e5ab..a574f425 100644
--- a/doc/html/index.html
+++ b/doc/html/index.html
@@ -395,10 +395,7 @@ file before build process.
cpplint
is used to validate C++ and eslint
for JavaScript files.
Currently, the JavaScript validator and formatter seems to be a little buggy,
thus it is not recommended to use.
-The developer needs to have python
, node.js
, eslint
, Closure Linter
and clang-format
installed.
-It is worth to make life easier by creating symbolic link to clang-format
.
-sudo ln -s /usr/bin/clang-format-<clang format version> /usr/bin/clang-format
-
+The developer needs to have python
, node.js
, eslint
, Closure Linter
and clang-format-3.9
installed.
For convenience, in the root of the project links were provided for easier access:
code_format -> tools/codestyle/code_formatter.sh
diff --git a/doc/src/tools.md b/doc/src/tools.md
index 2ceb3b7a..36f901ca 100644
--- a/doc/src/tools.md
+++ b/doc/src/tools.md
@@ -85,12 +85,7 @@ To format code use scripts provided in the ``tools/codestyle`` directory.
**Currently, the JavaScript validator and formatter seems to be a little buggy,
thus it is not recommended to use.**
-The developer needs to have ``python``, ``node.js``, ``eslint``, ``Closure Linter`` and ``clang-format`` installed.
-
-It is worth to make life easier by creating symbolic link to ``clang-format``.
-```sh
-sudo ln -s /usr/bin/clang-format- /usr/bin/clang-format
-```
+The developer needs to have ``python``, ``node.js``, ``eslint``, ``Closure Linter`` and ``clang-format-3.9`` installed.
For convenience, in the root of the project links were provided for easier access:
- ``code_format -> tools/codestyle/code_formatter.sh``
diff --git a/tools/codestyle/c++_clang_formatter.sh b/tools/codestyle/c++_clang_formatter.sh
index e014c730..0e1874d7 100755
--- a/tools/codestyle/c++_clang_formatter.sh
+++ b/tools/codestyle/c++_clang_formatter.sh
@@ -10,12 +10,11 @@ done
SCRIPT_DIR="$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )"
# https://clangformat.com/
-if [ ! "$(command -v clang-format)" ]; then
+if [ ! "$(command -v clang-format-3.9)" ]; then
echo >&2 "clang-format is required, but it's not installed";
echo "-------------------------------------------------------------------------------------";
- echo "To install clang-format on Debian/Ubuntu, execute the following commands."
+ echo "To install clang-format on Debian/Ubuntu, execute the following command:"
echo " sudo apt-get install clang-format-3.9"
- echo " sudo ln -s /usr/bin/clang-format-3.9 /usr/bin/clang-format"
echo "-------------------------------------------------------------------------------------";
exit 1;
fi
@@ -34,7 +33,7 @@ AllowShortFunctionsOnASingleLine: false,
formatC++() {
printf "."
find -- "$1" -type f \( -name '*.cc' -o -name '*.cpp' -o -name '*.h' -o -name '*.hpp' \) | \
- grep -v 'src/google' | xargs -n1 --no-run-if-empty clang-format -i -style="$config"
+ grep -v 'src/google' | xargs -n1 --no-run-if-empty clang-format-3.9 -i -style="$config"
}
checkUpdatedFiles() {
@@ -42,7 +41,7 @@ checkUpdatedFiles() {
if [ "${f: -3}" == ".cc" ] || [ "${f: -4}" == ".cpp" ] || [ "${f: -2}" == ".h" ] || \
[ "${f: -4}" == ".hpp" ]; then
printf '.'
- clang-format -i -style="$config" "$f";
+ clang-format-3.9 -i -style="$config" "$f";
fi
done < <(git diff-index -z --name-only --diff-filter=AM HEAD --)
}