summaryrefslogtreecommitdiff
path: root/other/astyle/format-source
blob: 47a4a42023163dd0c3a345881f87782c4f87f8fc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/bin/sh

set -e

SOURCE_DIR="$1"

# 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 [ -f ../apidsl/apigen.native ]; then
  APIDSL=../apidsl/apigen.native
else
  APIDSL=apidsl_curl
fi

apidsl_curl() {
  curl -X POST --data-binary @"$1" https://apidsl.herokuapp.com/apidsl
}

# Check if toxcore.h and toxav.h match apidsl tox.in.h and toxav.in.h.
$APIDSL other/apidsl/tox.in.h   > toxcore/tox.h
$APIDSL other/apidsl/toxav.in.h > toxav/toxav.h

SOURCES=`find . -name "*.[ch]" -and -not -name "*.in.*" -and -not -wholename "*crypto_pwhash*" -and -not -wholename "./super_donators/*"`

$ASTYLE -n --options=other/astyle/astylerc $SOURCES

git diff --exit-code