diff options
Diffstat (limited to 'other/astyle/format-source')
-rwxr-xr-x | other/astyle/format-source | 49 |
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' | |||
36 | apidsl_request() { | 36 | apidsl_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. |
59 | set +x | 62 | set +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 & |
67 | set -x | 70 | set -x |
68 | 71 | ||
69 | wait; wait; wait; wait; wait; wait; wait | 72 | wait |
73 | wait | ||
74 | wait | ||
75 | wait | ||
76 | wait | ||
77 | wait | ||
78 | wait | ||
70 | 79 | ||
71 | if grep '<unresolved>' ./*/*.h; then | 80 | if 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 |
74 | fi | 83 | fi |
75 | 84 | ||
76 | CC_SOURCES=$(find . '(' -name '*.cc' ')') | 85 | readarray -t CC_SOURCES <<<"$(find . '(' -name '*.cc' ')')" |
77 | CC_SOURCES="$CC_SOURCES toxcore/crypto_core.c" | 86 | CC_SOURCES+=(toxcore/crypto_core.c) |
78 | CC_SOURCES="$CC_SOURCES toxcore/ping_array.c" | 87 | CC_SOURCES+=(toxcore/ping_array.c) |
79 | 88 | ||
80 | for bin in clang-format-6.0 clang-format-5.0 clang-format; do | 89 | for 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 |
85 | done | 94 | done |
@@ -91,8 +100,8 @@ FIND="$FIND -and -not -wholename './super_donators/*'" | |||
91 | FIND="$FIND -and -not -wholename './third_party/*'" | 100 | FIND="$FIND -and -not -wholename './third_party/*'" |
92 | FIND="$FIND -and -not -wholename './toxencryptsave/crypto_pwhash*'" | 101 | FIND="$FIND -and -not -wholename './toxencryptsave/crypto_pwhash*'" |
93 | 102 | ||
94 | C_SOURCES=$(eval "$FIND") | 103 | readarray -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 | ||
98 | git diff --exit-code | 107 | git diff --color=always --exit-code |