toxcore/other/astyle/format-source
iphydf bbdd798256
Fix unresolved reference in toxencryptsave API.
Also, make sure this won't happen again by checking for it in
format-source.
2016-12-14 11:35:43 +00:00

53 lines
1.2 KiB
Bash
Executable File

#!/bin/sh
set -e
SOURCE_DIR="$1"
APIDSL="$2"
ASTYLE="$3"
# Go to the source root.
if [ -z "$SOURCE_DIR" ]; then
SOURCE_DIR=.
fi
cd "$SOURCE_DIR"
if [ -z "$ASTYLE" ] || ! which "$ASTYLE"; then
ASTYLE=astyle
fi
if ! which "$ASTYLE"; then
# If we couldn't find or install an astyle binary, don't do anything.
echo "Could not find an astyle binary; please install astyle."
exit 1
fi
if ! which "$APIDSL"; then
if [ -f ../apidsl/apigen.native ]; then
APIDSL=../apidsl/apigen.native
else
APIDSL=apidsl_curl
fi
fi
apidsl_curl() {
curl -X POST --data-binary @"$1" https://apidsl.herokuapp.com/apidsl
}
# Check if apidsl generated sources are up to date.
$APIDSL toxcore/crypto_core.api.h > toxcore/crypto_core.h
$APIDSL toxcore/tox.api.h > toxcore/tox.h
$APIDSL toxav/toxav.api.h > toxav/toxav.h
$APIDSL toxencryptsave/toxencryptsave.api.h > toxencryptsave/toxencryptsave.h
if grep '<unresolved>' */*.h; then
echo "error: some apidsl references were unresolved"
exit 1
fi
SOURCES=`find . -name "*.[ch]" -and -not -name "*.api.h" -and -not -wholename "*crypto_pwhash*" -and -not -wholename "./super_donators/*"`
$ASTYLE -n --options=other/astyle/astylerc $SOURCES
git diff --exit-code