summaryrefslogtreecommitdiff
path: root/other/astyle/format-source
diff options
context:
space:
mode:
Diffstat (limited to 'other/astyle/format-source')
-rwxr-xr-xother/astyle/format-source49
1 files changed, 29 insertions, 20 deletions
diff --git a/other/astyle/format-source b/other/astyle/format-source
index 193e335c..7de28d06 100755
--- a/other/astyle/format-source
+++ b/other/astyle/format-source
@@ -36,10 +36,11 @@ FROM_JSON='s/\\"/"/g;s/^"(.*)"$/$1/;s/\\\\/\\/g;s/\\n/\n/g'
36apidsl_request() { 36apidsl_request() {
37 TMPFILE=$(mktemp /tmp/apidsl.XXXXXX) 37 TMPFILE=$(mktemp /tmp/apidsl.XXXXXX)
38 curl -s -o "$TMPFILE" -X POST --data @<( 38 curl -s -o "$TMPFILE" -X POST --data @<(
39 echo '["Request",'; 39 echo '["Request",'
40 cat $2; 40 cat "$2"
41 echo ']') https://apidsl.herokuapp.com/$1 41 echo ']'
42 if grep '\[1,"' "$TMPFILE" > /dev/null; then 42 ) "https://apidsl.herokuapp.com/$1"
43 if grep '\[1,"' "$TMPFILE" >/dev/null; then
43 echo "Error: $(grep -o '".*"' /tmp/apidsl-$$ | perl -0777 -pe "$FROM_JSON")" >&2 44 echo "Error: $(grep -o '".*"' /tmp/apidsl-$$ | perl -0777 -pe "$FROM_JSON")" >&2
44 rm "$TMPFILE" 45 rm "$TMPFILE"
45 exit 1 46 exit 1
@@ -52,34 +53,42 @@ apidsl_curl() {
52 echo "apidsl_curl $*" >&2 53 echo "apidsl_curl $*" >&2
53 apidsl_request "c" <( 54 apidsl_request "c" <(
54 apidsl_request "parse" <( 55 apidsl_request "parse" <(
55 perl -0777 -pe "$TO_JSON" $1)) | perl -0777 -pe "$FROM_JSON" 56 perl -0777 -pe "$TO_JSON" "$1"
57 )
58 ) | perl -0777 -pe "$FROM_JSON"
56} 59}
57 60
58# Check if apidsl generated sources are up to date. 61# Check if apidsl generated sources are up to date.
59set +x 62set +x
60$APIDSL toxcore/LAN_discovery.api.h > toxcore/LAN_discovery.h & 63"$APIDSL" toxcore/LAN_discovery.api.h >toxcore/LAN_discovery.h &
61$APIDSL toxcore/crypto_core.api.h > toxcore/crypto_core.h & 64"$APIDSL" toxcore/crypto_core.api.h >toxcore/crypto_core.h &
62$APIDSL toxcore/ping.api.h > toxcore/ping.h & 65"$APIDSL" toxcore/ping.api.h >toxcore/ping.h &
63$APIDSL toxcore/ping_array.api.h > toxcore/ping_array.h & 66"$APIDSL" toxcore/ping_array.api.h >toxcore/ping_array.h &
64$APIDSL toxcore/tox.api.h > toxcore/tox.h & 67"$APIDSL" toxcore/tox.api.h >toxcore/tox.h &
65$APIDSL toxav/toxav.api.h > toxav/toxav.h & 68"$APIDSL" toxav/toxav.api.h >toxav/toxav.h &
66$APIDSL toxencryptsave/toxencryptsave.api.h > toxencryptsave/toxencryptsave.h & 69"$APIDSL" toxencryptsave/toxencryptsave.api.h >toxencryptsave/toxencryptsave.h &
67set -x 70set -x
68 71
69wait; wait; wait; wait; wait; wait; wait 72wait
73wait
74wait
75wait
76wait
77wait
78wait
70 79
71if grep '<unresolved>' ./*/*.h; then 80if grep '<unresolved>' ./*/*.h; then
72 echo "error: some apidsl references were unresolved" 81 echo "error: some apidsl references were unresolved"
73 exit 1 82 exit 1
74fi 83fi
75 84
76CC_SOURCES=$(find . '(' -name '*.cc' ')') 85readarray -t CC_SOURCES <<<"$(find . '(' -name '*.cc' ')')"
77CC_SOURCES="$CC_SOURCES toxcore/crypto_core.c" 86CC_SOURCES+=(toxcore/crypto_core.c)
78CC_SOURCES="$CC_SOURCES toxcore/ping_array.c" 87CC_SOURCES+=(toxcore/ping_array.c)
79 88
80for bin in clang-format-6.0 clang-format-5.0 clang-format; do 89for bin in clang-format-6.0 clang-format-5.0 clang-format; do
81 if which "$bin"; then 90 if which "$bin"; then
82 "$bin" -i -style='{BasedOnStyle: Google, ColumnLimit: 100}' $CC_SOURCES 91 "$bin" -i -style='{BasedOnStyle: Google, ColumnLimit: 100}' "${CC_SOURCES[@]}"
83 break 92 break
84 fi 93 fi
85done 94done
@@ -91,8 +100,8 @@ FIND="$FIND -and -not -wholename './super_donators/*'"
91FIND="$FIND -and -not -wholename './third_party/*'" 100FIND="$FIND -and -not -wholename './third_party/*'"
92FIND="$FIND -and -not -wholename './toxencryptsave/crypto_pwhash*'" 101FIND="$FIND -and -not -wholename './toxencryptsave/crypto_pwhash*'"
93 102
94C_SOURCES=$(eval "$FIND") 103readarray -t C_SOURCES <<<"$(eval "$FIND")"
95 104
96$ASTYLE -n --options=other/astyle/astylerc $C_SOURCES 105"$ASTYLE" -n --options=other/astyle/astylerc "${C_SOURCES[@]}"
97 106
98git diff --exit-code 107git diff --color=always --exit-code