aboutsummaryrefslogtreecommitdiff
path: root/scripts/_user_build.in
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/_user_build.in')
-rw-r--r--scripts/_user_build.in32
1 files changed, 32 insertions, 0 deletions
diff --git a/scripts/_user_build.in b/scripts/_user_build.in
new file mode 100644
index 0000000..dfcc40a
--- /dev/null
+++ b/scripts/_user_build.in
@@ -0,0 +1,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}