2016-08-20 06:36:49 +08:00
|
|
|
#!/bin/sh
|
|
|
|
|
2016-08-20 02:31:08 +08:00
|
|
|
set -e
|
|
|
|
|
|
|
|
SOURCE_DIR="$1"
|
2016-09-21 17:51:58 +08:00
|
|
|
APIDSL="$2"
|
|
|
|
ASTYLE="$3"
|
2016-08-20 02:31:08 +08:00
|
|
|
|
|
|
|
# Go to the source root.
|
|
|
|
if [ -z "$SOURCE_DIR" ]; then
|
|
|
|
SOURCE_DIR=.
|
|
|
|
fi
|
|
|
|
cd "$SOURCE_DIR"
|
|
|
|
|
2016-09-07 18:09:00 +08:00
|
|
|
if [ -z "$ASTYLE" ] || ! which "$ASTYLE"; then
|
2016-08-20 06:36:49 +08:00
|
|
|
ASTYLE=astyle
|
|
|
|
fi
|
|
|
|
|
2016-09-07 18:09:00 +08:00
|
|
|
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
|
|
|
|
|
2016-09-21 17:51:58 +08:00
|
|
|
if ! which "$APIDSL"; then
|
|
|
|
if [ -f ../apidsl/apigen.native ]; then
|
|
|
|
APIDSL=../apidsl/apigen.native
|
|
|
|
else
|
|
|
|
APIDSL=apidsl_curl
|
2016-10-24 23:06:09 +08:00
|
|
|
fi
|
2016-08-20 02:31:08 +08:00
|
|
|
fi
|
|
|
|
|
|
|
|
apidsl_curl() {
|
|
|
|
curl -X POST --data-binary @"$1" https://apidsl.herokuapp.com/apidsl
|
|
|
|
}
|
|
|
|
|
2016-11-06 23:05:52 +08:00
|
|
|
# Check if apidsl generated sources are up to date.
|
|
|
|
$APIDSL toxcore/crypto_core.api.h > toxcore/crypto_core.h
|
2016-09-21 17:51:58 +08:00
|
|
|
$APIDSL toxcore/tox.api.h > toxcore/tox.h
|
|
|
|
$APIDSL toxav/toxav.api.h > toxav/toxav.h
|
2016-08-20 02:31:08 +08:00
|
|
|
|
2016-09-21 17:51:58 +08:00
|
|
|
SOURCES=`find . -name "*.[ch]" -and -not -name "*.api.h" -and -not -wholename "*crypto_pwhash*" -and -not -wholename "./super_donators/*"`
|
2016-08-20 06:36:49 +08:00
|
|
|
|
2016-08-21 06:15:49 +08:00
|
|
|
$ASTYLE -n --options=other/astyle/astylerc $SOURCES
|
2016-08-20 02:31:08 +08:00
|
|
|
|
|
|
|
git diff --exit-code
|