From: Matt Corallo Date: Sat, 12 Jun 2021 16:50:05 +0000 (+0000) Subject: Better support alternative targets in genbindings.sh X-Git-Tag: v0.0.98.1~2 X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=commitdiff_plain;h=d4e3e76ade1317f8ce4e2e6beb8f25a35e0b7f9e;p=ldk-java Better support alternative targets in genbindings.sh --- diff --git a/genbindings.sh b/genbindings.sh index 0cd88ba5..c10ff241 100755 --- a/genbindings.sh +++ b/genbindings.sh @@ -16,6 +16,13 @@ else COMMON_COMPILE="clang -std=c11 -Wall -Wextra -Wno-unused-parameter -Wno-ignored-qualifiers -Wno-unused-function -Wno-nullability-completeness -Wno-pointer-sign -Wdate-time -ffile-prefix-map=$(pwd)=" fi +if [ "$LDK_TARGET" != "" ]; then + LDK_TARGET_SUFFIX="_$LDK_TARGET" +fi +if [ "$LDK_TARGET_CPU" = "" ]; then + LDK_TARGET_CPU="sandybridge" +fi + set -e if [ "$LDK_GARBAGECOLLECTED_GIT_OVERRIDE" = "" ]; then @@ -46,11 +53,11 @@ javac -h src/main/jni src/main/java/org/ldk/enums/*.java src/main/java/org/ldk/i rm src/main/java/org/ldk/enums/*.class src/main/java/org/ldk/impl/bindings*.class echo "Building Java bindings..." -COMPILE="$COMMON_COMPILE -march=sandybridge -Isrc/main/jni -pthread -ldl -Wl,--no-undefined -shared -fPIC" +COMPILE="$COMMON_COMPILE -mcpu=$LDK_TARGET_CPU -Isrc/main/jni -pthread -ldl -Wl,--no-undefined -shared -fPIC" if [ "$3" = "true" ]; then - $COMPILE -o liblightningjni_debug.so -g -fsanitize=address -shared-libasan -Wl,-wrap,calloc -Wl,-wrap,realloc -Wl,-wrap,reallocarray -Wl,-wrap,malloc -Wl,-wrap,free -rdynamic -I"$1"/lightning-c-bindings/include/ $2 src/main/jni/bindings.c "$1"/lightning-c-bindings/target/debug/libldk.a -lm + $COMPILE -o liblightningjni_debug$LDK_TARGET_SUFFIX.so -g -fsanitize=address -shared-libasan -Wl,-wrap,calloc -Wl,-wrap,realloc -Wl,-wrap,reallocarray -Wl,-wrap,malloc -Wl,-wrap,free -rdynamic -I"$1"/lightning-c-bindings/include/ $2 src/main/jni/bindings.c "$1"/lightning-c-bindings/target/$LDK_TARGET/debug/libldk.a -lm else - $COMPILE -o liblightningjni_release.so -Wl,--version-script=libcode.version -flto -fuse-ld=lld -O3 -I"$1"/lightning-c-bindings/include/ $2 src/main/jni/bindings.c "$1"/lightning-c-bindings/target/release/libldk.a + $COMPILE -o liblightningjni_release$LDK_TARGET_SUFFIX.so -Wl,--version-script=libcode.version -flto -fuse-ld=lld -O3 -I"$1"/lightning-c-bindings/include/ $2 src/main/jni/bindings.c "$1"/lightning-c-bindings/target/$LDK_TARGET/release/libldk.a fi echo "Creating TS bindings..."