--- /dev/null
+name: Continuous Integration Checks
+
+on: [push, pull_request]
+
+jobs:
+ check_bindings:
+ runs-on: ubuntu-latest
+ # Ubuntu's version of rustc uses its own LLVM instead of being a real native package.
+ # This leaves us with an incompatible LLVM version when linking. Instead, use a real OS.
+ container: debian:bullseye
+ env:
+ TOOLCHAIN: stable
+ steps:
+ - name: Install native Rust toolchain, Valgrind, and build utilitis
+ run: |
+ apt-get update
+ apt-get -y dist-upgrade
+ apt-get -y install cargo valgrind lld git g++ clang
+ - name: Checkout source code
+ uses: actions/checkout@v2
+ - name: Sanity test bindings against Cargo.toml RL
+ working-directory: lightning-c-bindings
+ run: cargo check
+ - name: Install cbindgen
+ run: cargo install --force cbindgen
+ - name: Checkout Rust-Lightning git
+ run: git clone https://github.com/rust-bitcoin/rust-lightning
+ - name: Rebuild bindings, and check the sample app builds + links
+ run: ./genbindings.sh ./rust-lightning
+ - name: Check that the latest bindings are in git
+ run: |
+ git checkout lightning-c-bindings/Cargo.toml # genbindings edits this to update the path
+ if [ "$(git diff)" != "" ]; then
+ # cbindgen's bindings output order can be FS-dependant, so check that the lines are all the same:
+ mv lightning-c-bindings/include/lightning.h lightning-c-bindings/include/lightning.h.new
+ git checkout lightning-c-bindings/include/lightning.h
+ cat lightning-c-bindings/include/lightning.h | grep -v "Generated with cbindgen:[0-9\.]*" | sort > lightning-c-bindings/include/lightning.h.sorted
+ cat lightning-c-bindings/include/lightning.h.new | grep -v "Generated with cbindgen:[0-9\.]*" | sort > lightning-c-bindings/include/lightning.h.new.sorted
+ diff lightning-c-bindings/include/lightning.h.sorted lightning-c-bindings/include/lightning.h.new.sorted
+ [ "$(diff lightning-c-bindings/include/lightning.h.sorted lightning-c-bindings/include/lightning.h.new.sorted)" != "" ] && exit 2
+ git diff --exit-code
+ fi
+
set -e
set -x
+if [ ! -d "$1/lightning" ]; then
+ echo "USAGE: $0 path-to-rust-lightning"
+ exit 1
+fi
+
+# On reasonable systems, we can use realpath here, but OSX is a diva with 20-year-old software.
+ORIG_PWD="$(pwd)"
+cd "$1/lightning"
+LIGHTNING_PATH="$(pwd)"
+cd "$ORIG_PWD"
+
# Generate (and reasonably test) C bindings
# First build the latest c-bindings-gen binary
OUT_TEMPL="$(pwd)/lightning-c-bindings/src/c_types/derived.rs"
OUT_F="$(pwd)/lightning-c-bindings/include/rust_types.h"
OUT_CPP="$(pwd)/lightning-c-bindings/include/lightningpp.hpp"
+BIN="$(pwd)/c-bindings-gen/target/release/c-bindings-gen"
-cd lightning
+pushd "$LIGHTNING_PATH"
RUSTC_BOOTSTRAP=1 cargo rustc --profile=check -- -Zunstable-options --pretty=expanded |
- RUST_BACKTRACE=1 ../c-bindings-gen/target/release/c-bindings-gen $OUT/ lightning $OUT_TEMPL $OUT_F $OUT_CPP
-cd ..
+ RUST_BACKTRACE=1 "$BIN" "$OUT/" lightning "$OUT_TEMPL" "$OUT_F" "$OUT_CPP"
+popd
+
+HOST_PLATFORM="$(rustc --version --verbose | grep "host:")"
+if [ "$HOST_PLATFORM" = "host: x86_64-apple-darwin" ]; then
+ # OSX sed is for some reason not compatible with GNU sed
+ sed -i '' 's|lightning = { .*|lightning = { path = "'"$LIGHTNING_PATH"'" }|' lightning-c-bindings/Cargo.toml
+else
+ sed -i 's|lightning = { .*|lightning = { path = "'"$LIGHTNING_PATH"'" }|' lightning-c-bindings/Cargo.toml
+fi
# Now cd to lightning-c-bindings, build the generated bindings, and call cbindgen to build a C header file
PATH="$PATH:~/.cargo/bin"
cargo build
cbindgen -v --config cbindgen.toml -o include/lightning.h >/dev/null 2>&1
-HOST_PLATFORM="$(rustc --version --verbose | grep "host:")"
-
# cbindgen is relatively braindead when exporting typedefs -
# it happily exports all our typedefs for private types, even with the
# generics we specified in C mode! So we drop all those types manually here.
[dependencies]
bitcoin = "0.26"
secp256k1 = { version = "0.20.1", features = ["global-context-less-secure"] }
-lightning = { version = "0.0.12", path = "../lightning" }
+# Note that the following line is matched by genbindings to update the path
+lightning = { git = "https://github.com/rust-bitcoin/rust-lightning", rev = "8b4ea56966878140b11aa3e17b44fcf1e01d6413" }
[patch.crates-io]
# Rust-Secp256k1 PR 279. Should be dropped once merged.
[profile.release]
panic = "abort"
-
-# We eventually want to join the root workspace, but for now, the bindings generation is
-# a bit brittle and we don't want to hold up other developers from making changes just
-# because they break the bindings
-[workspace]
* It will send pings to each peer and disconnect those which did not respond to the last round of pings.
* Will most likely call send_data on all of the registered descriptors, thus, be very careful with reentrancy issues!
*/
-void PeerManager_timer_tick_occured(const struct LDKPeerManager *NONNULL_PTR this_arg);
+void PeerManager_timer_tick_occurred(const struct LDKPeerManager *NONNULL_PTR this_arg);
/**
* Build the commitment secret from the seed and the commitment number
/// It will send pings to each peer and disconnect those which did not respond to the last round of pings.
/// Will most likely call send_data on all of the registered descriptors, thus, be very careful with reentrancy issues!
#[no_mangle]
-pub extern "C" fn PeerManager_timer_tick_occured(this_arg: &PeerManager) {
- unsafe { &*this_arg.inner }.timer_tick_occured()
+pub extern "C" fn PeerManager_timer_tick_occurred(this_arg: &PeerManager) {
+ unsafe { &*this_arg.inner }.timer_tick_occurred()
}