File: format-coding-style.sh

package info (click to toggle)
visp 3.7.0-7
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 166,380 kB
  • sloc: cpp: 392,705; ansic: 224,448; xml: 23,444; python: 13,701; java: 4,792; sh: 206; objc: 145; makefile: 118
file content (33 lines) | stat: -rw-r--r-- 893 bytes parent folder | download | duplicates (7)
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
#!/bin/sh

script_path=`dirname $0`
visp_root=`(cd $script_path/..; pwd)`

# Change this if your clang-format executable is somewhere else
clang_format="clang-format"

command_exists () {
  type "$1" &> /dev/null ;
}

if ! command_exists $clang_format ; then
    echo "You have to install clang-format before using this script"
    echo "  Ubuntu: sudo apt-get install clang-format"
    echo "  OSX   : brew update; brew install clang-format"
    exit 0
fi

echo "Apply coding-style to visp: " $visp_root

read -r -p "Are you sure? [Y/n] " answer
answer="$(echo ${answer} | tr 'A-Z' 'a-z')"

if echo "$answer" | grep -iq "^y" ;then
  echo "We are applying coding-style rules..."
else
  echo "Exit the script"
  exit 0
fi

find "$visp_root" \( -name '*.h' -or -name '*.hpp' -or -name '*.c' -or -name '*.cpp' \) -not -path "${visp_root}/3rdparty/*" -prune -print0 | xargs -0 "$clang_format" -i