Some fixes for aarch64 macos
[ldk-java] / genbindings.sh
index 7fc10bc9924ecfb0cc68d47208d0c4f3c2fa2929..253b8aad94abb4ba912df8f0ce3a0db85d37c685 100755 (executable)
@@ -29,7 +29,7 @@ if [ "$3" = "leaks" ]; then
 fi
 
 cp "$1/lightning-c-bindings/include/lightning.h" ./
-if [ "$(rustc --version --verbose | grep "host:")" = "host: x86_64-apple-darwin" ]; then
+if [ "$(rustc --version --verbose | grep "host:")" = "host: x86_64-apple-darwin" ] || [ "$(rustc --version --verbose | grep "host:")" = "host: aarch64-apple-darwin" ]; then
        # OSX sed is for some reason not compatible with GNU sed
        sed -i '' "s/TransactionOutputs/C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ/g" ./lightning.h
 else
@@ -60,6 +60,7 @@ if [ "$2" != "wasm" ]; then
                        LDK_JAR_TARGET=true
                        ;;
                "aarch64-apple-darwin"*)
+                       LDK_TARGET_CPU="apple-a14"
                        LDK_TARGET_SUFFIX="_MacOSX-aarch64"
                        LDK_JAR_TARGET=true
                        ;;
@@ -70,7 +71,7 @@ if [ "$2" != "wasm" ]; then
                LDK_TARGET_CPU="sandybridge"
        fi
 
-       if [ "$(rustc --version --verbose | grep "host:")" = "host: x86_64-apple-darwin" ]; then
+       if [ "$(rustc --version --verbose | grep "host:")" = "host: x86_64-apple-darwin" ] || [ "$(rustc --version --verbose | grep "host:")" = "host: aarch64-apple-darwin" ]; then
                # OSX sed is for some reason not compatible with GNU sed
                sed -i '' "s/^    <version>.*<\/version>/    <version>${LDK_GARBAGECOLLECTED_GIT_OVERRIDE:1:100}<\/version>/g" pom.xml
        else
@@ -158,7 +159,7 @@ if [ "$2" != "wasm" ]; then
                        popd
                        LDK_LIB="tmp/libldk.bc tmp/libldk.a"
                fi
-               $COMPILE -o liblightningjni_release$LDK_TARGET_SUFFIX.so -flto -O3 -I"$1"/lightning-c-bindings/include/ $2 src/main/jni/bindings.c $LDK_LIB
+               $COMPILE -o liblightningjni_release$LDK_TARGET_SUFFIX.so -flto -O3 -I"$1"/lightning-c-bindings/include/ $2 src/main/jni/bindings.c $LDK_LIB -lm
                if [ "$IS_MAC" = "false" -a "$4" = "false" ]; then
                        GLIBC_SYMBS="$(objdump -T liblightningjni_release$LDK_TARGET_SUFFIX.so | grep GLIBC_ | grep -v "GLIBC_2\.2\." | grep -v "GLIBC_2\.3\(\.\| \)" | grep -v "GLIBC_2.\(14\|17\) " || echo)"
                        if [ "$GLIBC_SYMBS" != "" ]; then
@@ -222,6 +223,7 @@ else
                rm imports.mts.part
                tsc --types node --typeRoots .
                cp ../$WASM_FILE liblightningjs.wasm
+               cp ../README.md README.md
                echo Ready to publish!
                if [ -x "$(which node)" ]; then
                        NODE_V="$(node --version)"