Browse Source

clang-format: Explicitly require version 3.8 of the tool

Versions of clang-format newer than 3.8 produce different output.
Our source code guide says that version 3.8 exactly must be used.
Update the comment in our `.clang-format` config file accordingly.
Add a check to our formatting script to verify the version.
Also update its tool search to look for the explicitly-named
3.8 variant first.
Brad King 7 years ago
parent
commit
8cfc45f6bd
2 changed files with 7 additions and 2 deletions
  1. 1 1
      .clang-format
  2. 6 1
      Utilities/Scripts/clang-format.bash

+ 1 - 1
.clang-format

@@ -1,5 +1,5 @@
 ---
-# This configuration requires clang-format 3.8 or higher.
+# This configuration requires clang-format version 3.8 exactly.
 BasedOnStyle: Mozilla
 AlignOperands: false
 AlwaysBreakAfterReturnType: None

+ 6 - 1
Utilities/Scripts/clang-format.bash

@@ -78,8 +78,8 @@ test "$#" = 0 || die "$usage"
 
 # Find a default tool.
 tools='
-  clang-format
   clang-format-3.8
+  clang-format
 '
 if test "x$clang_format" = "x"; then
     for tool in $tools; do
@@ -96,6 +96,11 @@ if ! type -p "$clang_format" >/dev/null; then
     exit 1
 fi
 
+if ! "$clang_format" --version | grep 'clang-format version 3\.8' >/dev/null 2>/dev/null; then
+    echo "clang-format version 3.8 is required (exactly)"
+    exit 1
+fi
+
 # Select listing mode.
 case "$mode" in
     '')       echo "$usage"; exit 0 ;;