2020-06-12 18:32:13 +00:00
|
|
|
#!/usr/bin/env bash
|
2020-06-18 13:44:13 +00:00
|
|
|
|
2021-03-10 00:16:36 +00:00
|
|
|
CLANG_FORMAT_DESIRED_VERSION=11
|
|
|
|
|
|
|
|
binary=$(which clang-format-$CLANG_FORMAT_DESIRED_VERSION 2>/dev/null)
|
2021-08-25 23:54:08 +00:00
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
binary=$(which clang-format-mp-$CLANG_FORMAT_DESIRED_VERSION 2>/dev/null)
|
|
|
|
fi
|
2021-03-10 00:16:36 +00:00
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
binary=$(which clang-format 2>/dev/null)
|
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
echo "Please install clang-format version $CLANG_FORMAT_DESIRED_VERSION and re-run this script."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
version=$(clang-format --version)
|
|
|
|
if [[ ! $version == *"clang-format version $CLANG_FORMAT_DESIRED_VERSION"* ]]; then
|
|
|
|
echo "Please install clang-format version $CLANG_FORMAT_DESIRED_VERSION and re-run this script."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2021-05-12 11:36:00 +00:00
|
|
|
cd "$(dirname $0)/../"
|
|
|
|
if [ "$1" = "verify" ] ; then
|
2021-08-25 23:28:58 +00:00
|
|
|
if [ $($binary --output-replacements-xml $(find jni daemon llarp include pybind | grep -E '\.([hc](pp)?|mm?)$' | grep -v '\#') | grep '</replacement>' | wc -l) -ne 0 ] ; then
|
2021-05-14 17:07:44 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
2021-05-12 11:36:00 +00:00
|
|
|
else
|
2021-06-30 11:21:17 +00:00
|
|
|
$binary -i $(find jni daemon llarp include pybind | grep -E '\.([hc](pp)?|mm)$' | grep -v '\#') &> /dev/null
|
2021-05-12 11:36:00 +00:00
|
|
|
fi
|
2021-05-14 17:07:44 +00:00
|
|
|
|
|
|
|
swift_format=$(which swiftformat 2>/dev/null)
|
|
|
|
if [ $? -eq 0 ]; then
|
|
|
|
if [ "$1" = "verify" ] ; then
|
|
|
|
for f in $(find daemon | grep -E '\.swift$' | grep -v '\#') ; do
|
|
|
|
if [ $($swift_format --quiet --dryrun < "$f" | diff "$f" - | wc -l) -ne 0 ] ; then
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
else
|
|
|
|
$swift_format --quiet $(find daemon | grep -E '\.swift$' | grep -v '\#')
|
|
|
|
fi
|
|
|
|
|
|
|
|
fi
|