2 if [ ! -x "$ANDROID_TOOLCHAIN/bin/clang" ]; then
3 echo "Please set ANDROID_TOOLCHAIN to the path to NDK" > /dev/stderr
7 if [ "$1" = "" -o ! -f "$1/lightning/Cargo.toml" ]; then
8 echo "Please set first argument to the path to rust-lightning" > /dev/stderr
12 if [ "$2" = "" -o ! -d "$2/lightning-c-bindings" ]; then
13 echo "Please set second argument to the path to ldk-c-bindings" > /dev/stderr
17 if [ ! -d "$3" -o ! -f "$3/AndroidManifest.xml" ]; then
18 echo "Please set third argument to the path to ldk-java-bins/android-artifacts" > /dev/stderr
25 LDK_C_BINDINGS="$(realpath $2)"
26 RUST_LIGHTNING="$(realpath $1)"
28 export LDK_C_BINDINGS_EXTRA_TARGETS="x86_64-linux-android armv7-linux-androideabi aarch64-linux-android"
29 export LDK_C_BINDINGS_EXTRA_TARGET_CCS="x86_64-linux-android24-clang armv7a-linux-androideabi24-clang aarch64-linux-android24-clang"
30 ./genbindings.sh "$RUST_LIGHTNING" true
33 export PATH=$PATH:$ANDROID_TOOLCHAIN/bin
34 export SYSROOT=$ANDROID_TOOLCHAIN/sysroot/
36 # Remove any non-Android libraries installed locally
37 rm -fr src/main/resources
39 EXTRA_TARGETS=( $LDK_C_BINDINGS_EXTRA_TARGETS )
40 EXTRA_TARGET_CCS=( $LDK_C_BINDINGS_EXTRA_TARGET_CCS )
41 TARGET_CPUS=( "sandybridge" "generic" "generic" )
42 STRIPS=( "x86_64-linux-android-strip" "arm-linux-androideabi-strip" "aarch64-linux-android-strip" )
43 for IDX in ${!EXTRA_TARGETS[@]}; do
44 export CC="${EXTRA_TARGET_CCS[$IDX]}"
45 export LDK_TARGET="${EXTRA_TARGETS[$IDX]}"
46 export LDK_TARGET_CPU="${TARGET_CPUS[$IDX]}"
47 # Note that we expect to often fail here if we don't have wasm32 bins in the C bindings dir
48 ./genbindings.sh "$LDK_C_BINDINGS" "-lm -llog -I$SYSROOT/usr/include/" false true || echo
49 ${STRIPS[$IDX]} liblightningjni_release_${LDK_TARGET}.so
54 echo "Need local deterministic ldk-java-classes.jar"
55 ls ldk-java-classes.jar
60 mkdir -p ./aar/jni/{armeabi-v7a,arm64-v8a,x86_64}
62 cp liblightningjni_release_aarch64-linux-android.so ./aar/jni/arm64-v8a/liblightningjni.so
63 cp liblightningjni_release_armv7-linux-androideabi.so ./aar/jni/armeabi-v7a/liblightningjni.so
64 cp liblightningjni_release_x86_64-linux-android.so ./aar/jni/x86_64/liblightningjni.so
65 cp ldk-java-classes.jar ./aar/classes.jar
69 find . | sort > ../sources-zip-files.txt
70 touch -d "2021-01-01 00:00 UTC" $(cat ../sources-zip-files.txt)
71 cat ../sources-zip-files.txt | zip -X@ ../LDK-release.aar