Closed lvaccaro closed 2 years ago
awesome, thanks! I had to make a few tweaks to make it work but otherwise LGTM. cherry-picked into b996fb8d1d7a6b578f48ce85fc951450a853bcdf
commit 1d57f518e5b8ff8fd3ce4b328437cdbd59c9bf3d
Author: William Casarin <jb55@jb55.com>
Date: Thu Jun 30 11:34:43 2022 -0700
fixup! add rust bindings
diff --git a/Makefile b/Makefile
index 3c656b7..ab7f60c 100644
--- a/Makefile
+++ b/Makefile
@@ -28,8 +28,10 @@ js: target/js/lnsocket.js target/js/lnsocket.wasm
node: target/node/lnsocket.js target/node/lnsocket.wasm
-rust: lnsocket.a
+liblnsocket.a: lnsocket.a
cp lnsocket.a liblnsocket.a
+
+rust: liblnsocket.a
cargo build --release
target/node/lnsocket.js: target/tmp/node/lnsocket.js lnsocket_lib.js
diff --git a/build.rs b/build.rs
index eaaf8f7..d2e5926 100644
--- a/build.rs
+++ b/build.rs
@@ -22,7 +22,8 @@ fn main() {
// bindings for.
.header("lnsocket.h")
.header("lnsocket_internal.h")
- .clang_arg("-Ideps/secp256k1/include/")
+ .clang_arg("-Ideps/secp256k1/include")
+ .clang_arg("-Ideps/libsodium/src/libsodium/include")
.header("deps/secp256k1/include/secp256k1.h")
.trust_clang_mangling(false)
// Finish the builder and generate the bindings.
thanks
Use bindgen to add rust bindings at lnsocket C library.
Generate rust bindings and target library with:
In
rust/lib.rs
, I open a demo socket connection to my experimental local node.I am not a rust expert, so I open MR for feedbacks.
NOTE: on arm64 platform, the code failed to compile: it expects a
*mut u8
instead*mut i8
onCStr::from_ptr()
.