[Tools] Force clang-format version to 3.9 06/258706/2
authorRafal Walczyna <r.walczyna@samsung.com>
Mon, 24 May 2021 13:02:02 +0000 (15:02 +0200)
committerRafal Walczyna <r.walczyna@samsung.com>
Mon, 24 May 2021 14:10:21 +0000 (16:10 +0200)
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 <r.walczyna@samsung.com>
doc/html/index.html
doc/src/tools.md
tools/codestyle/c++_clang_formatter.sh

index 7253e5a..a574f42 100644 (file)
@@ -395,10 +395,7 @@ file before build process.</p>
 <p><code>cpplint</code> is used to validate C++ and <code>eslint</code> for JavaScript files.</p>
 <p><strong>Currently, the JavaScript validator and formatter seems to be a little buggy,
 thus it is not recommended to use.</strong></p>
-<p>The developer needs to have <code>python</code>, <code>node.js</code>, <code>eslint</code>, <code>Closure Linter</code> and <code>clang-format</code> installed.</p>
-<p>It is worth to make life easier by creating symbolic link to <code>clang-format</code>.</p>
-<pre><code class="lang-sh">sudo ln -s /usr/bin/clang-format-&lt;clang format version&gt; /usr/bin/clang-format
-</code></pre>
+<p>The developer needs to have <code>python</code>, <code>node.js</code>, <code>eslint</code>, <code>Closure Linter</code> and <code>clang-format-3.9</code> installed.</p>
 <p>For convenience, in the root of the project links were provided for easier access:</p>
 <ul>
 <li><code>code_format -&gt; tools/codestyle/code_formatter.sh</code></li>
index 2ceb3b7..36f901c 100644 (file)
@@ -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-<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``
index e014c73..0e1874d 100755 (executable)
@@ -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 --)
 }