File: format-coding-style.sh

package info (click to toggle)
visp 3.6.0-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 119,296 kB
  • sloc: cpp: 500,914; ansic: 52,904; xml: 22,642; python: 7,365; java: 4,247; sh: 482; makefile: 237; objc: 145
file content (33 lines) | stat: -rw-r--r-- 893 bytes parent folder | download | duplicates (4)
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