aboutsummaryrefslogtreecommitdiff
path: root/flatcc/scripts/_user_build.in
blob: dfcc40a624f87f4d75e08bd8372b718290bd3c43 (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
#!/bin/bash

set -e

CC=${CC:-cc}

# assume we are in a subdirectory of the project to build
HERE=$(dirname $0)/..
cd $HERE
ROOT=$(pwd)
NAME=$(basename $ROOT)

mkdir -p build
mkdir -p generated

cd build

if [[ "$FLATCC_PORTABLE" = "yes" ]]; then
    CFLAGS="$CFLAGS -DFLATCC_PORTABLE"
fi

CFLAGS="$CFLAGS -I ${ROOT}/include -I ${ROOT}/generated"
CFLAGS_DEBUG=${CFLAGS_DEBUG:--g}
CFLAGS_RELEASE=${CFLAGS_RELEASE:--O2 -DNDEBUG}

${ROOT}/bin/flatcc -a -o ${ROOT}/generated ${ROOT}/src/*.fbs

echo "building '$NAME' for debug"
$CC $CFLAGS $CFLAGS_DEBUG ${ROOT}/src/*.c ${ROOT}/lib/libflatccrt_d.a -o ${NAME}_d

echo "building '$NAME' for release"
$CC $CFLAGS $CFLAGS_RELEASE ${ROOT}/src/*.c ${ROOT}/lib/libflatccrt.a -o ${NAME}