Update CI references to LDK 0.0.121 branches
[ldk-java] / genbindings.sh
index 2e8204cc35c206cbe57dac615ee5c720ef3101e6..4a37eb3068f9fc6b4f9299fe2a4c38017455a47e 100755 (executable)
@@ -43,6 +43,11 @@ case "$TARGET_STRING" in
                CS_PLATFORM_NAME="linux-x64"
                LDK_JAR_TARGET=true
                ;;
+       "x86_64-redhat-linux"*)
+               LDK_TARGET_SUFFIX="_Linux-amd64"
+               CS_PLATFORM_NAME="linux-x64"
+               LDK_JAR_TARGET=true
+               ;;
        "x86_64-apple-darwin"*)
                LDK_TARGET_SUFFIX="_MacOSX-x86_64"
                CS_PLATFORM_NAME="osx-x64"
@@ -129,11 +134,12 @@ if [ "$2" = "c_sharp" ]; then
        fi
 
        # Compiling C# bindings with Mono
-       MONO_COMPILE="-out:csharpldk.dll -langversion:3 -t:library -unsafe c_sharp/src/org/ldk/enums/*.cs c_sharp/src/org/ldk/impl/*.cs c_sharp/src/org/ldk/util/*.cs c_sharp/src/org/ldk/structs/*.cs"
        if [ "$3" = "true" ]; then
-               mono-csc -g $MONO_COMPILE
+               mono-csc -g -out:csharpldk.dll -langversion:3 -t:library -unsafe c_sharp/src/org/ldk/enums/*.cs c_sharp/src/org/ldk/impl/*.cs c_sharp/src/org/ldk/util/*.cs c_sharp/src/org/ldk/structs/*.cs
        else
-               mono-csc -optimize+ $MONO_COMPILE
+               cd c_sharp
+               dotnet build --configuration Release
+               cd ..
        fi
 
        echo "Building C# bindings..."
@@ -153,11 +159,11 @@ if [ "$2" = "c_sharp" ]; then
                [ "$IS_APPLE_CLANG" = "false" ] && COMPILE="$COMPILE -flto"
                [ "$IS_MAC" = "false" ] && LINK="$LINK -Wl,--no-undefined"
                [ "$IS_WIN" = "false" ] && LINK="$LINK -Wl,--lto-O3"
-               [ "$IS_WIN" = "true" ] && LINK="$LINK --target=x86_64-pc-windows-gnu -L/usr/lib/gcc/x86_64-w64-mingw32/12-win32/ -lbcrypt -static-libgcc"
+               [ "$IS_WIN" = "true" ] && LINK="$LINK --target=x86_64-pc-windows-gnu -L/usr/lib/gcc/x86_64-w64-mingw32/12-win32/ -lbcrypt -lntdll -static-libgcc"
                [ "$IS_WIN" = "true" ] && COMPILE="$COMPILE --target=x86_64-pc-windows-gnu"
                LDK_LIB="$1"/lightning-c-bindings/target/$LDK_TARGET/release/libldk.a
                if [ "$IS_MAC" = "false" -a "$IS_WIN" = "false" -a "$4" = "false" ]; then
-                       LINK="$LINK -Wl,--version-script=c_sharp/libcode.version"
+                       LINK="$LINK -Wl,--version-script=c_sharp/libcode.version -Wl,--build-id=0x0000000000000000"
                fi
 
                # When building for Windows, a timestamp is included in the resulting dll,
@@ -168,8 +174,8 @@ if [ "$2" = "c_sharp" ]; then
 
                if [ "$LDK_JAR_TARGET" = "true" ]; then
                        # Copy resulting native binary for inclusion in release nuget zip
-                       mkdir -p c_sharp/packaging_artifacts/lib/net3.0/
-                       cp csharpldk.dll c_sharp/packaging_artifacts/lib/net3.0/
+                       mkdir -p c_sharp/packaging_artifacts/lib/net6.0/
+                       cp c_sharp/bin/Release/net6.0/csharpldk.dll c_sharp/packaging_artifacts/lib/net6.0/
 
                        mkdir -p c_sharp/packaging_artifacts/runtimes/"$CS_PLATFORM_NAME"/native/
                        if [ "$IS_WIN" = "true" ]; then
@@ -329,12 +335,27 @@ else
                [ "$IS_WIN" = "true" ] && LINK="$LINK -L/usr/lib/gcc/x86_64-w64-mingw32/12-win32/ -lbcrypt"
                LDK_LIB="$1"/lightning-c-bindings/target/$LDK_TARGET/release/libldk.a
                if [ "$IS_MAC" = "false" -a "$IS_WIN" = "false" -a "$4" = "false" ]; then
-                       LINK="$LINK -Wl,--version-script=c_sharp/libcode.version"
+                       LINK="$LINK -Wl,--version-script=libcode.version"
                fi
 
                $COMPILE -o bindings.o -c -O3 -I"$1"/lightning-c-bindings/include/ $2 src/main/jni/bindings.c
                $COMPILE $LINK -o liblightningjni_release$LDK_TARGET_SUFFIX.so -O3 $2 bindings.o $LDK_LIB -lm
                [ "$IS_APPLE_CLANG" != "true" ] && llvm-strip liblightningjni_release$LDK_TARGET_SUFFIX.so
+
+               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\|3\)\(\.\|)\)" | grep -v "GLIBC_2.\(3\.4\|14\|17\|18\|25\|28\|29\|32\|33\|34\|\))" || echo)"
+                       if [ "$GLIBC_SYMBS" != "" ]; then
+                               echo "Unexpected glibc version dependency! Some users need glibc 2.35 support, symbols for newer glibcs cannot be included."
+                               echo "$GLIBC_SYMBS"
+                               exit 1
+                       fi
+                       REALLOC_ARRAY_SYMBS="$(objdump -T liblightningjni_release$LDK_TARGET_SUFFIX.so | grep reallocarray || echo)"
+                       if [ "$REALLOC_ARRAY_SYMBS" != "" ]; then
+                               echo "Unexpected reallocarray dependency!"
+                               exit 1
+                       fi
+               fi
+
                if [ "$LDK_JAR_TARGET" = "true" ]; then
                        # Copy to JNI native directory for inclusion in JARs
                        mkdir -p src/main/resources/