Add format-source script.

This is easier to use from a precommit hook, so it can be used to ensure that
all formatting is correct before committing code.
This commit is contained in:
iphydf 2016-08-19 23:36:49 +01:00
parent 0e18966a27
commit c597f67012
No known key found for this signature in database
GPG Key ID: 3855DBA2D74403C9
2 changed files with 12 additions and 3 deletions

9
other/astyle/format-source Executable file
View File

@ -0,0 +1,9 @@
#!/bin/sh
if [ -z "$ASTYLE" ]; then
ASTYLE=astyle
fi
SOURCES=`find . -name "*.[ch]" -and -not -name "*.in.*" -and -not -wholename "*crypto_pwhash*" -and -not -wholename "./super_donators/*"`
$ASTYLE --options=other/astyle/astylerc $SOURCES

View File

@ -4,10 +4,10 @@ set -e -u -x
. other/travis/env-$ENV.sh . other/travis/env-$ENV.sh
# Check if toxcore.h and toxav.h match apidsl tox.in.h and toxav.in.h. # Check if toxcore.h and toxav.h match apidsl tox.in.h and toxav.in.h.
../apidsl/_build/apigen.native other/apidsl/tox.in.h | $ASTYLE --options=other/astyle/astylerc > toxcore/tox.h ../apidsl/_build/apigen.native other/apidsl/tox.in.h > toxcore/tox.h
../apidsl/_build/apigen.native other/apidsl/toxav.in.h | $ASTYLE --options=other/astyle/astylerc > toxav/toxav.h ../apidsl/_build/apigen.native other/apidsl/toxav.in.h > toxav/toxav.h
# Check if the code is formatted according to the astyle configuration. # Check if the code is formatted according to the astyle configuration.
$ASTYLE --options=other/astyle/astylerc `find . -name "*.[ch]" -and -not -name "*.in.*" -and -not -wholename "*crypto_pwhash*" -and -not -wholename "./super_donators/*"` other/astyle/format-source
git diff --exit-code git diff --exit-code
# Build toxcore and run tests. # Build toxcore and run tests.