Skip to content

Commit 125c99f

Browse files
committed
PHPC-1118: Add detection of the correct clang-format binary
1 parent b0d97b0 commit 125c99f

File tree

2 files changed

+24
-3
lines changed

2 files changed

+24
-3
lines changed

.clang-format

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ DerivePointerAlignment: false
4646
DisableFormat: false
4747
ExperimentalAutoDetectBinPacking: false
4848
ForEachMacros: []
49-
IncludeBlocks: Preserve
5049
IncludeCategories:
5150
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
5251
Priority: 2
@@ -55,7 +54,6 @@ IncludeCategories:
5554
- Regex: '.*'
5655
Priority: 1
5756
IndentCaseLabels: true
58-
IndentPPDirectives: None
5957
IndentWidth: 4
6058
IndentWrappedFunctionNames: false
6159
KeepEmptyLinesAtTheStartOfBlocks: true

scripts/clang-format.sh

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,29 @@ if test x"$1" = xchanged; then
1212
FILES="$FILES1 $FILES2 $FILES3"
1313
fi
1414

15+
# Find clang-format, we prefer -6.0, but also allow binaries without -suffix as
16+
# long as they're 6.0.0
17+
CLANG_FORMAT=
18+
19+
which clang-format-6.0
20+
if [ $? = 0 ]; then
21+
CLANG_FORMAT=`which clang-format-6.0`
22+
fi
23+
24+
which clang-format
25+
if [ $? = 0 ]; then
26+
VERSION=`clang-format -version | cut -d " " -f 3 | cut -c 1-3`
27+
if [ x"$VERSION" = "x6.0" ]; then
28+
CLANG_FORMAT=`which clang-format`
29+
fi
30+
fi
31+
32+
if [ x"$CLANG_FORMAT" = "x" ]; then
33+
echo "Couldn't find the right clang-format (needs version 6.0)"
34+
exit
35+
fi
36+
37+
# Run formatter
1538
for i in $FILES; do
16-
clang-format-7 -i $i
39+
$CLANG_FORMAT -i $i
1740
done

0 commit comments

Comments
 (0)