clang-format.hook 680 字节
Newer Older
朔-望's avatar
朔-望 已提交
1
#!/bin/bash
朔-望's avatar
朔-望 已提交
2 3 4 5 6 7 8 9 10 11 12 13
set -e

readonly VERSION="5.0"

version=$(clang-format -version)

if ! [[ $version == *"$VERSION"* ]]; then
    echo "clang-format version check failed."
    echo "a version contains '$VERSION' is needed, but get '$version'"
    echo "you can install the right version, and make an soft-link to '\$PATH' env"
    exit -1
fi
朔-望's avatar
朔-望 已提交
14

15 16
# https://medicineyeh.wordpress.com/2017/07/13/clang-format-with-pragma/
shift
L
liuruilong 已提交
17
perl -i -pe 's|^\s+#pragma\s+omp|// <TRICKY-CLANG-FORMAT-PRAGMA-FIX> #pragma omp|' "$@"
L
liuruilong 已提交
18 19
(
# remove clang format ios_io folder
L
liuruilong 已提交
20 21
flist=$(echo "$@" | perl -pe 's|src/ios_io/[^ ]*||')
clang-format -i $flist
L
liuruilong 已提交
22
)
23
perl -i -pe 's|// <TRICKY-CLANG-FORMAT-PRAGMA-FIX> ||' "$@"