runastyle

several improvements to help with users that have a development workstation without a native version of astyle with the expected version

patch 2 is the most important and less intrusive change towards that objective but the whole series completes the feature, including parts of patch 4 that will allow for example users with spaces on their username to point to a binary no their home directories.

I decided against splitting the changes on 2 patches for simplicity and because I was expecting the whole series might be squashed for merging anyway
This commit is contained in:
Carlo Marcelo Arenas Belón 2018-11-17 09:29:24 +01:00 committed by Daniel Marjamäki
parent d376e9f245
commit 8e465d5963
1 changed files with 28 additions and 29 deletions

View File

@ -1,4 +1,3 @@
#!/bin/bash #!/bin/bash
# The version check in this script is used to avoid commit battles # The version check in this script is used to avoid commit battles
# between different developers that use different astyle versions as # between different developers that use different astyle versions as
@ -7,37 +6,37 @@
# If project management wishes to take a newer astyle version into use # If project management wishes to take a newer astyle version into use
# just change this string to match the start of astyle version string. # just change this string to match the start of astyle version string.
ASTYLE_VERSION="Artistic Style Version 3.0.1" ASTYLE_VERSION="3.0.1"
ASTYLE="astyle" ASTYLE="${ASTYLE-astyle}"
DETECTED_VERSION=`$ASTYLE --version 2>&1` DETECTED_VERSION=$("$ASTYLE" --version 2>&1 | awk '{ print $NF; }')
if [[ "$DETECTED_VERSION" != ${ASTYLE_VERSION}* ]]; then if [ "$DETECTED_VERSION" != "${ASTYLE_VERSION}" ]; then
echo "You should use: ${ASTYLE_VERSION}"; echo "You should use version: ${ASTYLE_VERSION}"
echo "Detected: ${DETECTED_VERSION}" echo "Detected version: ${DETECTED_VERSION}"
exit 1; exit 1
fi fi
RCFILE=.astylerc RCFILE=.astylerc
$ASTYLE --options=$RCFILE cli/*.cpp "$ASTYLE" --options=$RCFILE cli/*.cpp
$ASTYLE --options=$RCFILE cli/*.h "$ASTYLE" --options=$RCFILE cli/*.h
$ASTYLE --options=$RCFILE democlient/*.cpp "$ASTYLE" --options=$RCFILE democlient/*.cpp
$ASTYLE --options=$RCFILE gui/*.cpp "$ASTYLE" --options=$RCFILE gui/*.cpp
$ASTYLE --options=$RCFILE gui/*.h "$ASTYLE" --options=$RCFILE gui/*.h
$ASTYLE --options=$RCFILE -r gui/test/*.cpp "$ASTYLE" --options=$RCFILE --recursive "gui/test/*.cpp"
$ASTYLE --options=$RCFILE -r gui/test/*.h "$ASTYLE" --options=$RCFILE --recursive "gui/test/*.h"
$ASTYLE --options=$RCFILE lib/*.cpp "$ASTYLE" --options=$RCFILE lib/*.cpp
$ASTYLE --options=$RCFILE lib/*.h "$ASTYLE" --options=$RCFILE lib/*.h
$ASTYLE --options=$RCFILE test/*.cpp "$ASTYLE" --options=$RCFILE test/*.cpp
$ASTYLE --options=$RCFILE test/cfg/*.c "$ASTYLE" --options=$RCFILE test/cfg/*.c
$ASTYLE --options=$RCFILE test/cfg/*.cpp "$ASTYLE" --options=$RCFILE test/cfg/*.cpp
$ASTYLE --options=$RCFILE test/*.h "$ASTYLE" --options=$RCFILE test/*.h
$ASTYLE --options=$RCFILE --recursive "tools/*.cpp" "$ASTYLE" --options=$RCFILE --recursive "tools/*.cpp"
$ASTYLE --options=$RCFILE --recursive "tools/*.h" "$ASTYLE" --options=$RCFILE --recursive "tools/*.h"
$ASTYLE --options=$RCFILE --recursive "samples/*.c" "$ASTYLE" --options=$RCFILE --recursive "samples/*.c"
$ASTYLE --options=$RCFILE --recursive "samples/*.cpp" "$ASTYLE" --options=$RCFILE --recursive "samples/*.cpp"
# Convert tabs to spaces.. even in strings # Convert tabs to spaces.. even in strings
# sed -i "s/\t/ /g" test/test*.cpp # sed -i "s/\t/ /g" test/test*.cpp
@ -46,13 +45,13 @@ $ASTYLE --options=$RCFILE --recursive "samples/*.cpp"
# TODO: use other tool than xmllint? use tabs instead of spaces? # TODO: use other tool than xmllint? use tabs instead of spaces?
for CFGFILE in cfg/*.cfg for CFGFILE in cfg/*.cfg
do do
xmllint --format -o ${CFGFILE}_ ${CFGFILE} xmllint --format -o "${CFGFILE}_" "$CFGFILE"
mv -f ${CFGFILE}_ ${CFGFILE} mv -f "${CFGFILE}_" "$CFGFILE"
done done
for PLATFORMFILE in platforms/*.xml for PLATFORMFILE in platforms/*.xml
do do
xmllint --format -o ${PLATFORMFILE}_ ${PLATFORMFILE} xmllint --format -o "${PLATFORMFILE}_" "$PLATFORMFILE"
mv -f ${PLATFORMFILE}_ ${PLATFORMFILE} mv -f "${PLATFORMFILE}_" "$PLATFORMFILE"
done done
xmllint --format -o man/cppcheck.1.xml_ man/cppcheck.1.xml xmllint --format -o man/cppcheck.1.xml_ man/cppcheck.1.xml