aboutsummaryrefslogtreecommitdiff
path: root/flatcc/scripts/flatcc-doc.sh
blob: 902ae5c19161bef4b471443f5f60e5dc2f08d40c (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
#!/bin/sh

HOME=$(dirname $0)/..
SCHEMA=${SCHEMA:-$1}
PREFIX=${PREFIX:-$2}
OUTDIR=${OUTDIR:-$3}
OUTDIR=${OUTDIR:-'.'}
INCLUDE=${INCLUDE:-$HOME/include}
FLATCC=${FLATCC:-$HOME/bin/flatcc}

if [ "x$SCHEMA" = "x" ]; then
    echo "Missing schema arg"
    echo "usage: $(basename $0) schema-file name-prefix [outdir]"
    exit 1
fi

if [ "x$PREFIX" = "x" ]; then
    echo "Missing prefix arg"
    echo "usage: $(basename $0) schema-file name-prefix [outdir]"
    exit 1
fi

echo "flatcc doc for schema: '$SCHEMA' with name prefix: '$PREFIX'"

echo "generating $OUTDIR/$PREFIX.doc"

$FLATCC $SCHEMA -a --json --stdout | \
    clang - -E -DNDEBUG -I $INCLUDE | \
    clang-format -style="WebKit" | \
    grep "^static.* $PREFIX\w*(" | \
    cut -f 1 -d '{' | \
    grep -v deprecated | \
    grep -v ");$" | \
    sed 's/__tmp//g' | \
    sed 's/)/);/g' \
    > $OUTDIR/$PREFIX.doc