LP-551 Remove BankMode string and use UavObject definitions
[librepilot.git] / make / scripts / uncrustify.sh
blobfb76263e6ab01b09a8eead74a5b334fba93f2eaf
1 #!/bin/bash -e
3 # uncrustify.sh - source code processing script.
4 # Copyright (c) 2013, The OpenPilot Team, http://www.openpilot.org
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 3 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful, but
12 # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 # for more details.
16 # You should have received a copy of the GNU General Public License along
17 # with this program; if not, write to the Free Software Foundation, Inc.,
18 # 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 # The following environment variables must be set
22 : ${UNCRUSTIFY?} ${UNCRUSTIFY_CONFIG?}
24 # No format flag file name
25 NO_FORMAT=.no-auto-format
27 # Recursive directory tree walk function
28 recursive()
30 if [ -d "$1" ]; then
31 # skip directory if no-format file is found
32 if [ -f "$1/$NO_FORMAT" ]; then
33 echo "Skipping: $1/"
34 return
36 echo "Processing: $1/"
38 # process all files and subdirectories
39 local name
40 for name in $1/*; do
41 recursive "$name"
42 done
43 else
44 # process only known file extensions
45 case "$1" in
46 *.c|*.h|*.cc|*.cpp|*.hpp)
47 ${UNCRUSTIFY} -c "${UNCRUSTIFY_CONFIG}" --no-backup "$1"
48 ${UNCRUSTIFY} -c "${UNCRUSTIFY_CONFIG}" --no-backup "$1" -q
50 esac
54 # Entry point
55 for dir in $*; do
56 recursive "$dir"
57 done