X-Git-Url: http://git.bitcoin.ninja/index.cgi?p=ldk-c-bindings;a=blobdiff_plain;f=genbindings.sh;h=f74b2ac61e2f619ffd88dd1209d07e9b49f82ab3;hp=3aa2f005390c19ed71a6a5acdca9d4d553c466b6;hb=fee27c4b40d1d25609a38bb220dd64b297af929a;hpb=0dddf9568dc41568aebdd4b4ce496d92d7c9054e diff --git a/genbindings.sh b/genbindings.sh index 3aa2f00..f74b2ac 100755 --- a/genbindings.sh +++ b/genbindings.sh @@ -230,9 +230,12 @@ while read LINE; do # We'll print this at the end ;; "XXX"*) - STRUCT_NAME="$(echo "$LINE" | awk '{ print $2 }')" + NEW_STRUCT_NAME="$(echo "$LINE" | awk '{ print $2 }')" + if [ "$NEW_STRUCT_NAME" != "$STRUCT_NAME" ]; then + STRUCT_CONTENTS="$(cat include/lightning.h | sed -n -e "/struct LDK$NEW_STRUCT_NAME/{:s" -e "/\} LDK$NEW_STRUCT_NAME;/!{N" -e "b s" -e "}" -e p -e "}")" + fi + STRUCT_NAME="$NEW_STRUCT_NAME" METHOD_NAME="$(echo "$LINE" | awk '{ print $3 }')" - STRUCT_CONTENTS="$(cat include/lightning.h | sed -n -e "/struct LDK$STRUCT_NAME/{:s" -e "/\} LDK$STRUCT_NAME;/!{N" -e "b s" -e "}" -e p -e "}")" METHOD="$(echo "$STRUCT_CONTENTS" | grep "(\*$METHOD_NAME)")" if [ "$METHOD" = "" ]; then echo "Unable to find method declaration for $LINE" @@ -273,7 +276,7 @@ mv include/lightningpp_new.hpp include/lightningpp.hpp # Finally, sanity-check the generated C and C++ bindings with demo apps: # Naively run the C demo app: -gcc $LOCAL_CFLAGS -Wall -g -pthread demo.c target/debug/libldk.a -ldl +gcc $LOCAL_CFLAGS -Wall -g -pthread demo.c target/debug/libldk.a -ldl -lm ./a.out # And run the C++ demo app @@ -283,7 +286,7 @@ LD_LIBRARY_PATH=target/debug/ ./a.out > /dev/null # Finally, run the C++ demo app with our native networking library # in valgrind to test memory model correctness and lack of leaks. gcc $LOCAL_CFLAGS -fPIC -std=c99 -Wall -g -pthread -I../ldk-net ../ldk-net/ldk_net.c -c -o ldk_net.o -g++ $LOCAL_CFLAGS -std=c++11 -Wall -g -pthread -DREAL_NET -I../ldk-net ldk_net.o demo.cpp target/debug/libldk.a -ldl +g++ $LOCAL_CFLAGS -std=c++11 -Wall -g -pthread -DREAL_NET -I../ldk-net ldk_net.o demo.cpp target/debug/libldk.a -ldl -lm if [ -x "`which valgrind`" ]; then valgrind --error-exitcode=4 --memcheck:leak-check=full --show-leak-kinds=all ./a.out echo