2009-01-05 16:52:02 +01:00
|
|
|
#!/bin/bash
|
2012-09-28 20:25:46 +02:00
|
|
|
# The version check in this script is used to avoid commit battles
|
2011-06-22 13:20:36 +02:00
|
|
|
# between different developers that use different astyle versions as
|
|
|
|
# different versions might have different output (this has happened in
|
|
|
|
# the past).
|
|
|
|
|
|
|
|
# If project management wishes to take a newer astyle version into use
|
2011-06-22 20:41:14 +02:00
|
|
|
# just change this string to match the start of astyle version string.
|
2018-11-17 09:29:24 +01:00
|
|
|
ASTYLE_VERSION="3.0.1"
|
|
|
|
ASTYLE="${ASTYLE-astyle}"
|
|
|
|
|
|
|
|
DETECTED_VERSION=$("$ASTYLE" --version 2>&1 | awk '{ print $NF; }')
|
|
|
|
if [ "$DETECTED_VERSION" != "${ASTYLE_VERSION}" ]; then
|
2019-02-07 19:57:01 +01:00
|
|
|
echo "You should use version: ${ASTYLE_VERSION}"
|
|
|
|
echo "Detected version: ${DETECTED_VERSION}"
|
|
|
|
exit 1
|
2011-02-11 22:37:38 +01:00
|
|
|
fi
|
2009-01-05 16:52:02 +01:00
|
|
|
|
2018-11-09 09:55:34 +01:00
|
|
|
RCFILE=.astylerc
|
|
|
|
|
2019-02-03 20:51:14 +01:00
|
|
|
function formatCplusplus {
|
2019-02-07 19:57:01 +01:00
|
|
|
"$ASTYLE" --options=$RCFILE "$1"
|
2019-02-03 20:51:14 +01:00
|
|
|
}
|
|
|
|
function formatCplusplusRecursive {
|
2019-02-07 19:57:01 +01:00
|
|
|
RCFILE=.astylerc
|
|
|
|
"$ASTYLE" --options=$RCFILE --recursive "$1"
|
2019-02-03 20:51:14 +01:00
|
|
|
}
|
|
|
|
|
2019-02-07 08:52:20 +01:00
|
|
|
formatCplusplus "cli/*.cpp"
|
|
|
|
formatCplusplus "cli/*.h"
|
|
|
|
formatCplusplus "democlient/*.cpp"
|
|
|
|
formatCplusplus "gui/*.cpp"
|
|
|
|
formatCplusplus "gui/*.h"
|
2019-02-03 20:51:14 +01:00
|
|
|
formatCplusplusRecursive "gui/test/*.cpp"
|
|
|
|
formatCplusplusRecursive "gui/test/*.h"
|
2019-02-07 08:52:20 +01:00
|
|
|
formatCplusplus "lib/*.cpp"
|
|
|
|
formatCplusplus "lib/*.h"
|
|
|
|
formatCplusplus "test/*.cpp"
|
|
|
|
formatCplusplus "test/cfg/*.c"
|
|
|
|
formatCplusplus "test/cfg/*.cpp"
|
|
|
|
formatCplusplus "test/*.h"
|
|
|
|
formatCplusplus "tools/*.cpp"
|
2019-02-03 20:51:14 +01:00
|
|
|
formatCplusplusRecursive "tools/*.h"
|
|
|
|
formatCplusplusRecursive "samples/*.c"
|
|
|
|
formatCplusplusRecursive "samples/*.cpp"
|
2012-10-03 20:14:23 +02:00
|
|
|
|
|
|
|
# Convert tabs to spaces.. even in strings
|
2013-01-24 19:44:42 +01:00
|
|
|
# sed -i "s/\t/ /g" test/test*.cpp
|
2012-10-03 20:14:23 +02:00
|
|
|
|
2019-02-03 20:51:14 +01:00
|
|
|
function formatXML {
|
2019-02-07 19:57:01 +01:00
|
|
|
xmllint --format -o "$1_" "$1"
|
|
|
|
if cmp -s "$1_" "$1"; then
|
|
|
|
rm -f "$1_"
|
|
|
|
else
|
|
|
|
mv -f "$1_" "$1"
|
|
|
|
fi
|
2019-02-03 20:51:14 +01:00
|
|
|
}
|
|
|
|
|
2014-10-14 06:46:22 +02:00
|
|
|
# format config files
|
|
|
|
# TODO: use other tool than xmllint? use tabs instead of spaces?
|
2014-10-16 06:38:18 +02:00
|
|
|
for CFGFILE in cfg/*.cfg
|
|
|
|
do
|
2019-02-07 19:57:01 +01:00
|
|
|
formatXML "$CFGFILE"
|
2014-10-16 06:38:18 +02:00
|
|
|
done
|
2018-02-16 09:08:38 +01:00
|
|
|
for PLATFORMFILE in platforms/*.xml
|
|
|
|
do
|
2019-02-07 19:57:01 +01:00
|
|
|
formatXML "$PLATFORMFILE"
|
2018-02-16 09:08:38 +01:00
|
|
|
done
|
2018-10-13 18:39:37 +02:00
|
|
|
|
2019-02-03 20:51:14 +01:00
|
|
|
formatXML man/cppcheck.1.xml
|
|
|
|
formatXML cppcheck-errors.rng
|