- name: Checkout latest MacOS binaries
run: |
export LDK_GARBAGECOLLECTED_GIT_OVERRIDE="$(cat .git_ver)"
- git clone https://git.bitcoin.ninja/ldk-java-bins
+ git clone --depth 1 https://git.bitcoin.ninja/ldk-java-bins
mkdir -p src/main/resources/
cp "ldk-java-bins/${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/liblightningjni_MacOSX-"* src/main/resources/
- name: Build Java/TS Release Bindings
run: ./build-release-jar.sh
- name: Run Java Tests against built release jar
run: |
- mvn install:install-file -Dfile=target/ldk-java-1.0-SNAPSHOT.jar -DgroupId=org.ldk -DartifactId=ldk-java -Dversion=1.0-SNAPSHOT -Dpackaging=jar
+ mvn install:install-file -Dfile=ldk-java.jar -DgroupId=org.ldk -DartifactId=ldk-java -Dversion=1.0-SNAPSHOT -Dpackaging=jar
cd javatester
mvn package
java -ea -jar target/ldk-java-tests-1.0-SNAPSHOT-jar-with-dependencies.jar
- name: Check latest library and jars are in bins repo
run: |
export LDK_GARBAGECOLLECTED_GIT_OVERRIDE="$(cat .git_ver)"
+ rm "ldk-java-bins/${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/"*.jar
+ rm "ldk-java-bins/${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/"liblightningjni_Linux*.nativelib
cp src/main/resources/liblightningjni_Linux-amd64.nativelib "ldk-java-bins/${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/"
- cp target/ldk-java-1.0-SNAPSHOT.jar "ldk-java-bins/${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/"
- cp target/ldk-java-1.0-SNAPSHOT-sources.jar "ldk-java-bins/${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/"
+ cp ldk-java-sources.jar "ldk-java-bins/${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/"
+ cp ldk-java.jar "ldk-java-bins/${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/"
+ cp ldk-java-classes.jar "ldk-java-bins/${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/"
+ cd ldk-java-bins
+ git diff --exit-code
+
+ android:
+ runs-on: ubuntu-latest
+ # Frankly, I'm not really sure why debian and ubuntu differ in the results here, they really shouldn't
+ container: debian:bullseye
+ env:
+ TOOLCHAIN: stable
+ steps:
+ - name: Install rust targets
+ run: |
+ apt-get update
+ apt-get -y dist-upgrade
+ apt-get -y install git g++ clang faketime zip unzip curl openjdk-11-jdk
+ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs > rustup.sh
+ chmod +x ./rustup.sh
+ ./rustup.sh -y
+ . $HOME/.cargo/env
+ rustup target add armv7-linux-androideabi
+ rustup target add aarch64-linux-android
+ rustup target add i686-linux-android
+ rustup target add x86_64-linux-android
+ - name: Checkout source code
+ uses: actions/checkout@v2
+ with:
+ fetch-depth: 0
+ - name: Install android NDK compilers
+ run: |
+ curl https://dl.google.com/android/repository/android-ndk-r22b-linux-x86_64.zip > android-ndk-r22b-linux-x86_64.zip
+ if [ "$(sha256sum android-ndk-r22b-linux-x86_64.zip | awk '{ print $1 }')" != "ac3a0421e76f71dd330d0cd55f9d99b9ac864c4c034fc67e0d671d022d4e806b" ]; then
+ echo "Bad hash"
+ exit 1
+ fi
+ unzip android-ndk-r22b-linux-x86_64.zip
+ - name: Install cbindgen
+ run: |
+ . $HOME/.cargo/env
+ cargo install --force cbindgen
+ - name: Checkout Rust-Lightning and LDK-C-Bindings git
+ run: |
+ git config --global user.email "ldk-ci@example.com"
+ git config --global user.name "LDK CI"
+ # Note this is a different endpoint, as we need one non-upstream commit!
+ git clone https://git.bitcoin.ninja/rust-lightning
+ cd rust-lightning
+ git checkout origin/2021-03-java-bindings-base
+ cd ..
+ git clone https://github.com/lightningdevkit/ldk-c-bindings
+ - name: Detect current git version
+ run: |
+ # We assume the top commit is just a bindings update commit, so we
+ # check out the previous commit to use as the commit we git describe.
+ # If the top commit is a merge commit, we need to get the last merge
+ # head and assume the latest bindings are built against its parent.
+ COMMIT_PARENTS=$(git show -s --pretty=format:%P HEAD)
+ if [ "${#COMMIT_PARENTS}" = 40 ]; then
+ export LDK_GARBAGECOLLECTED_GIT_OVERRIDE="$(git describe --tag HEAD^1)"
+ else
+ MERGE_HEAD=$(git show --pretty=format:%P HEAD | ( for last in $(cat /dev/stdin); do true; done; echo $last ))
+ export LDK_GARBAGECOLLECTED_GIT_OVERRIDE="$(git describe --tag $MERGE_HEAD^1)"
+ fi
+ echo "Using $LDK_GARBAGECOLLECTED_GIT_OVERRIDE as git version"
+ echo "$LDK_GARBAGECOLLECTED_GIT_OVERRIDE" > .git_ver
+ - name: Checkout Android AAR binaries and artifacts
+ run: git clone --depth 1 https://git.bitcoin.ninja/ldk-java-bins
+ - name: Build Android aar
+ run: |
+ . $HOME/.cargo/env
+ export LDK_GARBAGECOLLECTED_GIT_OVERRIDE="$(cat .git_ver)"
+ cp "ldk-java-bins/${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/ldk-java-classes.jar" ./
+ export ANDROID_TOOLCHAIN="$(pwd)/android-ndk-r22b/toolchains/llvm/prebuilt/linux-x86_64"
+ export PATH="$PATH:$ANDROID_TOOLCHAIN/bin"
+ ./android-build.sh ./rust-lightning ./ldk-c-bindings/ ./ldk-java-bins/android-artifacts
+ - name: Check latest library and jars are in bins repo
+ run: |
+ export LDK_GARBAGECOLLECTED_GIT_OVERRIDE="$(cat .git_ver)"
+ rm "ldk-java-bins/${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/LDK-release.aar"
+ cp LDK-release.aar "ldk-java-bins/${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/"
cd ldk-java-bins
git diff --exit-code
- name: Checkout latest Linux binaries
run: |
export LDK_GARBAGECOLLECTED_GIT_OVERRIDE="$(cat .git_ver)"
- git clone https://git.bitcoin.ninja/ldk-java-bins
+ git clone --depth 1 https://git.bitcoin.ninja/ldk-java-bins
mkdir -p src/main/resources/
cp "ldk-java-bins/${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/liblightningjni_Linux-"* src/main/resources/
- name: Build Java/TS Release Bindings
--- /dev/null
+#!/bin/bash
+if [ ! -x "$ANDROID_TOOLCHAIN/bin/clang" ]; then
+ echo "Please set ANDROID_TOOLCHAIN to the path to NDK" > /dev/stderr
+ exit 1
+fi
+
+if [ "$1" = "" -o ! -f "$1/lightning/Cargo.toml" ]; then
+ echo "Please set first argument to the path to rust-lightning" > /dev/stderr
+ exit 1
+fi
+
+if [ "$2" = "" -o ! -d "$2/lightning-c-bindings" ]; then
+ echo "Please set second argument to the path to ldk-c-bindings" > /dev/stderr
+ exit 1
+fi
+
+if [ ! -d "$3" -o ! -f "$3/AndroidManifest.xml" ]; then
+ echo "Please set third argument to the path to ldk-java-bins/android-artifacts" > /dev/stderr
+ exit 1
+fi
+
+set -e
+set -x
+
+LDK_C_BINDINGS="$(realpath $2)"
+RUST_LIGHTNING="$(realpath $1)"
+pushd "$2"
+export LDK_C_BINDINGS_EXTRA_TARGETS="x86_64-linux-android i686-linux-android armv7-linux-androideabi aarch64-linux-android"
+export LDK_C_BINDINGS_EXTRA_TARGET_CCS="x86_64-linux-android21-clang i686-linux-android21-clang armv7a-linux-androideabi21-clang aarch64-linux-android21-clang"
+./genbindings.sh "$RUST_LIGHTNING" true
+popd
+
+export PATH=$PATH:$ANDROID_TOOLCHAIN/bin
+export SYSROOT=$ANDROID_TOOLCHAIN/sysroot/
+
+# Remove any non-Android libraries installed locally
+rm -fr src/main/resources
+
+EXTRA_TARGETS=( $LDK_C_BINDINGS_EXTRA_TARGETS )
+EXTRA_TARGET_CCS=( $LDK_C_BINDINGS_EXTRA_TARGET_CCS )
+TARGET_CPUS=( "sandybridge" "generic" "generic" "generic" )
+STRIPS=( "x86_64-linux-android-strip" "i686-linux-android-strip" "arm-linux-androideabi-strip" "aarch64-linux-android-strip" )
+for IDX in ${!EXTRA_TARGETS[@]}; do
+ export CC="${EXTRA_TARGET_CCS[$IDX]}"
+ export LDK_TARGET="${EXTRA_TARGETS[$IDX]}"
+ export LDK_TARGET_CPU="${TARGET_CPUS[$IDX]}"
+ # Note that we expect to often fail here if we don't have wasm32 bins in the C bindings dir
+ ./genbindings.sh "$LDK_C_BINDINGS" "-lm -llog -I$SYSROOT/usr/include/" false true || echo
+ ${STRIPS[$IDX]} liblightningjni_release_${LDK_TARGET}.so
+done
+
+export LANG=C
+
+echo "Need local deterministic ldk-java-classes.jar"
+ls ldk-java-classes.jar
+
+rm -rf aar
+mkdir aar
+cp -r "$3/"* ./aar/
+mkdir -p ./aar/jni/{arm64,armeabi,x86,x86_64}
+
+cp liblightningjni_release_aarch64-linux-android.so ./aar/jni/arm64/liblightningjni.so
+cp liblightningjni_release_armv7-linux-androideabi.so ./aar/jni/armeabi/liblightningjni.so
+cp liblightningjni_release_i686-linux-android.so ./aar/jni/x86/liblightningjni.so
+cp liblightningjni_release_x86_64-linux-android.so ./aar/jni/x86_64/liblightningjni.so
+cp ldk-java-classes.jar ./aar/classes.jar
+
+rm -f LDK-release.aar
+cd ./aar
+find . | sort > ../sources-zip-files.txt
+touch -d "2021-01-01 00:00 UTC" $(cat ../sources-zip-files.txt)
+cat ../sources-zip-files.txt | zip -X@ ../LDK-release.aar
+cd ..
+rm -r aar
$COMPILE -o liblightningjni_debug$LDK_TARGET_SUFFIX.so -g -fsanitize=address -shared-libasan -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
LDK_LIB="$1"/lightning-c-bindings/target/$LDK_TARGET/release/libldk.a
- if [ "$IS_MAC" = "false" ]; then
+ if [ "$IS_MAC" = "false" -a "$4" = "false" ]; then
COMPILE="$COMPILE -Wl,--version-script=libcode.version -fuse-ld=lld"
# __cxa_thread_atexit_impl is used to more effeciently cleanup per-thread local storage by rust libstd.
# However, it is not available on glibc versions 2.17 or earlier, and rust libstd has a null-check and
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
- if [ "$IS_MAC" = "false" ]; then
+ 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
echo "Unexpected glibc version dependency! Some users need glibc 2.17 support, symbols for newer glibcs cannot be included."