summaryrefslogtreecommitdiff
path: root/src/corefx/format-code.sh
blob: c0898f21259f691ba55f5902bf6430c166694e62 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/usr/bin/env bash

# OS X names clang-format as clang-format; Ubuntu uses
# clang-format-version so check for the right one
if command -v "clang-format-3.6" > /dev/null; then
   export CF="$(command -v clang-format-3.6)"
elif command -v "clang-format" > /dev/null; then
   export CF="$(command -v clang-format)"
else
   echo "Unable to find clang-format"
   exit 1
fi

cd $(dirname "$0")

for D in */; do
    for file in "${D}"*.cpp; do
        if [ -e $file ] ; then
            $CF -style=file -i "$file"
        fi
    done
   
    for file in "${D}"*.h ; do
        if [ -e $file ] ; then
            $CF -style=file -i "$file"
        fi
    done

    for file in "${D}"*.hpp ; do
        if [ -e $file ] ; then
            $CF -style=file -i "$file"
        fi
    done

   for file in "${D}"*.in ; do
       if [ -e $file ] ; then
            $CF -style=file -i "$file"
       fi
   done
done