nostrdb

an unfairly fast embedded nostr database backed by lmdb
git clone git://jb55.com/nostrdb
Log | Files | Refs | Submodules | README | LICENSE

_user_build.in (1045B)


      1 #!/bin/bash
      2 
      3 set -e
      4 
      5 CC=${CC:-cc}
      6 
      7 # assume we are in a subdirectory of the project to build
      8 HERE=$(dirname $0)/..
      9 cd $HERE
     10 ROOT=$(pwd)
     11 NAME=$(basename $ROOT)
     12 
     13 mkdir -p build
     14 mkdir -p generated
     15 
     16 cd build
     17 
     18 # we cannot link with debug library unless we use the sanitize flag.
     19 SANFLAG_DEBUG=""
     20 compiler_info="$($CC --version 2>&1)"
     21 echo "using compiler: $compiler_info"
     22 if echo $compiler_info | grep -q -i "clang"; then
     23     SANFLAG_DEBUG="-fsanitize=undefined"
     24     echo "debug sanitizer flag: $SANFLAG_DEBUG"
     25 fi
     26 
     27 if [[ "$FLATCC_PORTABLE" = "yes" ]]; then
     28     CFLAGS="$CFLAGS -DFLATCC_PORTABLE"
     29 fi
     30 
     31 CFLAGS="$CFLAGS -I ${ROOT}/include -I ${ROOT}/generated"
     32 CFLAGS_DEBUG=${CFLAGS_DEBUG:--g $SANFLAG_DEBUG}
     33 CFLAGS_RELEASE=${CFLAGS_RELEASE:--O2 -DNDEBUG}
     34 
     35 ${ROOT}/bin/flatcc -a -o ${ROOT}/generated ${ROOT}/src/*.fbs
     36 
     37 echo "building '$NAME' for debug"
     38 $CC $CFLAGS $CFLAGS_DEBUG ${ROOT}/src/*.c ${ROOT}/lib/libflatccrt_d.a -o ${NAME}_d
     39 
     40 echo "building '$NAME' for release"
     41 $CC $CFLAGS $CFLAGS_RELEASE ${ROOT}/src/*.c ${ROOT}/lib/libflatccrt.a -o ${NAME}