sed --version >/dev/null 2>&1
}
-if [ "$CC" != "" ]; then
- COMMON_COMPILE="$CC -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)="
-else
+if [ "$CC" = "" ]; then
CC=clang
- 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
+TARGET_STRING="$LDK_TARGET"
+if [ "$TARGET_STRING" = "" ]; then
+ # We assume clang-style $CC --version here, but worst-case we just get an empty suffix
+ TARGET_STRING="$($CC --version | grep Target | awk '{ print $2 }')"
+fi
+
+IS_MAC=false
+[ "$($CC --version | grep apple-darwin)" != "" ] && IS_MAC=true
+IS_APPLE_CLANG=false
+[ "$($CC --version | grep "Apple clang version")" != "" ] && IS_APPLE_CLANG=true
+
+case "$TARGET_STRING" in
+ "x86_64-pc-linux"*)
+ LDK_TARGET_SUFFIX="_Linux-amd64"
+ LDK_JAR_TARGET=true
+ ;;
+ "x86_64-apple-darwin"*)
+ LDK_TARGET_SUFFIX="_MacOSX-x86_64"
+ LDK_JAR_TARGET=true
+ IS_MAC=true
+ ;;
+ "aarch64-apple-darwin"*)
+ LDK_TARGET_CPU="apple-a14"
+ LDK_TARGET_SUFFIX="_MacOSX-aarch64"
+ LDK_JAR_TARGET=true
+ IS_MAC=true
+ ;;
+ *)
+ LDK_TARGET_SUFFIX="_${TARGET_STRING}"
+esac
+if [ "$LDK_TARGET_CPU" = "" ]; then
+ LDK_TARGET_CPU="sandybridge"
+fi
+
+COMMON_COMPILE="$CC -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)="
+[ "$IS_MAC" = "true" -a "$2" != "wasm" ] && COMMON_COMPILE="$COMMON_COMPILE --target=$TARGET_STRING -mcpu=$LDK_TARGET_CPU"
+
DEBUG_ARG="$3"
if [ "$3" = "leaks" ]; then
DEBUG_ARG="true"
if [ "$2" = "c_sharp" ]; then
- TARGET_STRING="$LDK_TARGET"
- if [ "$TARGET_STRING" = "" ]; then
- # We assume clang-style $CC --version here, but worst-case we just get an empty suffix
- TARGET_STRING="$($CC --version | grep Target | awk '{ print $2 }')"
- fi
- case "$TARGET_STRING" in
- "x86_64-pc-linux"*)
- LDK_TARGET_SUFFIX="_Linux-amd64"
- LDK_JAR_TARGET=true
- ;;
- "x86_64-apple-darwin"*)
- LDK_TARGET_SUFFIX="_MacOSX-x86_64"
- LDK_JAR_TARGET=true
- ;;
- "aarch64-apple-darwin"*)
- LDK_TARGET_CPU="apple-a14"
- LDK_TARGET_SUFFIX="_MacOSX-aarch64"
- LDK_JAR_TARGET=true
- ;;
- *)
- LDK_TARGET_SUFFIX="_${TARGET_STRING}"
- esac
- if [ "$LDK_TARGET_CPU" = "" ]; then
- LDK_TARGET_CPU="sandybridge"
- fi
-
echo "Creating C# bindings..."
mkdir -p c_sharp/src/org/ldk/{enums,structs,impl}
rm -f c_sharp/src/org/ldk/{enums,structs,impl}/*.cs
mv ./-out:csharpldk.dll csharpldk.dll # Mono is braindead, apparently
echo "Building C# bindings..."
- COMPILE="$COMMON_COMPILE -mcpu=$LDK_TARGET_CPU -Isrc/main/jni -pthread -fPIC"
+ COMPILE="$COMMON_COMPILE -Isrc/main/jni -pthread -fPIC"
LINK="-ldl -shared"
[ "$IS_MAC" = "false" ] && LINK="$LINK -Wl,--no-undefined"
[ "$IS_MAC" = "true" ] && COMPILE="$COMPILE -mmacosx-version-min=10.9"
llvm-strip liblightningjni_release$LDK_TARGET_SUFFIX.so
fi
elif [ "$2" = "python" ]; then
- TARGET_STRING="$LDK_TARGET"
- if [ "$TARGET_STRING" = "" ]; then
- # We assume clang-style $CC --version here, but worst-case we just get an empty suffix
- TARGET_STRING="$($CC --version | grep Target | awk '{ print $2 }')"
- fi
- case "$TARGET_STRING" in
- "x86_64-pc-linux"*)
- LDK_TARGET_SUFFIX="_Linux-amd64"
- LDK_JAR_TARGET=true
- ;;
- "x86_64-apple-darwin"*)
- LDK_TARGET_SUFFIX="_MacOSX-x86_64"
- LDK_JAR_TARGET=true
- ;;
- "aarch64-apple-darwin"*)
- LDK_TARGET_CPU="apple-a14"
- LDK_TARGET_SUFFIX="_MacOSX-aarch64"
- LDK_JAR_TARGET=true
- ;;
- *)
- LDK_TARGET_SUFFIX="_${TARGET_STRING}"
- esac
- if [ "$LDK_TARGET_CPU" = "" ]; then
- LDK_TARGET_CPU="sandybridge"
- fi
-
echo "Creating Python bindings..."
mkdir -p python/src/{enums,structs,impl}
rm -f python/src/{enums,structs,impl}/*.py
[ "$($CC --version | grep "Apple clang version")" != "" ] && IS_APPLE_CLANG=true
echo "Building Python bindings..."
- COMPILE="$COMMON_COMPILE -mcpu=$LDK_TARGET_CPU -Isrc/main/jni -pthread -fPIC"
+ COMPILE="$COMMON_COMPILE -Isrc/main/jni -pthread -fPIC"
LINK="-ldl -shared"
[ "$IS_MAC" = "false" ] && LINK="$LINK -Wl,--no-undefined"
[ "$IS_MAC" = "true" ] && COMPILE="$COMPILE -mmacosx-version-min=10.9"
fi
fi
else
- TARGET_STRING="$LDK_TARGET"
- if [ "$TARGET_STRING" = "" ]; then
- # We assume clang-style $CC --version here, but worst-case we just get an empty suffix
- TARGET_STRING="$($CC --version | grep Target | awk '{ print $2 }')"
- fi
- case "$TARGET_STRING" in
- "x86_64-pc-linux"*)
- LDK_TARGET_SUFFIX="_Linux-amd64"
- LDK_JAR_TARGET=true
- ;;
- "x86_64-apple-darwin"*)
- LDK_TARGET_SUFFIX="_MacOSX-x86_64"
- LDK_JAR_TARGET=true
- ;;
- "aarch64-apple-darwin"*)
- LDK_TARGET_CPU="apple-a14"
- LDK_TARGET_SUFFIX="_MacOSX-aarch64"
- LDK_JAR_TARGET=true
- ;;
- *)
- LDK_TARGET_SUFFIX="_${TARGET_STRING}"
- esac
- if [ "$LDK_TARGET_CPU" = "" ]; then
- LDK_TARGET_CPU="sandybridge"
- fi
-
if is_gnu_sed; then
sed -i "s/^ <version>.*<\/version>/ <version>${LDK_GARBAGECOLLECTED_GIT_OVERRIDE:1:100}<\/version>/g" pom.xml
else
javac -h src/main/jni src/main/java/org/ldk/enums/*.java src/main/java/org/ldk/impl/*.java
rm src/main/java/org/ldk/enums/*.class src/main/java/org/ldk/impl/bindings*.class
- IS_MAC=false
- [ "$($CC --version | grep apple-darwin)" != "" ] && IS_MAC=true
- IS_APPLE_CLANG=false
- [ "$($CC --version | grep "Apple clang version")" != "" ] && IS_APPLE_CLANG=true
-
echo "Building Java bindings..."
- COMPILE="$COMMON_COMPILE -mcpu=$LDK_TARGET_CPU -Isrc/main/jni -pthread -fPIC"
+ COMPILE="$COMMON_COMPILE -Isrc/main/jni -pthread -fPIC"
LINK="-ldl -shared"
[ "$IS_MAC" = "false" ] && LINK="$LINK -Wl,--no-undefined"
[ "$IS_MAC" = "true" ] && COMPILE="$COMPILE -mmacosx-version-min=10.9"